Skip to content

Commit 40e23bd

Browse files
committed
REVIEW 公众号的菜单
1 parent f7fe794 commit 40e23bd

File tree

3 files changed

+42
-47
lines changed

3 files changed

+42
-47
lines changed

src/views/mp/draft/index.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ import WxEditor from '@/views/mp/components/wx-editor/WxEditor.vue'
261261
import WxNews from '@/views/mp/components/wx-news/main.vue'
262262
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
263263
import { getAccessToken } from '@/utils/auth'
264-
import { createDraft, deleteDraft, getDraftPage, updateDraft } from '@/api/mp/draft'
265-
import { getSimpleAccountList } from '@/api/mp/account'
266-
import { submitFreePublish } from '@/api/mp/freePublish'
264+
import * as MpAccountApi from '@/api/mp/account'
265+
import * as MpDraftApi from '@/api/mp/draft'
266+
import * as MpFreePublishApi from '@/api/mp/freePublish'
267267
const message = useMessage() // 消息
268268
// 可以用改本地数据模拟,避免API调用超限
269269
// import drafts from './mock'
@@ -302,7 +302,7 @@ const hackResetEditor = ref(false)
302302
303303
/** 初始化 **/
304304
onMounted(async () => {
305-
accountList.value = await getSimpleAccountList()
305+
accountList.value = await MpAccountApi.getSimpleAccountList()
306306
// 选中第一个
307307
if (accountList.value.length > 0) {
308308
// @ts-ignore
@@ -328,7 +328,7 @@ const getList = async () => {
328328
329329
loading.value = true
330330
try {
331-
const drafts = await getDraftPage(queryParams)
331+
const drafts = await MpDraftApi.getDraftPage(queryParams)
332332
drafts.list.forEach((item) => {
333333
const newsItem = item.content.newsItem
334334
// 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面
@@ -389,7 +389,7 @@ const submitForm = () => {
389389
// TODO @Dhb52: 参考别的模块写法,改成 await 方式
390390
addMaterialLoading.value = true
391391
if (operateMaterial.value === 'add') {
392-
createDraft(queryParams.accountId, articlesAdd.value)
392+
MpDraftApi.createDraft(queryParams.accountId, articlesAdd.value)
393393
.then(() => {
394394
message.notifySuccess('新增成功')
395395
dialogNewsVisible.value = false
@@ -399,7 +399,7 @@ const submitForm = () => {
399399
addMaterialLoading.value = false
400400
})
401401
} else {
402-
updateDraft(queryParams.accountId, articlesMediaId.value, articlesAdd.value)
402+
MpDraftApi.updateDraft(queryParams.accountId, articlesMediaId.value, articlesAdd.value)
403403
.then(() => {
404404
message.notifySuccess('更新成功')
405405
dialogNewsVisible.value = false
@@ -553,7 +553,7 @@ const handlePublish = async (item) => {
553553
'你正在通过发布的方式发表内容。 发布不占用群发次数,一天可多次发布。已发布内容不会推送给用户,也不会展示在公众号主页中。 发布后,你可以前往发表记录获取链接,也可以将发布内容添加到自定义菜单、自动回复、话题和页面模板中。'
554554
try {
555555
await message.confirm(content)
556-
await submitFreePublish(accountId, mediaId)
556+
await MpFreePublishApi.submitFreePublish(accountId, mediaId)
557557
message.notifySuccess('发布成功')
558558
await getList()
559559
} catch {}
@@ -565,7 +565,7 @@ const handleDelete = async (item) => {
565565
const mediaId = item.mediaId
566566
try {
567567
await message.confirm('此操作将永久删除该草稿, 是否继续?')
568-
await deleteDraft(accountId, mediaId)
568+
await MpDraftApi.deleteDraft(accountId, mediaId)
569569
message.notifySuccess('删除成功')
570570
await getList()
571571
} catch {}

src/views/mp/menu/index.vue

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
<template>
2-
<div class="app-container">
3-
<doc-alert title="公众号菜单" url="https://doc.iocoder.cn/mp/menu/" />
4-
5-
<!-- 搜索工作栏 -->
6-
<el-form ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
2+
<doc-alert title="公众号菜单" url="https://doc.iocoder.cn/mp/menu/" />
3+
<!-- 搜索工作栏 -->
4+
<ContentWrap>
5+
<el-form
6+
class="-mb-15px"
7+
:model="queryParams"
8+
ref="queryFormRef"
9+
:inline="true"
10+
label-width="68px"
11+
>
712
<el-form-item label="公众号" prop="accountId">
813
<el-select v-model="accountId" placeholder="请选择公众号">
914
<el-option
1015
v-for="item in accountList"
11-
:key="parseInt(item.id)"
16+
:key="item.id"
1217
:label="item.name"
13-
:value="parseInt(item.id)"
18+
:value="item.id"
1419
/>
1520
</el-select>
1621
</el-form-item>
1722
<el-form-item>
18-
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
19-
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
23+
<el-button @click="handleQuery"><Icon icon="ep:search" />搜索</el-button>
24+
<el-button @click="resetQuery"><Icon icon="ep:refresh" />重置</el-button>
2025
</el-form-item>
2126
</el-form>
27+
</ContentWrap>
2228

29+
<!-- 列表 -->
30+
<ContentWrap>
2331
<div class="public-account-management clearfix" v-loading="loading">
2432
<!--左边配置菜单-->
2533
<div class="left">
@@ -63,15 +71,13 @@
6371
<el-button
6472
class="save_btn"
6573
type="success"
66-
size="small"
6774
@click="handleSave"
6875
v-hasPermi="['mp:menu:save']"
6976
>保存并发布菜单</el-button
7077
>
7178
<el-button
7279
class="save_btn"
7380
type="danger"
74-
size="small"
7581
@click="handleDelete"
7682
v-hasPermi="['mp:menu:delete']"
7783
>清空菜单</el-button
@@ -82,9 +88,9 @@
8288
<div v-if="showRightFlag" class="right">
8389
<div class="configure_page">
8490
<div class="delete_btn">
85-
<el-button size="small" type="danger" @click="handleDeleteMenu(tempObj)"
86-
>删除当前菜单<Icon icon="ep:delete"
87-
/></el-button>
91+
<el-button size="small" type="danger" @click="handleDeleteMenu(tempObj)">
92+
删除当前菜单<Icon icon="ep:delete" />
93+
</el-button>
8894
</div>
8995
<div>
9096
<span>菜单名称:</span>
@@ -161,9 +167,9 @@
161167
<div class="select-item" v-if="tempObj && tempObj.replyArticles">
162168
<WxNews :articles="tempObj.replyArticles" />
163169
<el-row class="ope-row" justify="center" align="middle">
164-
<el-button type="danger" circle @click="deleteMaterial"
165-
><icon icon="ep:delete"
166-
/></el-button>
170+
<el-button type="danger" circle @click="deleteMaterial">
171+
<icon icon="ep:delete" />
172+
</el-button>
167173
</el-row>
168174
</div>
169175
<div v-else>
@@ -197,33 +203,25 @@
197203
<p>请选择菜单配置</p>
198204
</div>
199205
</div>
200-
</div>
206+
</ContentWrap>
201207
</template>
202-
203-
<script setup>
204-
import { ref, nextTick } from 'vue'
208+
<script setup name="MpMenu">
209+
import { handleTree } from '@/utils/tree'
205210
import WxReplySelect from '@/views/mp/components/wx-reply/main.vue'
206211
import WxNews from '@/views/mp/components/wx-news/main.vue'
207212
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
208213
import { deleteMenu, getMenuList, saveMenu } from '@/api/mp/menu'
209-
import { getSimpleAccountList } from '@/api/mp/account'
210-
import { handleTree } from '@/utils/tree'
214+
import * as MpAccountApi from '@/api/mp/account'
211215
import menuOptions from './menuOptions'
212-
213-
const message = useMessage()
216+
const message = useMessage() // 消息
214217
215218
// ======================== 列表查询 ========================
216-
// 遮罩层
217-
const loading = ref(true)
218-
// 显示搜索条件
219-
const showSearch = ref(true)
220-
// 公众号Id
221-
const accountId = ref(undefined)
222-
// 公众号名
223-
const name = ref('')
219+
const loading = ref(true) // 遮罩层
220+
const accountId = ref(undefined) // 公众号Id
221+
const name = ref('') // 公众号名
224222
const menuList = ref({ children: [] })
223+
const accountList = ref([]) // 公众号账号列表
225224
226-
// const menuList = ref(menuListData)
227225
// ======================== 菜单操作 ========================
228226
const isActive = ref(-1) // 一级菜单点中样式
229227
const isSubMenuActive = ref(-1) // 一级菜单点中样式
@@ -241,11 +239,8 @@ const tempSelfObj = ref({
241239
})
242240
const dialogNewsVisible = ref(false) // 跳转图文时的素材选择弹窗
243241
244-
// 公众号账号列表
245-
const accountList = ref([])
246-
247242
onMounted(async () => {
248-
accountList.value = await getSimpleAccountList()
243+
accountList.value = await MpAccountApi.getSimpleAccountList()
249244
// 选中第一个
250245
if (accountList.value.length > 0) {
251246
// @ts-ignore
File renamed without changes.

0 commit comments

Comments
 (0)