first commit
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
import path from "path";
|
||||
import type { App } from "vue";
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
|
||||
|
||||
export const Layout = () => import("@/layout/index.vue");
|
||||
|
||||
// 静态路由
|
||||
export const constantRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: "/redirect",
|
||||
component: Layout,
|
||||
meta: { hidden: true },
|
||||
children: [
|
||||
{
|
||||
path: "/redirect/:path(.*)",
|
||||
component: () => import("@/views/redirect/index.vue"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/autoLogin",
|
||||
name: "AutoLogin",
|
||||
component: () => import("@/views/autoLogin/index.vue"),
|
||||
meta: { hidden: true },
|
||||
},
|
||||
{
|
||||
path: "/software",
|
||||
name: "Software",
|
||||
component: () => import("@/views/software/index.vue"),
|
||||
meta: { hidden: true },
|
||||
children: [
|
||||
{
|
||||
path: "id/:id/os/:os",
|
||||
component: () => import("@/views/software/index.vue"),
|
||||
children: [{ path: "fonts/:fonts", component: () => import("@/views/software/index.vue") }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/helper",
|
||||
name: "Helper",
|
||||
component: () => import("@/views/helper/index.vue"),
|
||||
meta: { hidden: true },
|
||||
children: [
|
||||
{
|
||||
path: "id/:id",
|
||||
component: () => import("@/views/helper/index.vue"),
|
||||
},
|
||||
{
|
||||
path: "page/:page",
|
||||
component: () => import("@/views/helper/index.vue"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/resetPassword",
|
||||
name: "ResetPassword",
|
||||
component: () => import("@/views/resetPassword/index.vue"),
|
||||
meta: { hidden: true },
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
name: "/",
|
||||
component: Layout,
|
||||
redirect: "/software",
|
||||
children: [
|
||||
{
|
||||
path: "dashboard",
|
||||
component: () => import("@/views/dashboard/index.vue"),
|
||||
// 用于 keep-alive 功能,需要与 SFC 中自动推导或显式声明的组件名称一致
|
||||
// 参考文档: https://cn.vuejs.org/guide/built-ins/keep-alive.html#include-exclude
|
||||
name: "Dashboard",
|
||||
meta: {
|
||||
title: "账号信息",
|
||||
icon: "homepage",
|
||||
affix: true,
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "401",
|
||||
component: () => import("@/views/error-page/401.vue"),
|
||||
meta: { hidden: true },
|
||||
},
|
||||
{
|
||||
path: "404",
|
||||
component: () => import("@/views/error-page/404.vue"),
|
||||
meta: { hidden: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// 外部链接
|
||||
// {
|
||||
// path: "/external-link",
|
||||
// component: Layout,
|
||||
// children: [ {
|
||||
// component: () => import("@/views/external-link/index.vue"),
|
||||
// path: "https://www.cnblogs.com/haoxianrui/",
|
||||
// meta: { title: "外部链接", icon: "link" },
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// 多级嵌套路由
|
||||
/* {
|
||||
path: '/nested',
|
||||
component: Layout,
|
||||
redirect: '/nested/level1/level2',
|
||||
name: 'Nested',
|
||||
meta: {title: '多级菜单', icon: 'nested'},
|
||||
children: [
|
||||
{
|
||||
path: 'level1',
|
||||
component: () => import('@/views/nested/level1/index.vue'),
|
||||
name: 'Level1',
|
||||
meta: {title: '菜单一级'},
|
||||
redirect: '/nested/level1/level2',
|
||||
children: [
|
||||
{
|
||||
path: 'level2',
|
||||
component: () => import('@/views/nested/level1/level2/index.vue'),
|
||||
name: 'Level2',
|
||||
meta: {title: '菜单二级'},
|
||||
redirect: '/nested/level1/level2/level3',
|
||||
children: [
|
||||
{
|
||||
path: 'level3-1',
|
||||
component: () => import('@/views/nested/level1/level2/level3/index1.vue'),
|
||||
name: 'Level3-1',
|
||||
meta: {title: '菜单三级-1'}
|
||||
},
|
||||
{
|
||||
path: 'level3-2',
|
||||
component: () => import('@/views/nested/level1/level2/level3/index2.vue'),
|
||||
name: 'Level3-2',
|
||||
meta: {title: '菜单三级-2'}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
}*/
|
||||
];
|
||||
|
||||
/**
|
||||
* 创建路由
|
||||
*/
|
||||
const router = createRouter({
|
||||
history: createWebHistory(), // createWebHashHistory(),
|
||||
routes: constantRoutes,
|
||||
// 刷新时,滚动条位置还原
|
||||
scrollBehavior: () => ({ left: 0, top: 0 }),
|
||||
});
|
||||
|
||||
// 全局注册 router
|
||||
export function setupRouter(app: App<Element>) {
|
||||
app.use(router);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置路由
|
||||
*/
|
||||
export function resetRouter() {
|
||||
router.replace({ path: "/index" });
|
||||
}
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user