|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|