mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-06 01:28:01 +00:00
refactor: 优化前端代码结构和资源管理 style: 调整前端代码格式和样式 chore: 更新.gitignore和构建配置 fix: 修复前端资源路径和引用问题 docs: 更新前端文档和注释 perf: 优化前端性能和加载速度 test: 更新前端测试用例 build: 调整前端构建配置 ci: 更新CI/CD配置
37 lines
1.4 KiB
TypeScript
Executable File
37 lines
1.4 KiB
TypeScript
Executable File
import type { App } from "vue";
|
|
import { createRouter, createWebHashHistory } from "vue-router";
|
|
import { HOME_ROUTE_NAME, ROOT_LAYOUT_ROUTE_NAME, staticRoutes } from "./staticRoutes";
|
|
import { setupBeforeEachGuard } from "./beforeEach";
|
|
import { setupAfterEachGuard } from "./afterEach";
|
|
import "@utils/ui";
|
|
|
|
/**
|
|
* 路由分层:`staticRoutes` 一次性注册(登录页、首页、仪表盘、异常页等);
|
|
* 业务菜单来自后端或壳层合并后再由守卫动态 `addRoute`。
|
|
*/
|
|
export const router = createRouter({
|
|
history: createWebHashHistory(),
|
|
routes: staticRoutes,
|
|
// 刷新时,滚动条位置还原
|
|
scrollBehavior: () => ({ left: 0, top: 0 }),
|
|
});
|
|
|
|
// 初始化路由
|
|
export function initRouter(app: App<Element>): void {
|
|
setupBeforeEachGuard(router); // 路由前置守卫
|
|
setupAfterEachGuard(router); // 路由后置守卫
|
|
app.use(router);
|
|
}
|
|
|
|
// 主页路径;须与 `staticRoutes` 中首页子路由一致(当前为 `/home`)
|
|
export const HOME_PAGE_PATH = "/home";
|
|
|
|
export { HOME_ROUTE_NAME, ROOT_LAYOUT_ROUTE_NAME };
|
|
|
|
/** 供 `@/router` 一处导入的运行时模块 */
|
|
export { RouteRegistry, ComponentLoader, RouteTransformer, RouteValidator } from "./dynamicRoutes";
|
|
export type { ValidationResult } from "./dynamicRoutes";
|
|
export { IframeRouteManager } from "./staticRoutes";
|
|
export { MenuProcessor, builtinFrontendRoutes } from "./MenuProcessor";
|
|
export { RoutePermissionValidator } from "./beforeEach";
|