Files
it-console/code/web/IT工具综合平台/src/router/index.js

195 lines
4.3 KiB
JavaScript
Raw Normal View History

2023-01-29 10:17:49 +08:00
/*
* @Author: Kane
* @Date: 2022-12-14 15:12:46
* @LastEditors: Kane
2023-02-04 23:39:29 +08:00
* @LastEditTime: 2023-02-04 22:36:13
* @FilePath: /IT/src/router/index.js
2023-01-29 10:17:49 +08:00
* @Description: 定义应用路由配置
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import { createRouter, createWebHashHistory } from 'vue-router';
const routes = [
//框架路由
{
path: "/",
name: "Root",
redirect: "Login", //默认路由指向登录页面
hidden: true,
},
2023-02-04 23:39:29 +08:00
{
path:"/error-page",
name: "ErrorPage",
hidden: true,
component: ()=> import("@/views/ErrorPage.vue"),
},
2023-01-29 10:17:49 +08:00
{
path: "/login",
name: "Login",
component: () => import("../views/account/Login.vue"),
hidden: true,
},
{
path: "/home",
name: "Home",
hidden: true,
meta: {
title: "控制台"
},
component: () => import("../layout/Index.vue"),
},
//侧边导航栏路由
{ //首页
path: "/console",
name: "Console",
meta: {
title: "总览",
icon: "house",
},
component: () => import("../layout/Index.vue"),
children: [
{
path: "/desktop",
name: "DeskTop",
meta: {
title: "工作台",
icon: "house",
},
2023-01-30 23:25:57 +08:00
component: () => import("../views/overview/Desktop.vue"),
2023-01-29 10:17:49 +08:00
},
],
},
{
//需求管理
path: "/requirement",
name: "Requirement",
meta: {
title: "需求管理",
icon: "Document",
},
component: () => import("../layout/Index.vue"),
children: [
{
path: "/requirement-manager",
name: "RequirementManager",
meta: {
title: "需求管理",
icon: "Document",
},
2023-02-03 17:16:46 +08:00
component: () => import("../views/requirement/RequirementManager.vue"),
2023-01-29 10:17:49 +08:00
},
{
path: "/requirement-editing",
name: "RequirementEditing",
hidden: true,
meta: {
title: "需求管理",
icon: "edit",
},
component: () => import("../views/requirement/RequirementEditing.vue"),
},
],
},
{//信息管理
2023-02-03 19:04:51 +08:00
path: "/privilege",
name: "Privilege",
2023-01-29 10:17:49 +08:00
meta: {
2023-02-03 19:04:51 +08:00
title: "权限管理",
icon: "User",
2023-01-29 10:17:49 +08:00
},
children: [
{
2023-02-03 19:04:51 +08:00
path: "/user-manager",
name: "UserManager",
2023-01-29 10:17:49 +08:00
meta: {
2023-02-03 19:04:51 +08:00
title: "用户管理",
icon: "User",
2023-01-29 10:17:49 +08:00
},
2023-02-03 19:04:51 +08:00
component: () => import("../views/privilege/StaffInfo.vue"),
2023-01-29 10:17:49 +08:00
},
{
2023-02-03 19:04:51 +08:00
path: "/privilege-manager",
name: "PrivilegeManager",
2023-01-29 10:17:49 +08:00
meta: {
2023-02-03 19:04:51 +08:00
title: "权限管理",
2023-01-29 10:17:49 +08:00
icon: "edit",
},
2023-02-03 19:04:51 +08:00
component: () => import("../views/privilege/PrivilegeManager.vue"),
2023-01-29 10:17:49 +08:00
},
],
component: () => import("../layout/Index.vue"),
},
{
path: "/network",
name: "NetworkManager",
meta: {
title: "网络管理",
2023-02-03 19:04:51 +08:00
icon: "switch",
2023-01-29 10:17:49 +08:00
},
component: () => import("../layout/Index.vue"),
children: [
{
path: "/network-point-manager",
name: "NetworkPointManager",
meta: {
title: "网络点管理",
icon: "Monitor",
},
component: () => import("../views/network/NetworkPoint/NetworkPoint.vue"),
},
{
path: "/network-point-edit",
name: "NetworkPointEdit",
hidden: true,
component: () => import("../views/network/NetworkPoint/EditNetworkPoint.vue"),
},
{
path: "/switch-manager",
name: "SwitchManager",
meta: {
title: "交换机管理",
icon: "switch",
},
component: () => import("../views/network/switch/SwitchManager.vue"),
}
],
},
];
const router = createRouter({
history: createWebHashHistory(),
routes
});
//前置路由守卫
router.beforeEach((to) =>
{
const token = window.localStorage.getItem("token");
//先检查token
if (!token)
{
//如果token不存在判断路由是否走向login,如果不是则指向login
//走向login则不干预
if (to.name !== "Login")
{
return {
name: "Login",
};
}
}
//修改默认打开的页面,跳向工作台
// if (to.name === "Home")
// {
// console.log("跳向工作台");
// return {
// name: "DeskTop",
// };
// }
});
export default router;