Download apps/web-antd/src/router/index.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 927 Bytes
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-antd/src/router/index.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/apps/web-antd/src/router/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-antd/src/router/index.ts
927 Bytes
| import { | |
| createRouter, | |
| createWebHashHistory, | |
| createWebHistory, | |
| } from 'vue-router'; | |
| import { resetStaticRoutes } from '@vben/utils'; | |
| import { createRouterGuard } from './guard'; | |
| import { routes } from './routes'; | |
| /** | |
| * @zh_CN 创建vue-router实例 | |
| */ | |
| const router = createRouter({ | |
| history: | |
| import.meta.env.VITE_ROUTER_HISTORY === 'hash' | |
| ? createWebHashHistory(import.meta.env.VITE_BASE) | |
| : createWebHistory(import.meta.env.VITE_BASE), | |
| // 应该添加到路由的初始路由列表。 | |
| routes, | |
| scrollBehavior: (to, _from, savedPosition) => { | |
| if (savedPosition) { | |
| return savedPosition; | |
| } | |
| return to.hash ? { behavior: 'smooth', el: to.hash } : { left: 0, top: 0 }; | |
| }, | |
| // 是否应该禁止尾部斜杠。 | |
| // strict: true, | |
| }); | |
| const resetRoutes = () => resetStaticRoutes(router, routes); | |
| // 创建路由守卫 | |
| createRouterGuard(router); | |
| export { resetRoutes, router }; | |