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

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

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

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

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

Loading…
Cancel
Save