mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 多页签绑定路由
This commit is contained in:
@ -1,24 +1,3 @@
|
||||
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
|
||||
import type { App } from 'vue';
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import { constantRoutes, customRoutes, RouteNameMap } from './routes';
|
||||
import createRouterGuide from './permission';
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [...customRoutes, ...constantRoutes];
|
||||
|
||||
/** 用于部署vercel托管服务 */
|
||||
const isVercel = import.meta.env.VITE_HTTP_ENV === 'VERCEL';
|
||||
|
||||
export const router = createRouter({
|
||||
history: isVercel ? createWebHashHistory() : createWebHistory(),
|
||||
routes
|
||||
});
|
||||
|
||||
export async function setupRouter(app: App) {
|
||||
app.use(router);
|
||||
createRouterGuide(router);
|
||||
await router.isReady();
|
||||
}
|
||||
|
||||
export { RouteNameMap };
|
||||
export { router, setupRouter } from './setup';
|
||||
export { RouteNameMap, ROUTE_HOME, customRoutes } from './routes';
|
||||
export { menus } from './menus';
|
||||
|
@ -17,7 +17,7 @@ const loginModuleRegExp = getLoginModuleRegExp();
|
||||
* 固定不变的路由
|
||||
* @description !最后一项重定向未找到的路由须放置路由的最后一项
|
||||
*/
|
||||
export const constantRoutes: RouteRecordRaw[] = [
|
||||
const constantRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
name: RouteNameMap.get('system'),
|
||||
path: EnumRoutePath.system,
|
||||
@ -82,6 +82,17 @@ export const constantRoutes: RouteRecordRaw[] = [
|
||||
}
|
||||
];
|
||||
|
||||
/** 路由首页 */
|
||||
export const ROUTE_HOME: CustomRoute = {
|
||||
name: RouteNameMap.get('dashboard-analysis'),
|
||||
path: EnumRoutePath['dashboard-analysis'],
|
||||
component: () => import('@/views/dashboard/analysis/index.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
title: EnumRouteTitle['dashboard-analysis']
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 自定义路由
|
||||
*/
|
||||
@ -89,10 +100,24 @@ export const customRoutes: CustomRoute[] = [
|
||||
{
|
||||
name: RouteNameMap.get('root'),
|
||||
path: EnumRoutePath.root,
|
||||
redirect: { name: RouteNameMap.get('dashboard-analysis') },
|
||||
component: BasicLayout,
|
||||
redirect: { name: ROUTE_HOME.name },
|
||||
meta: {
|
||||
isNotMenu: true
|
||||
}
|
||||
},
|
||||
children: [
|
||||
// 重载
|
||||
{
|
||||
name: RouteNameMap.get('reload'),
|
||||
path: EnumRoutePath.reload,
|
||||
component: () => import('@/views/system/reload/index.vue'),
|
||||
meta: {
|
||||
title: EnumRouteTitle.reload,
|
||||
isNotMenu: true,
|
||||
fullPage: true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: RouteNameMap.get('dashboard'),
|
||||
@ -105,15 +130,7 @@ export const customRoutes: CustomRoute[] = [
|
||||
icon: Dashboard
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: RouteNameMap.get('dashboard-analysis'),
|
||||
path: EnumRoutePath['dashboard-analysis'],
|
||||
component: () => import('@/views/dashboard/analysis/index.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
title: EnumRouteTitle['dashboard-analysis']
|
||||
}
|
||||
},
|
||||
ROUTE_HOME,
|
||||
{
|
||||
name: RouteNameMap.get('dashboard-workbench'),
|
||||
path: EnumRoutePath['dashboard-workbench'],
|
||||
@ -169,10 +186,5 @@ export const customRoutes: CustomRoute[] = [
|
||||
}
|
||||
];
|
||||
|
||||
/** 路由白名单(不需要登录) */
|
||||
export const whitelistRoutes: string[] = [
|
||||
RouteNameMap.get('login')!,
|
||||
RouteNameMap.get('exception-403')!,
|
||||
RouteNameMap.get('exception-404')!,
|
||||
RouteNameMap.get('exception-500')!
|
||||
];
|
||||
/** 所有路由 */
|
||||
export const routes: RouteRecordRaw[] = [...customRoutes, ...constantRoutes];
|
||||
|
18
src/router/setup.ts
Normal file
18
src/router/setup.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
|
||||
import type { App } from 'vue';
|
||||
import { routes } from './routes';
|
||||
import createRouterGuide from './permission';
|
||||
|
||||
/** 用于部署vercel托管服务 */
|
||||
const isVercel = import.meta.env.VITE_HTTP_ENV === 'VERCEL';
|
||||
|
||||
export const router = createRouter({
|
||||
history: isVercel ? createWebHashHistory() : createWebHistory(),
|
||||
routes
|
||||
});
|
||||
|
||||
export async function setupRouter(app: App) {
|
||||
app.use(router);
|
||||
createRouterGuide(router);
|
||||
await router.isReady();
|
||||
}
|
Reference in New Issue
Block a user