chore: format code
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { generatorMenus, generatorRoutes } from '@vben-core/helpers';
|
||||
import { preferences } from '@vben-core/preferences';
|
||||
import { useAccessStore } from '@vben-core/stores';
|
||||
import type { RouteLocationNormalized, Router } from 'vue-router';
|
||||
|
||||
import { LOGIN_PATH } from '@vben/constants';
|
||||
import { $t } from '@vben/locales';
|
||||
import { startProgress, stopProgress } from '@vben/utils';
|
||||
import { generatorMenus, generatorRoutes } from '@vben-core/helpers';
|
||||
import { preferences } from '@vben-core/preferences';
|
||||
import { useAccessStore } from '@vben-core/stores';
|
||||
|
||||
import { useTitle } from '@vueuse/core';
|
||||
|
||||
import { dynamicRoutes } from '@/router/routes';
|
||||
@@ -81,15 +82,16 @@ function setupAccessGuard(router: Router) {
|
||||
// 生成路由表
|
||||
// 当前登录用户拥有的角色标识列表
|
||||
const userRoles = accessStore.getUserRoles;
|
||||
const routes = await generatorRoutes(dynamicRoutes, userRoles);
|
||||
const accessibleRoutes = await generatorRoutes(dynamicRoutes, userRoles);
|
||||
// 动态添加到router实例内
|
||||
routes.forEach((route) => router.addRoute(route));
|
||||
accessibleRoutes.forEach((route) => router.addRoute(route));
|
||||
|
||||
const menus = await generatorMenus(routes, router);
|
||||
// 生成菜单
|
||||
const menus = await generatorMenus(accessibleRoutes, router);
|
||||
|
||||
// 保存菜单信息和路由信息
|
||||
accessStore.setAccessMenus(menus);
|
||||
accessStore.setAccessRoutes(routes);
|
||||
accessStore.setAccessRoutes(accessibleRoutes);
|
||||
const redirectPath = (from.query.redirect ?? to.path) as string;
|
||||
|
||||
return {
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import type { RouteRecordName, RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import { traverseTreeValues } from '@vben/utils';
|
||||
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
|
||||
import { traverseTreeValues } from '@vben/utils';
|
||||
|
||||
import { createRouterGuard } from './guard';
|
||||
import { routes } from './routes';
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import { AuthPageLayoutType } from '@/layouts';
|
||||
import { Fallback } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { AuthPageLayoutType } from '@/layouts';
|
||||
|
||||
import Login from '@/views/_essential/authentication/login.vue';
|
||||
|
||||
/** 基本路由,这些路由是必须存在的 */
|
||||
const essentialRoutes: RouteRecordRaw[] = [
|
||||
const essentialsRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
component: AuthPageLayoutType,
|
||||
meta: {
|
||||
@@ -69,7 +69,7 @@ const essentialRoutes: RouteRecordRaw[] = [
|
||||
},
|
||||
// 错误页
|
||||
{
|
||||
component: Fallback,
|
||||
component: () => import('@/views/_essential/fallback/not-found.vue'),
|
||||
meta: {
|
||||
hideInBreadcrumb: true,
|
||||
hideInMenu: true,
|
||||
@@ -82,4 +82,4 @@ const essentialRoutes: RouteRecordRaw[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export { essentialRoutes };
|
||||
export { essentialsRoutes };
|
@@ -1,8 +1,9 @@
|
||||
import { preferences } from '@vben-core/preferences';
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import { BasicLayout, IFrameView } from '@/layouts';
|
||||
import { VBEN_GITHUB_URL } from '@vben/constants';
|
||||
import { preferences } from '@vben-core/preferences';
|
||||
|
||||
import { BasicLayout, IFrameView } from '@/layouts';
|
||||
import { $t } from '@vben/locales/helper';
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { mergeRouteModules } from '@vben-core/helpers';
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import { essentialRoutes } from './_essential';
|
||||
import { mergeRouteModules } from '@vben-core/helpers';
|
||||
|
||||
import { essentialsRoutes } from './_essentials';
|
||||
|
||||
const dynamicRouteFiles = import.meta.glob('./dynamic/**/*.ts', {
|
||||
eager: true,
|
||||
@@ -23,6 +24,6 @@ const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
|
||||
const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
||||
|
||||
/** 路由列表,由基本路由+静态路由组成 */
|
||||
const routes: RouteRecordRaw[] = [...essentialRoutes, ...staticRoutes];
|
||||
const routes: RouteRecordRaw[] = [...essentialsRoutes, ...staticRoutes];
|
||||
|
||||
export { dynamicRoutes, externalRoutes, routes };
|
||||
|
Reference in New Issue
Block a user