Selaa lähdekoodia

动态路由和菜单调整

li.shaoyi 3 vuotta sitten
vanhempi
commit
9125442f91

+ 1 - 9
src/layout/components/menu.vue

@@ -119,15 +119,7 @@ export default defineComponent({
           secondeIndex = 0;
         for (let i = 0; i < list.length; i++) {
           for (let j = 0; j < list[i].children.length; j++) {
-            if (matched[1].name === 'marketSpot') {
-              // 处理动态市场 刷新问题
-              if (list[i].children[j].code === 'market_spot') {
-                firstIndex = i;
-                secondeIndex = j;
-                break
-              }
-            }
-            if (matched[1].name === list[i].children[j].code) {
+            if (matched.some((e) => e.name === list[i].children[j].code)) {
               firstIndex = i;
               secondeIndex = j;
               break;

+ 11 - 35
src/layout/components/top.vue

@@ -53,51 +53,27 @@ export default defineComponent({
     const isBottom = getHasBottom();
     // 选中菜单
     function chooseMenu(value: OperationTabMenu) {
-      const matched = route.matched;
-      const len = matched.length;
-      let temp = 'home';
-      if (matched.length > 2) {
-        temp = matched[2].name as string;
-      } else {
-        temp = matched[len - 1].name as string;
-      }
-      let name = temp;
-
-      if (temp === 'home') {
-        // 第一次进入项目
-        if (value?.code === 'market_spot') {
-          // 现货市场
-          router.push({ name: 'marketSpot' });
-          return
-        } else if (value?.children.length) {
-          // 默认第一个tab页
+      let name = 'home';
+      if (value.children && value.children.length) {
+        if (route.name === 'home') {
           name = value.children[0].code;
           index.value = ['0'];
         } else {
-          router.push({ name: '404' });
-          return;
-        }
-      } else {
-        // 这里处理页面刷新,还原 导航栏数据
-        const i = value.children.findIndex((e) => e.code === temp);
-        if (i === -1) {
-          if (value?.code === 'market_spot') {
-            // 现货市场
-            router.push({ name: 'marketSpot' });
-            return
-          } else if (value?.children.length) {
+          const i = value.children.findIndex((e) => e.code === route.name);
+          if (i === -1) {
             // 切换左边菜单栏
             // 默认第一个tab页
             name = value.children[0].code;
             index.value = ['0'];
           } else {
-            router.push({ name: '404' });
-            return;
+            // 切换右边上面tab 栏
+            name = value.children[i].code;
+            index.value = [i.toString()];
           }
-        } else {
-          // 切换右边上面tab 栏
-          index.value = [`${i}`];
         }
+      } else {
+        name = value.code;
+        index.value = ['0'];
       }
       list.value = value.children;
       setShowBottomPart(value.code);

+ 0 - 6
src/router/index.ts

@@ -37,12 +37,6 @@ const routes: Array<RouteRecordRaw> = [
                 name: 'home',
                 component: () => import('@/views/home.vue'),
             },
-            {
-                path: '/market-spot/',
-                name: 'marketSpot',
-                component: () => import('@/views/market/market-spot/index.vue'),
-                // props: route => ({ id: route.query.id })
-            },
         ],
     },
     {

+ 12 - 5
src/services/go/commonService/index.ts

@@ -92,12 +92,19 @@ export function queryNotice(): Promise<type.QueryNoticeRsp[]> {
  * 获取PC交易端菜单
  */
 export function GetPCMenus(): Promise<type.OperationTabMenu[]> {
-    // 目前只有平安期货需要 oem 这个参数 请求菜单数据,如后续添加需要根据name获取菜单,此处需要修改
-    const obj = isOemByEnum(OemType.pingan) ? { name: getOem() } : {}
-    const param = {
+    const oem = getOem();
+    const param: { loginID: number | null, name?: string } = {
         loginID: geLoginID_number(),
-    };
-    Object.assign(param, obj)
+    }
+    switch (oem) {
+        // 目前只有平安期货需要 oem 这个参数 请求菜单数据,如后续添加需要根据name获取菜单,此处需要修改
+        case OemType.pingan: {
+            param.name = oem
+        }
+        case OemType.tian_jing_mai_dun: {
+            param.name = 'trade'
+        }
+    }
     return commonSearch_go('/Common/GetPCWebMenus', param)
         .then((res) => {
             APP.set('menus', res);