fix: todo修改
This commit is contained in:
@@ -24,6 +24,49 @@ export namespace MpDraftApi {
|
||||
articles: Article[];
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 图文项(包含预览字段) */
|
||||
export interface NewsItem {
|
||||
title: string;
|
||||
thumbMediaId: string;
|
||||
author: string;
|
||||
digest: string;
|
||||
showCoverPic: number;
|
||||
content: string;
|
||||
contentSourceUrl: string;
|
||||
needOpenComment: number;
|
||||
onlyFansCanComment: number;
|
||||
thumbUrl: string;
|
||||
picUrl?: string; // 用于预览封面
|
||||
}
|
||||
|
||||
/** 图文列表 */
|
||||
export interface NewsItemList {
|
||||
newsItem: NewsItem[];
|
||||
}
|
||||
|
||||
/** 草稿文章(用于展示) */
|
||||
export interface DraftArticle {
|
||||
mediaId: string;
|
||||
content: NewsItemList;
|
||||
updateTime: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 创建空的图文项 */
|
||||
export function createEmptyNewsItem(): MpDraftApi.NewsItem {
|
||||
return {
|
||||
title: '',
|
||||
thumbMediaId: '',
|
||||
author: '',
|
||||
digest: '',
|
||||
showCoverPic: 0,
|
||||
content: '',
|
||||
contentSourceUrl: '',
|
||||
needOpenComment: 0,
|
||||
onlyFansCanComment: 0,
|
||||
thumbUrl: '',
|
||||
};
|
||||
}
|
||||
|
||||
/** 查询草稿列表 */
|
||||
|
||||
@@ -149,10 +149,6 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
|
||||
fieldName: 'reply',
|
||||
label: '回复消息',
|
||||
component: markRaw(WxReply),
|
||||
// TODO @hw:这里注释,要不要删除掉?
|
||||
// componentProps: {
|
||||
// modelValue: { type: 'video', content: '12456' },
|
||||
// },
|
||||
modelPropName: 'modelValue',
|
||||
});
|
||||
return schema;
|
||||
|
||||
@@ -113,13 +113,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
// 编辑:加载数据
|
||||
const rowData = data.row;
|
||||
const formValues: any = { ...rowData };
|
||||
// TODO @hw:下面要删除掉么,注释。
|
||||
// delete formValues.responseMessageType;
|
||||
// delete formValues.responseContent;
|
||||
// delete formValues.responseMediaId;
|
||||
// delete formValues.responseMediaUrl;
|
||||
// delete formValues.responseDescription;
|
||||
// delete formValues.responseArticles;
|
||||
formValues.reply = {
|
||||
type: rowData.responseMessageType,
|
||||
accountId: data.accountId || -1,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Article } from './modules/types';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MpDraftApi } from '#/api/mp/draft';
|
||||
|
||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
@@ -9,9 +8,8 @@ import { $t } from '@vben/locales';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteDraft, getDraftPage } from '#/api/mp/draft';
|
||||
import { createEmptyNewsItem, deleteDraft, getDraftPage } from '#/api/mp/draft';
|
||||
import { submitFreePublish } from '#/api/mp/freePublish';
|
||||
import { createEmptyNewsItem } from '#/views/mp/draft/modules/types';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import DraftTableCell from './modules/draft-table.vue';
|
||||
@@ -42,7 +40,7 @@ async function handleCreate() {
|
||||
}
|
||||
|
||||
/** 修改草稿 */
|
||||
async function handleEdit(row: Article) {
|
||||
async function handleEdit(row: MpDraftApi.DraftArticle) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
if (!accountId) {
|
||||
@@ -60,7 +58,7 @@ async function handleEdit(row: Article) {
|
||||
}
|
||||
|
||||
/** 删除草稿 */
|
||||
async function handleDelete(row: Article) {
|
||||
async function handleDelete(row: MpDraftApi.DraftArticle) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
if (!accountId) {
|
||||
@@ -82,7 +80,7 @@ async function handleDelete(row: Article) {
|
||||
}
|
||||
|
||||
/** 发布草稿 */
|
||||
async function handlePublish(row: Article) {
|
||||
async function handlePublish(row: MpDraftApi.DraftArticle) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
if (!accountId) {
|
||||
@@ -139,7 +137,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
}
|
||||
});
|
||||
return {
|
||||
list: drafts.list as unknown as Article[],
|
||||
list: drafts.list as unknown as MpDraftApi.DraftArticle[],
|
||||
total: drafts.total,
|
||||
};
|
||||
},
|
||||
@@ -153,8 +151,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
// TODO @hw:这里有点纠结,一般是 MpDraftApi.Article,但是一改貌似就 linter 告警了。
|
||||
} as VxeTableGridOptions<Article>,
|
||||
} as VxeTableGridOptions<MpDraftApi.DraftArticle>,
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { UploadFile } from 'ant-design-vue';
|
||||
|
||||
import type { NewsItem } from './types';
|
||||
import type { MpDraftApi } from '#/api/mp/draft';
|
||||
|
||||
import { computed, inject, reactive, ref } from 'vue';
|
||||
|
||||
@@ -14,16 +14,16 @@ import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||
|
||||
const props = defineProps<{
|
||||
isFirst: boolean;
|
||||
modelValue: NewsItem;
|
||||
modelValue: MpDraftApi.NewsItem;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', v: NewsItem): void;
|
||||
(e: 'update:modelValue', v: MpDraftApi.NewsItem): void;
|
||||
}>();
|
||||
|
||||
const UPLOAD_URL = `${import.meta.env.VITE_BASE_URL}/admin-api/mp/material/upload-permanent`; // 上传永久素材的地址
|
||||
const HEADERS = { Authorization: `Bearer ${useAccessStore().accessToken}` };
|
||||
const newsItem = computed<NewsItem>({
|
||||
const newsItem = computed<MpDraftApi.NewsItem>({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
},
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Article } from './types';
|
||||
import type { MpDraftApi } from '#/api/mp/draft';
|
||||
|
||||
import { WxNews } from '#/views/mp/components';
|
||||
|
||||
defineOptions({ name: 'DraftTableCell' });
|
||||
|
||||
const props = defineProps<{
|
||||
row: Article;
|
||||
row: MpDraftApi.DraftArticle;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import type { NewsItem } from './types';
|
||||
import type { MpDraftApi } from '#/api/mp/draft';
|
||||
|
||||
import { computed, provide, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message, Spin } from 'ant-design-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { createDraft, updateDraft } from '#/api/mp/draft';
|
||||
|
||||
@@ -16,10 +16,9 @@ const emit = defineEmits(['success']);
|
||||
const formData = ref<{
|
||||
accountId: number;
|
||||
mediaId?: string;
|
||||
newsList?: NewsItem[];
|
||||
newsList?: MpDraftApi.NewsItem[];
|
||||
}>();
|
||||
const newsList = ref<NewsItem[]>([]);
|
||||
const isSubmitting = ref(false);
|
||||
const newsList = ref<MpDraftApi.NewsItem[]>([]);
|
||||
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.mediaId ? '修改图文' : '新建图文';
|
||||
@@ -36,8 +35,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO @hw:是不是 isSubmitting 非必须哈?因为 modal 已经去 lock 啦。
|
||||
isSubmitting.value = true;
|
||||
// DONE @hw:是不是 isSubmitting 非必须哈?因为 modal 已经去 lock 啦。
|
||||
modalApi.lock();
|
||||
try {
|
||||
if (formData.value.mediaId) {
|
||||
@@ -54,7 +52,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
isSubmitting.value = false;
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
@@ -68,7 +65,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
accountId: number;
|
||||
isCreating: boolean;
|
||||
mediaId?: string;
|
||||
newsList?: NewsItem[];
|
||||
newsList?: MpDraftApi.NewsItem[];
|
||||
}>();
|
||||
if (!data) {
|
||||
return;
|
||||
@@ -85,12 +82,10 @@ const [Modal, modalApi] = useVbenModal({
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-4/5" destroy-on-close>
|
||||
<Spin :spinning="isSubmitting">
|
||||
<NewsForm
|
||||
v-if="formData"
|
||||
v-model="newsList"
|
||||
:is-creating="!formData.mediaId"
|
||||
/>
|
||||
</Spin>
|
||||
<NewsForm
|
||||
v-if="formData"
|
||||
v-model="newsList"
|
||||
:is-creating="!formData.mediaId"
|
||||
/>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { NewsItem } from './types';
|
||||
import type { MpDraftApi } from '#/api/mp/draft';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
@@ -8,23 +8,23 @@ import { IconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Col, Input, Layout, Row, Textarea } from 'ant-design-vue';
|
||||
|
||||
import { createEmptyNewsItem } from '#/api/mp/draft';
|
||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||
|
||||
import CoverSelect from './cover-select.vue';
|
||||
import { createEmptyNewsItem } from './types';
|
||||
|
||||
defineOptions({ name: 'NewsForm' });
|
||||
|
||||
const props = defineProps<{
|
||||
isCreating: boolean;
|
||||
modelValue: NewsItem[] | null;
|
||||
modelValue: MpDraftApi.NewsItem[] | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', v: NewsItem[]): void;
|
||||
(e: 'update:modelValue', v: MpDraftApi.NewsItem[]): void;
|
||||
}>();
|
||||
|
||||
const newsList = computed<NewsItem[]>({
|
||||
const newsList = computed<MpDraftApi.NewsItem[]>({
|
||||
get() {
|
||||
return props.modelValue === null
|
||||
? [createEmptyNewsItem()]
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
// TODO @hw:这个要融合到 draftApi 里么?类似其他模块的。
|
||||
interface NewsItem {
|
||||
title: string;
|
||||
thumbMediaId: string;
|
||||
author: string;
|
||||
digest: string;
|
||||
showCoverPic: number;
|
||||
content: string;
|
||||
contentSourceUrl: string;
|
||||
needOpenComment: number;
|
||||
onlyFansCanComment: number;
|
||||
thumbUrl: string;
|
||||
picUrl?: string; // 用于预览封面
|
||||
}
|
||||
|
||||
interface NewsItemList {
|
||||
newsItem: NewsItem[];
|
||||
}
|
||||
|
||||
interface Article {
|
||||
mediaId: string;
|
||||
content: NewsItemList;
|
||||
updateTime: number;
|
||||
}
|
||||
|
||||
function createEmptyNewsItem(): NewsItem {
|
||||
return {
|
||||
title: '',
|
||||
thumbMediaId: '',
|
||||
author: '',
|
||||
digest: '',
|
||||
showCoverPic: 0,
|
||||
content: '',
|
||||
contentSourceUrl: '',
|
||||
needOpenComment: 0,
|
||||
onlyFansCanComment: 0,
|
||||
thumbUrl: '',
|
||||
};
|
||||
}
|
||||
|
||||
export type { Article, NewsItem, NewsItemList };
|
||||
export { createEmptyNewsItem };
|
||||
Reference in New Issue
Block a user