From 9e87842f7ed9eae98b3af55993b81d3a79913579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E7=A5=9E=E7=A5=9E=E7=A5=9E?= Date: Thu, 29 Jan 2026 22:49:34 +0800 Subject: [PATCH] feat: describe how to add route rules --- src/router/index.ts | 5 ++++- src/router/rules/index.ts | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/router/rules/index.ts 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; +}