1. 重命名 DataGrid 为 MessageTable,增加可读性

2. 调整素材管理,读取 API 接口

(cherry picked from commit 48c7b58b03)
This commit is contained in:
YunaiV 2023-04-15 08:42:52 +08:00 committed by shizhong
parent f0ad6b706e
commit 01691827fc
5 changed files with 15 additions and 14 deletions

View File

@ -17,10 +17,6 @@ const emit = defineEmits<{
(e: 'change', id?: number, name?: string): void (e: 'change', id?: number, name?: string): void
}>() }>()
onMounted(() => {
handleQuery()
})
const handleQuery = async () => { const handleQuery = async () => {
accountList.value = await MpAccountApi.getSimpleAccountList() accountList.value = await MpAccountApi.getSimpleAccountList()
// //
@ -33,4 +29,9 @@ const handleQuery = async () => {
const onChanged = () => { const onChanged = () => {
emit('change', account.id, account.name) emit('change', account.id, account.name)
} }
/** 初始化 */
onMounted(() => {
handleQuery()
})
</script> </script>

View File

@ -21,7 +21,10 @@ export const createEditorConfig = (
allowedFileTypes: ['image/*'], allowedFileTypes: ['image/*'],
// 自定义上传参数,例如传递验证的 token 等。参数会被添加到 formData 中,一起上传到服务端。 // 自定义上传参数,例如传递验证的 token 等。参数会被添加到 formData 中,一起上传到服务端。
meta: { accountId: accountId }, meta: {
accountId: accountId,
type: 'image'
},
// 将 meta 拼接到 url 参数中,默认 false // 将 meta 拼接到 url 参数中,默认 false
metaWithUrl: true, metaWithUrl: true,
@ -64,7 +67,7 @@ export const createEditorConfig = (
}, },
// 自定义插入图片 // 自定义插入图片
customInsert(res: any, insertFn: InsertFnType) { customInsert(res: any, insertFn: InsertFnType) {
insertFn(res.data, 'image', res.data) insertFn(res.data.url, 'image', res.data.url)
} }
} }
} }

View File

@ -265,8 +265,7 @@ import * as MpDraftApi from '@/api/mp/draft'
import * as MpFreePublishApi from '@/api/mp/freePublish' import * as MpFreePublishApi from '@/api/mp/freePublish'
import type { UploadFiles, UploadProps, UploadRawFile } from 'element-plus' import type { UploadFiles, UploadProps, UploadRawFile } from 'element-plus'
import { createEditorConfig } from './editor-config' import { createEditorConfig } from './editor-config'
// API // import drafts from './mock' // API
import drafts from './mock'
import { IEditorConfig } from '@wangeditor/editor' import { IEditorConfig } from '@wangeditor/editor'
const message = useMessage() // const message = useMessage() //
@ -342,7 +341,7 @@ const editorConfig = ref<Partial<IEditorConfig>>({})
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
// const drafts = await MpDraftApi.getDraftPage(queryParams) const drafts = await MpDraftApi.getDraftPage(queryParams)
drafts.list.forEach((item) => { drafts.list.forEach((item) => {
const newsItem = item.content.newsItem const newsItem = item.content.newsItem
// thumbUrl picUrl wx-news // thumbUrl picUrl wx-news

View File

@ -143,5 +143,3 @@ const props = defineProps({
const emit = defineEmits<{ (e: 'send', v: number) }>() const emit = defineEmits<{ (e: 'send', v: number) }>()
</script> </script>
<style scoped></style>

View File

@ -58,7 +58,7 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<DataGrid :list="list" :loading="loading" @send="handleSend" /> <MessageTable :list="list" :loading="loading" @send="handleSend" />
<Pagination <Pagination
v-show="total > 0" v-show="total > 0"
:total="total" :total="total"
@ -83,7 +83,7 @@
import * as MpMessageApi from '@/api/mp/message' import * as MpMessageApi from '@/api/mp/message'
import WxMsg from '@/views/mp/components/wx-msg/main.vue' import WxMsg from '@/views/mp/components/wx-msg/main.vue'
import WxAccountSelect from '@/views/mp/components/wx-account-select/main.vue' import WxAccountSelect from '@/views/mp/components/wx-account-select/main.vue'
import DataGrid from './DataGrid.vue' import MessageTable from './MessageTable.vue'
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict' import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import { MsgType } from '@/views/mp/components/wx-msg/types' import { MsgType } from '@/views/mp/components/wx-msg/types'
import type { FormInstance } from 'element-plus' import type { FormInstance } from 'element-plus'
@ -142,7 +142,7 @@ const getList = async () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = async () => { const resetQuery = async () => {
// accountIdreset // accountId reset
const accountId = queryParams.accountId const accountId = queryParams.accountId
queryFormRef.value?.resetFields() queryFormRef.value?.resetFields()
queryParams.accountId = accountId queryParams.accountId = accountId