diff --git a/.env.front b/.env.front
index 2641417d7a50dfcb8842bdaf68c34cf107180ede..a63b63795ae6e86c04bee04519955948c154de4e 100644
--- a/.env.front
+++ b/.env.front
@@ -17,3 +17,18 @@ VITE_API_URL=/admin-api
# 打包路径
VITE_BASE_PATH=/
+
+# 项目本地运行端口号, 与.vscode/launch.json配合
+VITE_PORT=5173
+
+# 是否删除debugger
+VITE_DROP_DEBUGGER=false
+
+# 是否删除console.log
+VITE_DROP_CONSOLE=false
+
+# 是否sourcemap
+VITE_SOURCEMAP=true
+
+# 验证码的开关
+VITE_APP_CAPTCHA_ENABLE=false
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000000000000000000000000000000000000..e4093b3a95a2bec8ab6b0284b56d5c328ee2a8a9
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,16 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "msedge",
+ "request": "launch",
+ "name": "Launch Edge against localhost",
+ "url": "http://localhost:5173",
+ "webRoot": "${workspaceFolder}/src",
+ "sourceMaps": true
+ }
+ ]
+}
diff --git a/build/vite/index.ts b/build/vite/index.ts
index 0e721ce9ebaee7a604986913754c123773d322ce..288ec93bde47a9e4ce9f5f95fbf017fb9a8729d3 100644
--- a/build/vite/index.ts
+++ b/build/vite/index.ts
@@ -13,7 +13,7 @@ import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import viteCompression from 'vite-plugin-compression'
import topLevelAwait from 'vite-plugin-top-level-await'
-import vueSetupExtend from 'vite-plugin-vue-setup-extend'
+import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
@@ -98,7 +98,8 @@ export function createVitePlugins() {
deleteOriginFile: false //压缩后是否删除源文件
}),
ViteEjsPlugin(),
- topLevelAwait({ // https://juejin.cn/post/7152191742513512485
+ topLevelAwait({
+ // https://juejin.cn/post/7152191742513512485
// The export name of top-level await promise for each chunk module
promiseExportName: '__tla',
// The function to generate import names of top-level await promise in each chunk module
diff --git a/package.json b/package.json
index def1f5c7587b917646b7dfcedc79859f5b31603d..84e420d1e51de8003354937915619dbea9e901f3 100644
--- a/package.json
+++ b/package.json
@@ -126,7 +126,7 @@
"vite-plugin-purge-icons": "^0.9.2",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-top-level-await": "^1.3.0",
- "vite-plugin-vue-setup-extend": "^0.4.0",
+ "vite-plugin-vue-setup-extend-plus": "^0.1.0",
"vite-plugin-windicss": "^1.8.10",
"vue-tsc": "^1.2.0",
"windicss": "^3.5.6"
diff --git a/src/views/mp/autoReply/index.vue b/src/views/mp/autoReply/index.vue
index 03f98b54924b8a29caef76e7c09edbc9e5900ad5..4877ec76c8437c66f58198b6f5b5b1979f056c85 100644
--- a/src/views/mp/autoReply/index.vue
+++ b/src/views/mp/autoReply/index.vue
@@ -3,28 +3,7 @@
-
-
-
-
-
-
-
- 搜索
- 重置
-
-
+ accountChanged(accountId)" />
@@ -181,20 +160,13 @@
diff --git a/src/views/mp/components/wx-account-select/main.vue b/src/views/mp/components/wx-account-select/main.vue
new file mode 100644
index 0000000000000000000000000000000000000000..f75bc7d69f051fcf58b7d5114c81feccecce1e19
--- /dev/null
+++ b/src/views/mp/components/wx-account-select/main.vue
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/mp/components/wx-material-select/main.vue b/src/views/mp/components/wx-material-select/main.vue
index 7f565823a227b25583fa185bff3a76d59c4dac99..d67ffb1f5d72a7717df6008f904022607f04ef8b 100644
--- a/src/views/mp/components/wx-material-select/main.vue
+++ b/src/views/mp/components/wx-material-select/main.vue
@@ -14,7 +14,8 @@
{{ item.name }}
- 选择
+ 选择
+
@@ -48,7 +49,8 @@
选择
+ >选择
+
@@ -89,7 +91,8 @@
>
选择
+ >选择
+
@@ -110,7 +113,8 @@
- 选择
+ 选择
+
@@ -127,125 +131,101 @@
-
diff --git a/src/views/mp/menu/index.vue b/src/views/mp/menu/index.vue
index 2d4b7c760d31d38e9c44a9704443f0a2dec332a3..249f3a7c6d1e105c8bb5bd291b537195bb24825f 100644
--- a/src/views/mp/menu/index.vue
+++ b/src/views/mp/menu/index.vue
@@ -2,22 +2,7 @@
-
-
-
-
-
-
-
- 搜索
- 重置
-
-
+ accountChanged(accountId)" />
@@ -204,17 +189,15 @@ import { handleTree } from '@/utils/tree'
import WxReplySelect from '@/views/mp/components/wx-reply/main.vue'
import WxNews from '@/views/mp/components/wx-news/main.vue'
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
-import { deleteMenu, getMenuList, saveMenu } from '@/api/mp/menu'
-import * as MpAccountApi from '@/api/mp/account'
+import WxAccountSelect from '@/views/mp/components/wx-account-select/main.vue'
+import * as MpMenuApi from '@/api/mp/menu'
import menuOptions from './menuOptions'
const message = useMessage() // 消息
// ======================== 列表查询 ========================
const loading = ref(true) // 遮罩层
const accountId = ref(undefined) // 公众号Id
-const name = ref('') // 公众号名
const menuList = ref({ children: [] })
-const accountList = ref([]) // 公众号账号列表
// ======================== 菜单操作 ========================
const isActive = ref(-1) // 一级菜单点中样式
@@ -228,60 +211,34 @@ const showConfigureContent = ref(true) // 是否展示配置内容;如果有
const hackResetWxReplySelect = ref(false) // 重置 WxReplySelect 组件
const tempObj = ref({}) // 右边临时变量,作为中间值牵引关系
-const tempSelfObj = ref({
- // 一些临时值放在这里进行判断,如果放在 tempObj,由于引用关系,menu 也会多了多余的参数
-})
+// 一些临时值放在这里进行判断,如果放在 tempObj,由于引用关系,menu 也会多了多余的参数
+const tempSelfObj = ref({})
const dialogNewsVisible = ref(false) // 跳转图文时的素材选择弹窗
-onMounted(async () => {
- accountList.value = await MpAccountApi.getSimpleAccountList()
- // 选中第一个
- if (accountList.value.length > 0) {
- // @ts-ignore
- setAccountId(accountList.value[0].id)
- }
- await getList()
-})
-
-// ======================== 列表查询 ========================
-/** 设置账号编号 */
-const setAccountId = (id) => {
+/** 侦听公众号变化 **/
+const accountChanged = (id) => {
accountId.value = id
- name.value = accountList.value.find((item) => item.id === accountId.value)?.name
+ getList()
}
+/** 查询并转换菜单 **/
const getList = async () => {
loading.value = false
- getMenuList(accountId.value)
- .then((response) => {
- const menuData = convertMenuList(response)
- menuList.value = handleTree(menuData, 'id')
- })
- .finally(() => {
- loading.value = false
- })
+ try {
+ const data = await MpMenuApi.getMenuList(accountId.value)
+ const menuData = convertMenuList(data)
+ menuList.value = handleTree(menuData, 'id')
+ } finally {
+ loading.value = false
+ }
}
/** 搜索按钮操作 */
const handleQuery = () => {
resetForm()
- // 默认选中第一个
- if (accountId.value) {
- setAccountId(accountId.value)
- }
getList()
}
-/** 重置按钮操作 */
-const resetQuery = () => {
- resetForm()
- // 默认选中第一个
- if (accountList.value.length > 0) {
- setAccountId(accountList.value[0].id)
- }
- handleQuery()
-}
-
// 将后端返回的 menuList,转换成前端的 menuList
const convertMenuList = (list) => {
if (!list) return []
@@ -443,7 +400,7 @@ const handleSave = async () => {
try {
await message.confirm('确定要删除吗?')
loading.value = true
- await saveMenu(accountId.value, convertMenuFormList())
+ await MpMenuApi.saveMenu(accountId.value, convertMenuFormList())
getList()
message.notifySuccess('发布成功')
} finally {
@@ -464,7 +421,7 @@ const handleDelete = async () => {
try {
await message.confirm('确定要删除吗?')
loading.value = true
- await deleteMenu(accountId.value)
+ await MpMenuApi.deleteMenu(accountId.value)
handleQuery()
message.notifySuccess('清空成功')
} finally {
@@ -546,6 +503,7 @@ const deleteMaterial = () => {
delete tempObj.value['replyArticles']
}
+