diff --git a/src/router/index.ts b/src/router/index.ts index dd77c5b..7fed8e0 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -3,6 +3,7 @@ import { createWebHashHistory, type RouteRecordRaw, } from "vue-router"; +import { addRulesForRoutes } from "./rules"; /** * 通过 vite 的 meta.glob 从文件系统读取路由文件 @@ -49,10 +50,12 @@ function getRoutePathFromFilePath(filePath: string): string { const routes: RouteRecordRaw[] = generateRoutesFromPages(); +const ruledRoutes = addRulesForRoutes(routes); + // WebHash 使用 /# 开头处理前端页面路由 const router = createRouter({ history: createWebHashHistory(), - routes, + routes: ruledRoutes, }); export default router; diff --git a/src/router/rules/index.ts b/src/router/rules/index.ts new file mode 100644 index 0000000..08d6a31 --- /dev/null +++ b/src/router/rules/index.ts @@ -0,0 +1,5 @@ +import { type RouteRecordRaw } from "vue-router"; + +export function addRulesForRoutes(router: RouteRecordRaw) { + return router; +}