首次提交

This commit is contained in:
2023-06-04 20:01:58 +08:00
parent 00c64c53bb
commit 587f078d21
560 changed files with 106725 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
/**
* @description: 路由的白名单常量对象
* @type: 数组
*/
export const WHITE_LIST = [
{ name: "notFound", children: [] },
{ name: "login", children: [] }
]
/**
* @description: NOTFOUND常量对象{name:'notFound'}
* @type: object
*/
export const NOT_FOUND = {
name: "notFound"
}
export const REDIRECT_ROUTE_NAME = "Redirect"
export const DEFAULT_ROUTE_NAME = "Workplace"
/**
* @description: 默认路由对象没有component,固定在router/constants.js文件查看
* @type: object
*/
export const DEFAULT_ROUTE = {
title: "menu.dashboard.workplace",
name: DEFAULT_ROUTE_NAME,
fullPath: "/dashboard/workplace"
}

31
cdTMP/src/router/index.js Normal file
View File

@@ -0,0 +1,31 @@
import { createRouter, createWebHistory } from "vue-router"
// appRoutes为modules下面的所有路由
import { appRoutes } from "./routes"
// 引入基本重定向路由和notFound路由
import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from "./routes/base"
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: "/",
redirect: "login"
},
{
path: "/login",
name: "login",
component: () => import("@/views/login.vue"),
meta: {
requiresAuth: false
}
},
...appRoutes,
REDIRECT_MAIN,
NOT_FOUND_ROUTE
],
scrollBehavior() {
// 页面跳转后滚动到顶部
return { top: 0 }
}
})
export default router

View File

@@ -0,0 +1,34 @@
import { REDIRECT_ROUTE_NAME } from "@/router/constants"
/**
* @description: 返回import("@/layout/default-layout.vue")
* @type: Promise对象
*/
export const DEFAULT_LAYOUT = () => import("@/layout/default-layout.vue")
export const REDIRECT_MAIN = {
path: "/redirect",
name: "redirectWrapper",
component: DEFAULT_LAYOUT, // () => import("@/layout/default-layout.vue")
meta: {
requiresAuth: true,
hideInMenu: true
},
children: [
{
path: "/redirect/:path",
name: REDIRECT_ROUTE_NAME, // 'Redirect'
component: () => import("@/views/redirect/index.vue"),
meta: {
requiresAuth: true,
hideInMenu: true
}
}
]
}
export const NOT_FOUND_ROUTE = {
path: "/:pathMatch(.*)*",
name: "notFound",
component: () => import("@/views/not-found/index.vue")
}

View File

@@ -0,0 +1 @@
import { setRouteEmitter } from "@/utils/route-listener"

View File

@@ -0,0 +1 @@
import NProgress from 'nprogress'

View File

@@ -0,0 +1,24 @@
// 导入modules文件夹所有js文件
const modules = import.meta.glob("./modules/*.js", { eager: true })
// 导入externalModules下面所有js文件
const externalMoudles = import.meta.glob("./externalModules/*.js", { eager: true })
/**
* @description: 传入一个路由文件和一个空数组
* @return: 返回文件路由的数组
*/
function formatModules(_modules, result) {
Object.keys(_modules).forEach((key) => {
const defaultModule = _modules[key].default // 取文件值需要.default
if (!defaultModule) return
const moduleList = Array.isArray(defaultModule) ? [...defaultModule] : [defaultModule]
result.push(...moduleList)
})
return result
}
/**
* @description: 该变量直接获取moduels文件夹下路由数组
* @return: 返回文件路由的数组
*/
export const appRoutes = formatModules(modules, [])
export const appExternalRoutes = formatModules(externalMoudles, [])

View File

@@ -0,0 +1,27 @@
import { DEFAULT_LAYOUT } from "../base"
const DASHBOARD = {
path: "/dashboard",
name: "dashboard",
component: DEFAULT_LAYOUT, // () => import("@/layout/default-layout.vue")
meta: {
locale: "menu.dashboard",
requiresAuth: true,
icon: "icon-dashboard",
order: 0
},
children: [
{
path: "workplace",
name: "Workplace",
component: () => import("@/views/dashboard/workplace/index.vue"),
meta: {
locale: "menu.dashboard.workplace",
requiresAuth: true,
roles: ["*"]
}
},
]
}
export default DASHBOARD