fix: todo修改
This commit is contained in:
@@ -24,6 +24,49 @@ export namespace MpDraftApi {
|
|||||||
articles: Article[];
|
articles: Article[];
|
||||||
createTime?: Date;
|
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',
|
fieldName: 'reply',
|
||||||
label: '回复消息',
|
label: '回复消息',
|
||||||
component: markRaw(WxReply),
|
component: markRaw(WxReply),
|
||||||
// TODO @hw:这里注释,要不要删除掉?
|
|
||||||
// componentProps: {
|
|
||||||
// modelValue: { type: 'video', content: '12456' },
|
|
||||||
// },
|
|
||||||
modelPropName: 'modelValue',
|
modelPropName: 'modelValue',
|
||||||
});
|
});
|
||||||
return schema;
|
return schema;
|
||||||
|
|||||||
@@ -113,13 +113,6 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
// 编辑:加载数据
|
// 编辑:加载数据
|
||||||
const rowData = data.row;
|
const rowData = data.row;
|
||||||
const formValues: any = { ...rowData };
|
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 = {
|
formValues.reply = {
|
||||||
type: rowData.responseMessageType,
|
type: rowData.responseMessageType,
|
||||||
accountId: data.accountId || -1,
|
accountId: data.accountId || -1,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Article } from './modules/types';
|
|
||||||
|
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MpDraftApi } from '#/api/mp/draft';
|
||||||
|
|
||||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
@@ -9,9 +8,8 @@ import { $t } from '@vben/locales';
|
|||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
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 { submitFreePublish } from '#/api/mp/freePublish';
|
||||||
import { createEmptyNewsItem } from '#/views/mp/draft/modules/types';
|
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
import DraftTableCell from './modules/draft-table.vue';
|
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 formValues = await gridApi.formApi.getValues();
|
||||||
const accountId = formValues.accountId;
|
const accountId = formValues.accountId;
|
||||||
if (!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 formValues = await gridApi.formApi.getValues();
|
||||||
const accountId = formValues.accountId;
|
const accountId = formValues.accountId;
|
||||||
if (!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 formValues = await gridApi.formApi.getValues();
|
||||||
const accountId = formValues.accountId;
|
const accountId = formValues.accountId;
|
||||||
if (!accountId) {
|
if (!accountId) {
|
||||||
@@ -139,7 +137,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
list: drafts.list as unknown as Article[],
|
list: drafts.list as unknown as MpDraftApi.DraftArticle[],
|
||||||
total: drafts.total,
|
total: drafts.total,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -153,8 +151,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
refresh: true,
|
refresh: true,
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
// TODO @hw:这里有点纠结,一般是 MpDraftApi.Article,但是一改貌似就 linter 告警了。
|
} as VxeTableGridOptions<MpDraftApi.DraftArticle>,
|
||||||
} as VxeTableGridOptions<Article>,
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { UploadFile } from 'ant-design-vue';
|
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';
|
import { computed, inject, reactive, ref } from 'vue';
|
||||||
|
|
||||||
@@ -14,16 +14,16 @@ import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
isFirst: boolean;
|
isFirst: boolean;
|
||||||
modelValue: NewsItem;
|
modelValue: MpDraftApi.NewsItem;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
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 UPLOAD_URL = `${import.meta.env.VITE_BASE_URL}/admin-api/mp/material/upload-permanent`; // 上传永久素材的地址
|
||||||
const HEADERS = { Authorization: `Bearer ${useAccessStore().accessToken}` };
|
const HEADERS = { Authorization: `Bearer ${useAccessStore().accessToken}` };
|
||||||
const newsItem = computed<NewsItem>({
|
const newsItem = computed<MpDraftApi.NewsItem>({
|
||||||
get() {
|
get() {
|
||||||
return props.modelValue;
|
return props.modelValue;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Article } from './types';
|
import type { MpDraftApi } from '#/api/mp/draft';
|
||||||
|
|
||||||
import { WxNews } from '#/views/mp/components';
|
import { WxNews } from '#/views/mp/components';
|
||||||
|
|
||||||
defineOptions({ name: 'DraftTableCell' });
|
defineOptions({ name: 'DraftTableCell' });
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
row: Article;
|
row: MpDraftApi.DraftArticle;
|
||||||
}>();
|
}>();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { NewsItem } from './types';
|
import type { MpDraftApi } from '#/api/mp/draft';
|
||||||
|
|
||||||
import { computed, provide, ref } from 'vue';
|
import { computed, provide, ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
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';
|
import { createDraft, updateDraft } from '#/api/mp/draft';
|
||||||
|
|
||||||
@@ -16,10 +16,9 @@ const emit = defineEmits(['success']);
|
|||||||
const formData = ref<{
|
const formData = ref<{
|
||||||
accountId: number;
|
accountId: number;
|
||||||
mediaId?: string;
|
mediaId?: string;
|
||||||
newsList?: NewsItem[];
|
newsList?: MpDraftApi.NewsItem[];
|
||||||
}>();
|
}>();
|
||||||
const newsList = ref<NewsItem[]>([]);
|
const newsList = ref<MpDraftApi.NewsItem[]>([]);
|
||||||
const isSubmitting = ref(false);
|
|
||||||
|
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
return formData.value?.mediaId ? '修改图文' : '新建图文';
|
return formData.value?.mediaId ? '修改图文' : '新建图文';
|
||||||
@@ -36,8 +35,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @hw:是不是 isSubmitting 非必须哈?因为 modal 已经去 lock 啦。
|
// DONE @hw:是不是 isSubmitting 非必须哈?因为 modal 已经去 lock 啦。
|
||||||
isSubmitting.value = true;
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
if (formData.value.mediaId) {
|
if (formData.value.mediaId) {
|
||||||
@@ -54,7 +52,6 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
await modalApi.close();
|
await modalApi.close();
|
||||||
emit('success');
|
emit('success');
|
||||||
} finally {
|
} finally {
|
||||||
isSubmitting.value = false;
|
|
||||||
modalApi.unlock();
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -68,7 +65,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
accountId: number;
|
accountId: number;
|
||||||
isCreating: boolean;
|
isCreating: boolean;
|
||||||
mediaId?: string;
|
mediaId?: string;
|
||||||
newsList?: NewsItem[];
|
newsList?: MpDraftApi.NewsItem[];
|
||||||
}>();
|
}>();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
@@ -85,12 +82,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :title="getTitle" class="w-4/5" destroy-on-close>
|
<Modal :title="getTitle" class="w-4/5" destroy-on-close>
|
||||||
<Spin :spinning="isSubmitting">
|
|
||||||
<NewsForm
|
<NewsForm
|
||||||
v-if="formData"
|
v-if="formData"
|
||||||
v-model="newsList"
|
v-model="newsList"
|
||||||
:is-creating="!formData.mediaId"
|
:is-creating="!formData.mediaId"
|
||||||
/>
|
/>
|
||||||
</Spin>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { NewsItem } from './types';
|
import type { MpDraftApi } from '#/api/mp/draft';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
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 { Button, Col, Input, Layout, Row, Textarea } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { createEmptyNewsItem } from '#/api/mp/draft';
|
||||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||||
|
|
||||||
import CoverSelect from './cover-select.vue';
|
import CoverSelect from './cover-select.vue';
|
||||||
import { createEmptyNewsItem } from './types';
|
|
||||||
|
|
||||||
defineOptions({ name: 'NewsForm' });
|
defineOptions({ name: 'NewsForm' });
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
isCreating: boolean;
|
isCreating: boolean;
|
||||||
modelValue: NewsItem[] | null;
|
modelValue: MpDraftApi.NewsItem[] | null;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
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() {
|
get() {
|
||||||
return props.modelValue === null
|
return props.modelValue === null
|
||||||
? [createEmptyNewsItem()]
|
? [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