Explorar o código

[Feat 0000] 菜单配置支持白板布局

houzekong hai 4 meses
pai
achega
5a70c9619c
Modificáronse 3 ficheiros con 90 adicións e 79 borrados
  1. 78 74
      public/js/global.js
  2. 6 0
      src/router/constant.ts
  3. 6 5
      src/router/helper/routeHelper.ts

+ 78 - 74
public/js/global.js

@@ -3,68 +3,69 @@ const __STATIC_ROUTES__ = [
     {
     {
         redirect: undefined,
         redirect: undefined,
         path: '/dashboard',
         path: '/dashboard',
-        component: 'layouts/default/index',
+        component: 'PLAIN_LAYOUT',
+        // component: 'LAYOUT',
         children: [
         children: [
             {
             {
-                path: '/dashboard/sealedGoafIndex',
-                component: 'dashboard/SealedGoaf',
+                path: '/dashboard/sealedgoaf',
+                component: '/dashboard/SealedGoaf',
                 meta: {
                 meta: {
                     keepAlive: true,
                     keepAlive: true,
                     internalOrExternal: false,
                     internalOrExternal: false,
                     icon: '',
                     icon: '',
-                    componentName: 'sealedGoafIndex',
+                    componentName: 'SealedGoaf',
                     title: '采空区首页',
                     title: '采空区首页',
                 },
                 },
-                name: 'dashboard-sealedGoafIndex',
-            },
-            {
-                path: '/dashboard/analysis',
-                component: 'dashboard/Analysis',
-                meta: {
-                    keepAlive: true,
-                    internalOrExternal: false,
-                    icon: '',
-                    componentName: 'Analysis',
-                    title: '首页',
-                },
-                name: 'dashboard-analysis',
-            },
-            {
-                path: '/portal-view/system',
-                component: '1',
-                meta: {
-                    keepAlive: false,
-                    internalOrExternal: false,
-                    icon: '',
-                    componentName: '1',
-                    title: '主门户',
-                },
-                name: 'portal-view-system',
-            },
-            {
-                path: '/portal-view/personal',
-                component: '1',
-                meta: {
-                    keepAlive: false,
-                    internalOrExternal: false,
-                    icon: '',
-                    componentName: '1',
-                    title: '个人工作台',
-                },
-                name: 'portal-view-personal',
-            },
-            {
-                path: '/dashboard/workbench',
-                component: 'dashboard/workbench/index',
-                meta: {
-                    keepAlive: false,
-                    internalOrExternal: false,
-                    icon: '',
-                    componentName: 'index',
-                    title: '工作台',
-                },
-                name: 'dashboard-workbench',
+                name: 'dashboard-sealedgoaf',
             },
             },
+            // {
+            //     path: '/dashboard/analysis',
+            //     component: 'dashboard/Analysis',
+            //     meta: {
+            //         keepAlive: true,
+            //         internalOrExternal: false,
+            //         icon: '',
+            //         componentName: 'Analysis',
+            //         title: '首页',
+            //     },
+            //     name: 'dashboard-analysis',
+            // },
+            // {
+            //     path: '/portal-view/system',
+            //     component: '1',
+            //     meta: {
+            //         keepAlive: false,
+            //         internalOrExternal: false,
+            //         icon: '',
+            //         componentName: '1',
+            //         title: '主门户',
+            //     },
+            //     name: 'portal-view-system',
+            // },
+            // {
+            //     path: '/portal-view/personal',
+            //     component: '1',
+            //     meta: {
+            //         keepAlive: false,
+            //         internalOrExternal: false,
+            //         icon: '',
+            //         componentName: '1',
+            //         title: '个人工作台',
+            //     },
+            //     name: 'portal-view-personal',
+            // },
+            // {
+            //     path: '/dashboard/workbench',
+            //     component: 'dashboard/workbench/index',
+            //     meta: {
+            //         keepAlive: false,
+            //         internalOrExternal: false,
+            //         icon: '',
+            //         componentName: 'index',
+            //         title: '工作台',
+            //     },
+            //     name: 'dashboard-workbench',
+            // },
         ],
         ],
         meta: {
         meta: {
             keepAlive: false,
             keepAlive: false,
@@ -72,16 +73,19 @@ const __STATIC_ROUTES__ = [
             icon: '',
             icon: '',
             componentName: 'index',
             componentName: 'index',
             title: '主页',
             title: '主页',
+            hideMenu: true,
+            hideBreadcrumb: true,
+            hideTab: true
         },
         },
         name: 'dashboard',
         name: 'dashboard',
     },
     },
     {
     {
         redirect: undefined,
         redirect: undefined,
-        path: '/basicInfo',
-        component: 'layouts/default/index',
+        path: '/basicinfo',
+        component: 'LAYOUT',
         children: [
         children: [
             {
             {
-                path: '/basicInfo/minesInfo',
+                path: '/basicinfo/mines-info',
                 component: 'dashboard/basicInfo/minesInfo',
                 component: 'dashboard/basicInfo/minesInfo',
                 meta: {
                 meta: {
                     keepAlive: true,
                     keepAlive: true,
@@ -90,10 +94,10 @@ const __STATIC_ROUTES__ = [
                     componentName: 'index',
                     componentName: 'index',
                     title: '矿山信息',
                     title: '矿山信息',
                 },
                 },
-                name: 'basicInfo-minesInfoIndex',
+                name: 'basicinfo-mines-info',
             },
             },
             {
             {
-                path: '/basicInfo/accessStatistics',
+                path: '/basicinfo/access-statistics',
                 component: 'dashboard/basicInfo/accessStatistics',
                 component: 'dashboard/basicInfo/accessStatistics',
                 meta: {
                 meta: {
                     keepAlive: true,
                     keepAlive: true,
@@ -102,10 +106,10 @@ const __STATIC_ROUTES__ = [
                     componentName: 'index',
                     componentName: 'index',
                     title: '接入统计',
                     title: '接入统计',
                 },
                 },
-                name: 'basicInfo-accessStatisticsIndex',
+                name: 'basicinfo-access-statistics',
             },
             },
             {
             {
-                path: '/basicInfo/dataQuality',
+                path: '/basicinfo/data-quality',
                 component: 'dashboard/basicInfo/dataQuality',
                 component: 'dashboard/basicInfo/dataQuality',
                 meta: {
                 meta: {
                     keepAlive: true,
                     keepAlive: true,
@@ -114,10 +118,10 @@ const __STATIC_ROUTES__ = [
                     componentName: 'index',
                     componentName: 'index',
                     title: '数据质量',
                     title: '数据质量',
                 },
                 },
-                name: 'basicInfo-dataQualityIndex',
+                name: 'basicinfo-data-quality',
             },
             },
             {
             {
-                path: '/basicInfo/closedStatistics',
+                path: '/basicinfo/closed-statistics',
                 component: 'dashboard/basicInfo/closedStatistics',
                 component: 'dashboard/basicInfo/closedStatistics',
                 meta: {
                 meta: {
                     keepAlive: true,
                     keepAlive: true,
@@ -126,7 +130,7 @@ const __STATIC_ROUTES__ = [
                     componentName: 'index',
                     componentName: 'index',
                     title: '密闭统计',
                     title: '密闭统计',
                 },
                 },
-                name: 'basicInfo-closedStatisticsIndex',
+                name: 'basicinfo-closed-statistics',
             },
             },
         ],
         ],
         meta: {
         meta: {
@@ -140,11 +144,11 @@ const __STATIC_ROUTES__ = [
     },
     },
     {
     {
         redirect: undefined,
         redirect: undefined,
-        path: '/sealedMonitoring',
-        component: 'layouts/default/index',
+        path: '/sealed',
+        component: 'LAYOUT',
         children: [
         children: [
             {
             {
-                path: '${id}',
+                path: '/sealed/${id}',
                 component: '/dashboard/sealedMonitoring/realtimeData/index',
                 component: '/dashboard/sealedMonitoring/realtimeData/index',
                 meta: {
                 meta: {
                     keepAlive: true,
                     keepAlive: true,
@@ -155,7 +159,7 @@ const __STATIC_ROUTES__ = [
                     hideMenu: true
                     hideMenu: true
                     // orderNo: '${departOrder}',
                     // orderNo: '${departOrder}',
                 },
                 },
-                name: '${id}',
+                name: 'sealed-${id}',
             }
             }
         ],
         ],
         meta: {
         meta: {
@@ -166,12 +170,12 @@ const __STATIC_ROUTES__ = [
             title: '密闭监测',
             title: '密闭监测',
             generation: true,
             generation: true,
         },
         },
-        name: 'sealedMonitoring',
+        name: 'sealed',
     },
     },
     {
     {
         redirect: undefined,
         redirect: undefined,
         path: '/warningAnalysis',
         path: '/warningAnalysis',
-        component: 'layouts/default/index',
+        component: 'LAYOUT',
         children: [],
         children: [],
         meta: {
         meta: {
             keepAlive: false,
             keepAlive: false,
@@ -185,7 +189,7 @@ const __STATIC_ROUTES__ = [
     {
     {
         redirect: undefined,
         redirect: undefined,
         path: '/smartAnalysis',
         path: '/smartAnalysis',
-        component: 'layouts/default/index',
+        component: 'LAYOUT',
         children: [],
         children: [],
         meta: {
         meta: {
             keepAlive: false,
             keepAlive: false,
@@ -199,7 +203,7 @@ const __STATIC_ROUTES__ = [
     {
     {
         redirect: undefined,
         redirect: undefined,
         path: '/3dManage',
         path: '/3dManage',
-        component: 'layouts/default/index',
+        component: 'LAYOUT',
         children: [],
         children: [],
         meta: {
         meta: {
             keepAlive: false,
             keepAlive: false,
@@ -212,8 +216,8 @@ const __STATIC_ROUTES__ = [
     },
     },
     {
     {
         redirect: undefined,
         redirect: undefined,
-        path: '/isystem',
-        component: 'layouts/default/index',
+        path: '/system',
+        component: 'LAYOUT',
         children: [
         children: [
             {
             {
                 path: '/system/menu',
                 path: '/system/menu',
@@ -409,7 +413,7 @@ const __STATIC_ROUTES__ = [
     // {
     // {
     //     redirect: undefined,
     //     redirect: undefined,
     //     path: '/monitor',
     //     path: '/monitor',
-    //     component: 'layouts/default/index',
+    //     component: 'LAYOUT',
     //     children: [
     //     children: [
     //         {
     //         {
     //             path: '/monitor/route',
     //             path: '/monitor/route',

+ 6 - 0
src/router/constant.ts

@@ -13,6 +13,12 @@ export const EXCEPTION_COMPONENT = () => import('/@/views/sys/exception/Exceptio
  */
  */
 export const LAYOUT = () => import('/@/layouts/default/index.vue');
 export const LAYOUT = () => import('/@/layouts/default/index.vue');
 
 
+/**
+ * 白板布局,去除了侧边栏以及标签页等内容,仅保留头部、功能选择以及内容
+ * @returns
+ */
+export const PLAIN_LAYOUT = () => import('/@/layouts/default/plain.vue');
+
 /**
 /**
  * @description: parent-layout
  * @description: parent-layout
  */
  */

+ 6 - 5
src/router/helper/routeHelper.ts

@@ -1,7 +1,7 @@
 import type { AppRouteModule, AppRouteRecordRaw } from '/@/router/types';
 import type { AppRouteModule, AppRouteRecordRaw } from '/@/router/types';
 import type { Router, RouteRecordNormalized } from 'vue-router';
 import type { Router, RouteRecordNormalized } from 'vue-router';
 
 
-import { getParentLayout, LAYOUT, EXCEPTION_COMPONENT } from '/@/router/constant';
+import { getParentLayout, LAYOUT, PLAIN_LAYOUT } from '/@/router/constant';
 import { cloneDeep, omit } from 'lodash-es';
 import { cloneDeep, omit } from 'lodash-es';
 import { warn } from '/@/utils/log';
 import { warn } from '/@/utils/log';
 import { createRouter, createWebHashHistory } from 'vue-router';
 import { createRouter, createWebHashHistory } from 'vue-router';
@@ -16,6 +16,7 @@ const IFRAME = () => import('/@/views/sys/iframe/FrameBlank.vue');
 const LayoutMap = new Map<string, () => Promise<typeof import('*.vue')>>();
 const LayoutMap = new Map<string, () => Promise<typeof import('*.vue')>>();
 
 
 LayoutMap.set('LAYOUT', LAYOUT);
 LayoutMap.set('LAYOUT', LAYOUT);
+LayoutMap.set('PLAIN_LAYOUT', PLAIN_LAYOUT);
 LayoutMap.set('IFRAME', IFRAME);
 LayoutMap.set('IFRAME', IFRAME);
 
 
 let dynamicViewsModules: Record<string, () => Promise<Recordable>>;
 let dynamicViewsModules: Record<string, () => Promise<Recordable>>;
@@ -77,8 +78,8 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
     if (!item.component && item.meta?.frameSrc) {
     if (!item.component && item.meta?.frameSrc) {
       item.component = 'IFRAME';
       item.component = 'IFRAME';
     }
     }
-    let { component, name } = item;
-    const { children } = item;
+    let { component } = item;
+    const { children, name } = item;
     if (component) {
     if (component) {
       const layoutFound = LayoutMap.get(component.toUpperCase());
       const layoutFound = LayoutMap.get(component.toUpperCase());
       if (layoutFound) {
       if (layoutFound) {
@@ -126,7 +127,7 @@ export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModul
     const component = route.component as string;
     const component = route.component as string;
     if (component) {
     if (component) {
       route.originComponent = component;
       route.originComponent = component;
-      if (component.toUpperCase() === 'LAYOUT') {
+      if (component.toUpperCase().endsWith('LAYOUT')) {
         route.component = LayoutMap.get(component.toUpperCase());
         route.component = LayoutMap.get(component.toUpperCase());
       } else {
       } else {
         route.children = [cloneDeep(route)];
         route.children = [cloneDeep(route)];
@@ -228,5 +229,5 @@ export function addSlashToRouteComponent(routeList: AppRouteRecordRaw[]) {
     }
     }
     route.children && addSlashToRouteComponent(route.children);
     route.children && addSlashToRouteComponent(route.children);
   });
   });
-  return routeList as unknown as T[];
+  return routeList;
 }
 }