121 lines
2.6 KiB
JavaScript
Raw Normal View History

2023-02-28 01:16:49 +08:00
/*
* @Author: Kane
2023-02-28 09:30:02 +08:00
* @Date: 2023-02-28 01:22:48
2023-02-28 01:16:49 +08:00
* @LastEditors: Kane
2023-02-28 19:58:03 +08:00
* @FilePath: /task_schedule/src/router/index.js
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
2023-02-28 01:16:49 +08:00
*/
2023-02-28 09:30:02 +08:00
2023-02-28 01:16:49 +08:00
import { createRouter, createWebHashHistory } from "vue-router";
const routes = [
{
path: "/",
name: "Root",
redirect: "Login",
hidden: true,
},
{
path: "/login",
name: "Login",
hidden: true,
component: async () => await import( "@/views/Login.vue" ),
2023-02-28 19:58:03 +08:00
},
2023-03-23 18:39:15 +08:00
// 桌面霸屏
2023-03-03 16:08:27 +08:00
{
path: "/desktop_archievement",
name: "DesktopArchievement",
hidden: true,
component: async () => await import( "@/views/DesktopArchievement.vue" ),
2023-03-03 16:08:27 +08:00
},
2023-03-23 18:39:15 +08:00
// 工作台
{
path:"/console",
name:"Console",
meta: {
title: "总览",
icon: "house",
},
component: ()=> import("../layout/Index.vue"),
children:[
{
path:"/desktop",
name:"Desktop",
meta: {
title:"工作台",
icon: "house",
},
component: ()=> import("../views/Desktop.vue"),
},
],
},
//数据管理
{
path:"/data",
name:"Data",
meta:{
title:"数据管理",
icon: "document",
},
component: ()=> import("../layout/Index.vue"),
children:[
{
path:"/staff_data",
name:"StaffDataManagement",
meta: {
title:"坐席管理",
icon: "user",
},
component: ()=> import("../views/StaffManagement.vue"),
},
{
path:"/archievement_data",
name:"ArchievementDataManagement",
meta: {
title:"数据管理",
icon: "document",
},
component: ()=> import("../views/DataManagement.vue"),
},
],
},
2023-02-28 01:16:49 +08:00
];
const router = createRouter(
{
history: createWebHashHistory(),
routes,
}
);
// 路由守卫
2023-03-03 16:08:27 +08:00
// router.beforeEach((to) =>
// {
2023-03-01 18:47:16 +08:00
2023-03-03 16:08:27 +08:00
// });
2023-03-01 18:47:16 +08:00
2023-03-23 18:39:15 +08:00
// 工具函数
function hasOnlyChild( children )
{
if ( !children )
{
return false;
}
const routes = children.filter((item)=>
{
return !item.hidden;
});
if ( routes.length === 1)
{
return true;
}
return false;
}
export { router, hasOnlyChild };