321 lines
10 KiB
TypeScript
Raw Normal View History

2024-04-16 23:57:17 +08:00
import { RouteRecordRaw } from "vue-router";
2024-04-21 16:08:59 +08:00
import { testMultilevelMenu } from "@/mock/testRoute";
2024-04-12 12:34:18 +08:00
/**
* path路径与文件夹名称相同便
*
* meta对象参数meta对象中
* meta: {
2024-04-21 16:08:59 +08:00
* title: 菜单栏以及 tabsView
* link: 是否是超链接菜单1 link 2iframe: false
* hide: 是否隐藏此路由
* keepAlive: 是否缓存组件状态
* affix: 是否固定在 tabsView
* iframe: 是否内嵌窗口1iframetrue 2link
2024-04-12 12:34:18 +08:00
* roles: 当前路由权限表示 admincommon
2024-04-21 16:08:59 +08:00
* icon: 菜单tabsView
* svgIcon: svg图标
2024-04-12 12:34:18 +08:00
* }
*/
/**
*
* children下的一级路由为menu菜单的最外层 `children下的一级路由`
* children下的一级路由内在设置children则是在一级当前菜单下再配置菜单
*
*/
2024-04-16 23:57:17 +08:00
export const dynamicRoutes: RouteRecordRaw[] = [
2024-04-12 12:34:18 +08:00
{
path: "/",
name: "/",
redirect: "/home",
component: () => import("@/layout/index.vue"), // 容器布局-顶层路由
2024-04-16 23:57:17 +08:00
meta: {
2024-04-21 16:08:59 +08:00
keepAlive: true
2024-04-12 12:34:18 +08:00
},
// 二级路由-主要渲染页面
children: [
{
path: "/home",
name: "home",
component: () => import("@/views/home/home.vue"),
meta: {
title: "home", // 国际化
2024-04-21 16:08:59 +08:00
hide: false, // 是否隐藏此路由
2024-05-18 19:35:57 +08:00
keepAlive: false, // 缓存组件状态
2024-04-21 16:08:59 +08:00
affix: true, // 固定在tagesView栏上
link: "", // 是否外链
iframe: false, // 是否内嵌窗口
2024-04-12 12:34:18 +08:00
roles: ["admin", "common"], // 路由权限
2024-04-14 16:51:11 +08:00
svgIcon: "home" // 菜单图标
2024-04-12 12:34:18 +08:00
}
},
{
path: "/home2",
name: "home2",
component: () => import("@/views/home/home.vue"),
meta: {
2024-04-13 15:54:07 +08:00
title: "home", // 国际化
2024-04-21 16:08:59 +08:00
hide: false, // 是否隐藏此路由
2024-05-18 19:35:57 +08:00
keepAlive: false, // 缓存组件状态
2024-04-21 16:08:59 +08:00
affix: true, // 固定在tagesView栏上
link: "", // 是否外链
iframe: false, // 是否内嵌窗口
2024-04-12 12:34:18 +08:00
roles: ["common"], // 路由权限
2024-04-14 16:51:11 +08:00
svgIcon: "home" // 菜单图标
2024-04-12 12:34:18 +08:00
}
},
2024-05-27 13:05:29 +08:00
{
path: "/basic-table",
name: "basic-table",
redirect: "/basic-table/common-table",
meta: {
title: "basic-table",
link: "",
hide: false,
keepAlive: true,
affix: true,
iframe: false,
roles: ["admin"],
svgIcon: "set"
},
children: [
{
path: "/basic-table/common-table",
name: "common-table",
component: () => import("@/views/basic-table/common-table/common-table.vue"),
meta: {
title: "common-table",
link: "",
hide: false,
keepAlive: true,
affix: false,
iframe: false,
roles: ["admin"],
icon: "icon-menu"
}
2024-05-30 23:42:18 +08:00
},
{
path: "/basic-table/custom-table",
name: "custom-table",
component: () => import("@/views/basic-table/custom-table/custom-table.vue"),
meta: {
title: "custom-table",
link: "",
hide: false,
keepAlive: true,
affix: false,
iframe: false,
roles: ["admin"],
icon: "icon-menu"
}
2024-05-27 13:05:29 +08:00
}
]
},
2024-04-12 12:34:18 +08:00
{
path: "/common-components",
name: "common-components",
redirect: "/common-components/form-component",
meta: {
title: "common-components",
2024-04-21 16:08:59 +08:00
link: "",
hide: false,
keepAlive: true,
affix: true,
iframe: false,
2024-04-12 12:34:18 +08:00
roles: ["admin"],
2024-04-14 16:51:11 +08:00
svgIcon: "set"
2024-04-12 12:34:18 +08:00
},
children: [
{
path: "/common-components/form-component",
name: "form-component",
component: () => import("@/views/common-components/form-component/form-component.vue"),
meta: {
title: "form-component",
2024-04-21 16:08:59 +08:00
link: "",
hide: false,
keepAlive: true,
affix: false,
iframe: false,
2024-04-12 12:34:18 +08:00
roles: ["admin"],
2024-04-14 16:51:11 +08:00
icon: "icon-menu"
2024-04-12 12:34:18 +08:00
}
2024-04-21 00:26:49 +08:00
},
{
path: "/common-components/dynamic-form",
name: "dynamic-form",
component: () => import("@/views/common-components/dynamic-form/dynamic-form.vue"),
meta: {
title: "dynamic-form",
2024-04-21 16:08:59 +08:00
link: "",
hide: false,
keepAlive: true,
affix: false,
iframe: false,
2024-04-21 00:26:49 +08:00
roles: ["admin"],
icon: "icon-menu"
}
2024-04-12 12:34:18 +08:00
}
]
},
{
path: "/multilevel-menu",
name: "multilevel-menu",
2024-04-23 23:31:00 +08:00
redirect: "/multilevel-menu/second-menu-1",
2024-04-12 12:34:18 +08:00
meta: {
title: "multilevel-menu",
2024-04-21 16:08:59 +08:00
link: "",
hide: false,
keepAlive: true,
affix: true,
iframe: false,
2024-04-12 12:34:18 +08:00
roles: ["admin"],
2024-04-14 16:51:11 +08:00
svgIcon: "switch"
2024-04-12 12:34:18 +08:00
},
children: [
{
2024-04-21 00:26:49 +08:00
path: "/multilevel-menu/second-menu-1",
name: "second-menu-1",
component: () => import("@/views/multilevel-menu/second-menu/second-menu-1.vue"),
2024-04-12 12:34:18 +08:00
meta: {
2024-04-21 00:26:49 +08:00
title: "second-menu-1",
2024-04-21 16:08:59 +08:00
link: "",
hide: false,
keepAlive: true,
affix: false,
iframe: false,
2024-04-21 00:26:49 +08:00
roles: ["admin"],
icon: "icon-menu"
}
},
{
path: "/multilevel-menu/second-menu-2",
name: "second-menu-2",
2024-04-23 23:31:00 +08:00
redirect: "/multilevel-menu/third-menu-1",
2024-04-21 00:26:49 +08:00
meta: {
title: "second-menu-2",
2024-04-21 16:08:59 +08:00
link: "",
hide: false,
keepAlive: true,
affix: false,
iframe: false,
2024-04-12 12:34:18 +08:00
roles: ["admin"],
2024-04-14 16:51:11 +08:00
icon: "icon-menu"
2024-04-12 12:34:18 +08:00
},
children: [
{
2024-04-21 00:26:49 +08:00
path: "/multilevel-menu/third-menu-1",
name: "third-menu-1",
component: () => import("@/views/multilevel-menu/third-menu/third-menu-1.vue"),
meta: {
title: "third-menu-1",
2024-04-21 16:08:59 +08:00
link: "",
hide: false,
keepAlive: true,
affix: false,
iframe: false,
2024-04-21 00:26:49 +08:00
roles: ["admin"],
icon: "icon-menu"
}
},
{
path: "/multilevel-menu/third-menu-2",
name: "third-menu-2",
component: () => import("@/views/multilevel-menu/third-menu/third-menu-2.vue"),
2024-04-12 12:34:18 +08:00
meta: {
2024-04-21 00:26:49 +08:00
title: "third-menu-2",
2024-04-21 16:08:59 +08:00
link: "",
hide: false,
keepAlive: true,
affix: false,
iframe: false,
2024-04-12 12:34:18 +08:00
roles: ["admin"],
2024-04-14 16:51:11 +08:00
icon: "icon-menu"
2024-04-12 12:34:18 +08:00
}
2024-04-21 16:08:59 +08:00
},
...testMultilevelMenu
2024-04-12 12:34:18 +08:00
]
}
]
2024-04-14 16:51:11 +08:00
},
2024-04-27 19:18:49 +08:00
{
path: "/internationalization",
name: "internationalization",
component: () => import("@/views/internationalization/internationalization.vue"),
meta: {
title: "internationalization",
hide: false,
keepAlive: true,
affix: false,
link: "",
iframe: false,
roles: ["admin", "common"],
svgIcon: "earth"
}
},
2024-04-14 16:51:11 +08:00
{
path: "/about-project",
name: "about-project",
component: () => import("@/views/about-project/about-project.vue"),
meta: {
title: "about-project",
2024-04-21 16:08:59 +08:00
hide: false,
keepAlive: true,
2024-05-04 23:36:38 +08:00
affix: false,
2024-04-21 16:08:59 +08:00
link: "",
iframe: false,
2024-04-14 16:51:11 +08:00
roles: ["admin", "common"],
svgIcon: "about"
}
2024-04-12 12:34:18 +08:00
}
]
}
];
/**
*
* `dynamicRoutes数组`
* @description dynamicRoutes dynamicRoutes children lauyout
* @returns
*/
export const staticRoutes = [
{
path: "/login",
name: "login",
component: () => import("@/views/login/login.vue"),
meta: {
2024-04-27 19:18:49 +08:00
title: "login"
2024-04-12 12:34:18 +08:00
}
}
/**
*
* dynamicRoutes
*/
];
/**
* 404401
* @link https://router.vuejs.org/zh/guide/essentials/history-mode.html#netlify
*/
export const notFoundAndNoPower = [
{
2024-04-18 00:24:07 +08:00
path: "/401",
2024-04-27 19:18:49 +08:00
name: "no-power",
2024-04-18 00:24:07 +08:00
component: () => import("@/views/error/401.vue"),
2024-04-12 12:34:18 +08:00
meta: {
2024-04-27 19:18:49 +08:00
title: "not-power",
2024-04-21 16:08:59 +08:00
hide: true
2024-04-12 12:34:18 +08:00
}
},
{
2024-04-18 00:24:07 +08:00
path: "/:path(.*)*", // 匹配任意路由,兜底,未找到页面的时候跳转该页面
2024-04-27 19:18:49 +08:00
name: "not-found",
2024-04-18 00:24:07 +08:00
component: () => import("@/views/error/404.vue"),
2024-04-12 12:34:18 +08:00
meta: {
2024-04-27 19:18:49 +08:00
title: "not-found",
2024-04-21 16:08:59 +08:00
hide: true
2024-04-12 12:34:18 +08:00
}
}
];