miaofuhao hace 3 semanas
padre
commit
d5472770a9

+ 6 - 0
apps/web-ele/src/api/request.ts

@@ -194,6 +194,12 @@ function createRequestClient(baseURL: string) {
194 194
         ElMessage.error(timeoutMsg);
195 195
       }
196 196
 
197
+      // 当接口是/captchaImage时,不抛错
198
+      const requestUrl = response.config.url || '';
199
+      if (requestUrl.includes('/captchaImage')) {
200
+        return axiosResponseData;
201
+      }
202
+
197 203
       throw new Error(timeoutMsg || $t('http.apiRequestFailed'));
198 204
     },
199 205
   });

+ 30 - 4
apps/web-ele/src/views/system/menu/index.vue

@@ -4,9 +4,13 @@ import type { VbenFormProps } from '@vben/common-ui';
4 4
 import type { VxeGridProps } from '#/adapter/vxe-table';
5 5
 import type { Menu } from '#/api/system/menu/model';
6 6
 
7
+import { ref } from 'vue';
8
+
7 9
 import { Page, useVbenDrawer } from '@vben/common-ui';
8 10
 import { $t } from '@vben/locales';
9 11
 
12
+import { ElTabPane, ElTabs } from 'element-plus';
13
+
10 14
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
11 15
 import { menuDel, menuList } from '#/api/system/menu';
12 16
 
@@ -17,6 +21,10 @@ import { columns, querySchema } from './table-data';
17 21
  * 不要问为什么有两个根节点 v-if会控制只会渲染一个
18 22
  */
19 23
 
24
+// 添加tab切换功能
25
+const activeTab = ref('pc'); // 默认PC端
26
+const sourceMap = { pc: 0, mobile: 1 };
27
+
20 28
 const formOptions: VbenFormProps = {
21 29
   commonConfig: {
22 30
     labelWidth: 80,
@@ -38,6 +46,7 @@ const gridOptions: VxeGridProps = {
38 46
       query: async (_, formValues = {}) => {
39 47
         const resp = await menuList({
40 48
           ...formValues,
49
+          source: sourceMap[activeTab.value], // 添加source参数
41 50
         });
42 51
         return { items: resp };
43 52
       },
@@ -79,15 +88,23 @@ const collapseAll = () => {
79 88
   gridApi.grid?.setAllTreeExpand(false);
80 89
 };
81 90
 const addMenu = () => {
82
-  drawerApi.setData({});
91
+  drawerApi.setData({ source: sourceMap[activeTab.value] }); // 传递source参数
83 92
   drawerApi.open();
84 93
 };
85 94
 function handleEditMenu(record: Menu) {
86
-  drawerApi.setData({ id: record.menuId, update: true });
95
+  drawerApi.setData({
96
+    id: record.menuId,
97
+    update: true,
98
+    source: sourceMap[activeTab.value],
99
+  }); // 传递source参数
87 100
   drawerApi.open();
88 101
 }
89 102
 function handleAddMenu(record: Menu) {
90
-  drawerApi.setData({ id: record.menuId, update: false });
103
+  drawerApi.setData({
104
+    id: record.menuId,
105
+    update: false,
106
+    source: sourceMap[activeTab.value],
107
+  }); // 传递source参数
91 108
   drawerApi.open();
92 109
 }
93 110
 async function confirmEvent(row: Menu) {
@@ -95,10 +112,19 @@ async function confirmEvent(row: Menu) {
95 112
   console.error(result);
96 113
   await gridApi.reload();
97 114
 }
115
+
116
+// 切换tab时重新加载数据
117
+const handleTabChange = () => {
118
+  gridApi.reload();
119
+};
98 120
 </script>
99 121
 
100 122
 <template>
101
-  <Page class="h-full">
123
+  <Page class="h-full" style="background-color: #fff">
124
+    <ElTabs v-model="activeTab" @tab-change="handleTabChange" class="mb-4">
125
+      <ElTabPane label="PC端" name="pc" />
126
+      <ElTabPane label="移动端" name="mobile" />
127
+    </ElTabs>
102 128
     <BasicTable :table-title="$t('menus.table-title')">
103 129
       <template #toolbar-tools>
104 130
         <ElSpace>

+ 13 - 3
apps/web-ele/src/views/system/menu/menu-drawer.vue

@@ -234,9 +234,11 @@ const [Form, FormApi] = useVbenForm({
234 234
 interface ModalProps {
235 235
   id?: number | string;
236 236
   update: boolean;
237
+  source: number; // 添加source字段
237 238
 }
238 239
 // 新增还是修改的标识
239 240
 const isUpdate = ref<boolean>(false);
241
+const currentSource = ref<number>(0); // 默认PC端
240 242
 
241 243
 const [Drawer, DrawerApi] = useVbenDrawer({
242 244
   // 点击侧拉的确定按钮执行逻辑
@@ -248,7 +250,15 @@ const [Drawer, DrawerApi] = useVbenDrawer({
248 250
         return;
249 251
       }
250 252
       const data = await FormApi.getValues();
251
-      await (isUpdate.value ? menuUpdate(data) : menuAdd(data));
253
+      await (isUpdate.value
254
+        ? menuUpdate({
255
+            ...data,
256
+            source: currentSource.value, // 添加source参数
257
+          })
258
+        : menuAdd({
259
+            ...data,
260
+            source: currentSource.value, // 添加source参数
261
+          }));
252 262
       emit('reload');
253 263
       DrawerApi.close();
254 264
       await FormApi.resetForm();
@@ -263,8 +273,9 @@ const [Drawer, DrawerApi] = useVbenDrawer({
263 273
     if (!isOpen) {
264 274
       return null;
265 275
     }
266
-    const { id, update } = DrawerApi.getData() as ModalProps;
276
+    const { id, update, source } = DrawerApi.getData() as ModalProps;
267 277
     isUpdate.value = update;
278
+    currentSource.value = source; // 保存当前source值
268 279
     if (id) {
269 280
       await FormApi.setFieldValue('parentId', id);
270 281
       if (update) {
@@ -289,4 +300,3 @@ const [Drawer, DrawerApi] = useVbenDrawer({
289 300
   width: 100%;
290 301
 }
291 302
 </style>
292
-