2022-12-14 18:34:45 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* @Author: Kane
|
|
|
|
|
|
* @Date: 2022-12-14 15:12:46
|
|
|
|
|
|
* @LastEditors: Kane
|
2023-01-12 18:16:45 +08:00
|
|
|
|
* @LastEditTime: 2023-01-12 14:52:09
|
2022-12-14 18:34:45 +08:00
|
|
|
|
* @FilePath: \admin_system\src\router\index.js
|
2023-01-06 18:08:18 +08:00
|
|
|
|
* @Description: 定义应用路由配置
|
2022-12-14 18:34:45 +08:00
|
|
|
|
*
|
|
|
|
|
|
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
|
|
|
|
|
*/
|
2023-01-05 13:18:28 +08:00
|
|
|
|
import { createRouter, createWebHashHistory } from 'vue-router';
|
2022-12-14 15:23:07 +08:00
|
|
|
|
|
|
|
|
|
|
const routes = [
|
2023-01-06 18:08:18 +08:00
|
|
|
|
//框架路由
|
2022-12-14 15:23:07 +08:00
|
|
|
|
{
|
2022-12-14 18:34:45 +08:00
|
|
|
|
path: "/",
|
2023-01-05 13:18:28 +08:00
|
|
|
|
name: "Root",
|
2023-01-11 18:13:39 +08:00
|
|
|
|
redirect: "Login", //默认路由指向登录页面
|
2023-01-05 22:26:40 +08:00
|
|
|
|
hidden: true,
|
2022-12-14 15:23:07 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-12-14 18:34:45 +08:00
|
|
|
|
path: "/login",
|
|
|
|
|
|
name: "Login",
|
|
|
|
|
|
component: () => import("../views/account/Login.vue"),
|
2023-01-05 22:26:40 +08:00
|
|
|
|
hidden: true,
|
2023-01-05 13:18:28 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: "/home",
|
|
|
|
|
|
name: "Home",
|
2023-01-06 18:08:18 +08:00
|
|
|
|
hidden: true,
|
2023-01-05 22:26:40 +08:00
|
|
|
|
meta: {
|
|
|
|
|
|
title: "控制台"
|
|
|
|
|
|
},
|
2023-01-06 18:08:18 +08:00
|
|
|
|
component: () => import("../layout/Index.vue"),
|
|
|
|
|
|
},
|
|
|
|
|
|
//侧边导航栏路由
|
|
|
|
|
|
{ //首页
|
|
|
|
|
|
path: "/console",
|
|
|
|
|
|
name: "Console",
|
|
|
|
|
|
meta: {
|
2023-01-07 11:57:10 +08:00
|
|
|
|
title: "总览",
|
|
|
|
|
|
icon: "house",
|
2023-01-06 18:08:18 +08:00
|
|
|
|
},
|
2023-01-05 22:26:40 +08:00
|
|
|
|
children: [
|
|
|
|
|
|
{
|
2023-01-06 18:08:18 +08:00
|
|
|
|
path: "/desktop",
|
|
|
|
|
|
name: "DeskTop",
|
|
|
|
|
|
meta: {
|
2023-01-07 11:57:10 +08:00
|
|
|
|
title: "工作台",
|
|
|
|
|
|
icon: "house",
|
2023-01-05 22:26:40 +08:00
|
|
|
|
},
|
2023-01-06 18:08:18 +08:00
|
|
|
|
component: () => import("../views/overview/OverView.vue"),
|
2023-01-05 22:26:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
],
|
2023-01-05 13:18:28 +08:00
|
|
|
|
component: () => import("../layout/Index.vue"),
|
2023-01-05 22:26:40 +08:00
|
|
|
|
},
|
2023-01-06 18:08:18 +08:00
|
|
|
|
{//信息管理
|
2023-01-05 22:26:40 +08:00
|
|
|
|
path: "/news",
|
|
|
|
|
|
name: "News",
|
|
|
|
|
|
meta: {
|
|
|
|
|
|
title: "信息管理",
|
2023-01-07 11:57:10 +08:00
|
|
|
|
icon: "edit",
|
2023-01-05 22:26:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
children: [
|
2023-01-12 18:16:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: "/staffInfo",
|
|
|
|
|
|
name: "StaffInfo",
|
|
|
|
|
|
meta: {
|
|
|
|
|
|
title: "人员信息",
|
|
|
|
|
|
icon: "edit",
|
|
|
|
|
|
},
|
|
|
|
|
|
component: () => import("../views/info/StaffInfo.vue"),
|
|
|
|
|
|
},
|
2023-01-05 22:26:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: "/newsIndex",
|
|
|
|
|
|
name: "NewsIndex",
|
2023-01-06 18:08:18 +08:00
|
|
|
|
meta: {
|
2023-01-07 11:57:10 +08:00
|
|
|
|
title: "信息列表",
|
|
|
|
|
|
icon: "edit",
|
2023-01-05 22:26:40 +08:00
|
|
|
|
},
|
2023-01-06 18:08:18 +08:00
|
|
|
|
component: () => import("../views/news/News.vue"),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2023-01-06 23:19:26 +08:00
|
|
|
|
path: "/newsedit",
|
|
|
|
|
|
name: "NewsEdit",
|
2023-01-06 18:08:18 +08:00
|
|
|
|
meta: {
|
2023-01-07 11:57:10 +08:00
|
|
|
|
title: "信息编辑",
|
|
|
|
|
|
icon: "edit",
|
2023-01-06 18:08:18 +08:00
|
|
|
|
},
|
2023-01-06 23:19:26 +08:00
|
|
|
|
component: () => import("../views/news/NewsEdit.vue"),
|
2023-01-05 22:26:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
component: () => import("../layout/Index.vue"),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: "/user",
|
|
|
|
|
|
name: "User",
|
|
|
|
|
|
meta: {
|
|
|
|
|
|
title: "人员管理",
|
2023-01-07 11:57:10 +08:00
|
|
|
|
icon: "edit",
|
2023-01-05 22:26:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
component: () => import("../layout/Index.vue"),
|
|
|
|
|
|
},
|
2022-12-14 18:34:45 +08:00
|
|
|
|
];
|
2022-12-14 15:23:07 +08:00
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
|
|
history: createWebHashHistory(),
|
|
|
|
|
|
routes
|
2023-01-05 13:18:28 +08:00
|
|
|
|
});
|
2022-12-14 15:23:07 +08:00
|
|
|
|
|
2023-01-11 18:13:39 +08:00
|
|
|
|
//前置路由守卫
|
|
|
|
|
|
router.beforeEach((to) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
const token = window.localStorage.getItem("token");
|
|
|
|
|
|
|
|
|
|
|
|
if (!token)
|
|
|
|
|
|
{
|
|
|
|
|
|
//如果token不存在,判断路由是否走向login,如果不是则指向login
|
|
|
|
|
|
//走向login则不干预
|
|
|
|
|
|
if (to.name !== "Login")
|
|
|
|
|
|
{
|
|
|
|
|
|
return {
|
|
|
|
|
|
name: "Login",
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2023-01-05 13:18:28 +08:00
|
|
|
|
export default router;
|