Browse Source

🎟 优化

master
wangxiang 3 years ago
parent
commit
c454aa4e57
  1. 8
      kicc-ui/src/router/index.ts
  2. 8
      kicc-ui/src/router/routes/modules/dashboard.ts
  3. 2
      kicc-ui/src/router/types.ts

8
kicc-ui/src/router/index.ts

@ -10,14 +10,14 @@ import type { App } from 'vue'; @@ -10,14 +10,14 @@ import type { App } from 'vue';
import { createRouter, createWebHashHistory } from 'vue-router';
import { routesConfig } from './routes';
// 固定路由,设置基础路由不需要被重置掉
/** 固定路由,设置基础路由不需要被重置掉 */
const AFFIX_NAME_LIST: string[] = [];
const getRouteNames = (array: any[]) => array.forEach((item) => {
AFFIX_NAME_LIST.push(item.name);
getRouteNames(item.children || []);
});getRouteNames(routesConfig);
// 应用配置的静态路由
/** 应用配置的静态路由 */
export const router = createRouter({
history: createWebHashHistory(import.meta.env.VITE_PUBLIC_PATH as string),
routes: routesConfig as unknown as RouteRecordRaw[],
@ -25,7 +25,7 @@ export const router = createRouter({ @@ -25,7 +25,7 @@ export const router = createRouter({
scrollBehavior: () => ({ left: 0, top: 0 }),
});
// 重置所有路由,除基础路由外
/** 重置所有路由,除基础路由外 */
export function resetRouter() {
router.getRoutes().forEach((route) => {
const { name } = route;
@ -35,7 +35,7 @@ export function resetRouter() { @@ -35,7 +35,7 @@ export function resetRouter() {
});
}
// 配置路由器
/** 配置路由器 */
export function setupRouter(app: App<Element>) {
app.use(router);
}

8
kicc-ui/src/router/routes/modules/dashboard.ts

@ -28,7 +28,7 @@ const dashboard: AppRouteModule = { @@ -28,7 +28,7 @@ const dashboard: AppRouteModule = {
meta: {
// affix: true,
title: t('routes.dashboard.analysis'),
},
}
},
{
path: 'workbench',
@ -36,9 +36,9 @@ const dashboard: AppRouteModule = { @@ -36,9 +36,9 @@ const dashboard: AppRouteModule = {
component: () => import('/@/views/dashboard/workbench/index.vue'),
meta: {
title: t('routes.dashboard.workbench'),
},
},
],
}
}
]
};
export default dashboard;

2
kicc-ui/src/router/types.ts

@ -43,5 +43,5 @@ export interface Menu { @@ -43,5 +43,5 @@ export interface Menu {
hideMenu?: boolean;
}
// 导出类型 AppRouteModule = RouteModule | AppRouteRecordRaw;
/** 导出类型 AppRouteModule = RouteModule | AppRouteRecordRaw; */
export type AppRouteModule = AppRouteRecordRaw;

Loading…
Cancel
Save