Skip to content

Commit 48c7b58

Browse files
committed
1. 重命名 DataGrid 为 MessageTable,增加可读性
2. 调整素材管理,读取 API 接口
1 parent a5a8773 commit 48c7b58

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

src/views/mp/components/wx-account-select/main.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ const emit = defineEmits<{
1717
(e: 'change', id?: number, name?: string): void
1818
}>()
1919
20-
onMounted(() => {
21-
handleQuery()
22-
})
23-
2420
const handleQuery = async () => {
2521
accountList.value = await MpAccountApi.getSimpleAccountList()
2622
// 默认选中第一个
@@ -33,4 +29,9 @@ const handleQuery = async () => {
3329
const onChanged = () => {
3430
emit('change', account.id, account.name)
3531
}
32+
33+
/** 初始化 */
34+
onMounted(() => {
35+
handleQuery()
36+
})
3637
</script>

src/views/mp/draft/editor-config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export const createEditorConfig = (
2121
allowedFileTypes: ['image/*'],
2222

2323
// 自定义上传参数,例如传递验证的 token 等。参数会被添加到 formData 中,一起上传到服务端。
24-
meta: { accountId: accountId },
24+
meta: {
25+
accountId: accountId,
26+
type: 'image'
27+
},
2528
// 将 meta 拼接到 url 参数中,默认 false
2629
metaWithUrl: true,
2730

@@ -64,7 +67,7 @@ export const createEditorConfig = (
6467
},
6568
// 自定义插入图片
6669
customInsert(res: any, insertFn: InsertFnType) {
67-
insertFn(res.data, 'image', res.data)
70+
insertFn(res.data.url, 'image', res.data.url)
6871
}
6972
}
7073
}

src/views/mp/draft/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ import * as MpDraftApi from '@/api/mp/draft'
265265
import * as MpFreePublishApi from '@/api/mp/freePublish'
266266
import type { UploadFiles, UploadProps, UploadRawFile } from 'element-plus'
267267
import { createEditorConfig } from './editor-config'
268-
// 可以用改本地数据模拟,避免API调用超限
269-
import drafts from './mock'
268+
// import drafts from './mock' // 可以用改本地数据模拟,避免API调用超限
270269
import { IEditorConfig } from '@wangeditor/editor'
271270
272271
const message = useMessage() // 消息
@@ -342,7 +341,7 @@ const editorConfig = ref<Partial<IEditorConfig>>({})
342341
const getList = async () => {
343342
loading.value = true
344343
try {
345-
// const drafts = await MpDraftApi.getDraftPage(queryParams)
344+
const drafts = await MpDraftApi.getDraftPage(queryParams)
346345
drafts.list.forEach((item) => {
347346
const newsItem = item.content.newsItem
348347
// 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面

src/views/mp/message/DataGrid.vue renamed to src/views/mp/message/MessageTable.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,3 @@ const props = defineProps({
143143
144144
const emit = defineEmits<{ (e: 'send', v: number) }>()
145145
</script>
146-
147-
<style scoped></style>

src/views/mp/message/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
<!-- 列表 -->
6060
<ContentWrap>
61-
<DataGrid :list="list" :loading="loading" @send="handleSend" />
61+
<MessageTable :list="list" :loading="loading" @send="handleSend" />
6262
<Pagination
6363
v-show="total > 0"
6464
:total="total"
@@ -83,7 +83,7 @@
8383
import * as MpMessageApi from '@/api/mp/message'
8484
import WxMsg from '@/views/mp/components/wx-msg/main.vue'
8585
import WxAccountSelect from '@/views/mp/components/wx-account-select/main.vue'
86-
import DataGrid from './DataGrid.vue'
86+
import MessageTable from './MessageTable.vue'
8787
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
8888
import { MsgType } from '@/views/mp/components/wx-msg/types'
8989
import type { FormInstance } from 'element-plus'
@@ -142,7 +142,7 @@ const getList = async () => {
142142
143143
/** 重置按钮操作 */
144144
const resetQuery = async () => {
145-
// 暂存accountId,并在reset后恢复
145+
// 暂存 accountId,并在 reset 后恢复
146146
const accountId = queryParams.accountId
147147
queryFormRef.value?.resetFields()
148148
queryParams.accountId = accountId

0 commit comments

Comments
 (0)