chore: update deps

This commit is contained in:
vben
2024-06-01 22:17:52 +08:00
parent c531f0c154
commit f7b97e8a83
47 changed files with 569 additions and 322 deletions

View File

@@ -2,13 +2,12 @@ import type { ExRouteRecordRaw, MenuRecordRaw } from '@vben/types';
import type { RouteRecordRaw, Router } from 'vue-router';
import { LOGIN_PATH } from '@vben/constants';
import { useAccessStore } from '@vben/stores';
import { filterTree, mapTree, traverseTreeValues } from '@vben/utils';
import { dynamicRoutes } from '../routes';
import { dynamicRoutes } from '@/router/routes';
// 登录页面路由 path
const LOGIN_ROUTE_PATH = '/auth/login';
// 不需要权限的页面白名单
const WHITE_ROUTE_NAMES = new Set<string>([]);
@@ -29,14 +28,15 @@ function configAccessGuard(router: Router) {
}
// 白名单路由列表检查
// TODO: 不是很需要,通过 ignoreAccess 也可以做到,考虑删除
if (WHITE_ROUTE_NAMES.has(to.name as string)) {
return true;
}
// 没有访问权限,跳转登录页面
if (to.fullPath !== LOGIN_ROUTE_PATH) {
if (to.fullPath !== LOGIN_PATH) {
return {
path: LOGIN_ROUTE_PATH,
path: LOGIN_PATH,
// 如不需要,直接删除 query
query: { redirect: encodeURIComponent(to.fullPath) },
// 携带当前跳转的页面,登录后重新跳转该页面

View File

@@ -12,9 +12,11 @@ import { configAccessGuard } from './access';
* @param router
*/
function configCommonGuard(router: Router) {
// 记录已经加载的页面
const loadedPaths = new Set<string>();
router.beforeEach(async (to) => {
// 页面加载进度条
if (preference.pageProgress) {
startProgress();
}
@@ -25,6 +27,8 @@ function configCommonGuard(router: Router) {
router.afterEach((to) => {
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
loadedPaths.add(to.path);
// 关闭页面加载进度条
if (preference.pageProgress) {
stopProgress();
}

View File

@@ -2,9 +2,12 @@ import type { RouteRecordRaw } from 'vue-router';
import { AuthPageLayout } from '@/layouts';
import { Fallback } from '@vben/common-ui';
import { $t } from '@vben/locales';
/** 静态路由列表,访问这些页面可以不需要权限 */
const builtinRoutes: RouteRecordRaw[] = [
import Login from '@/views/_essential/authentication/login.vue';
/** 基本路由,这些路由是必须存在的 */
const essentialRoutes: RouteRecordRaw[] = [
{
component: AuthPageLayout,
meta: {
@@ -16,46 +19,50 @@ const builtinRoutes: RouteRecordRaw[] = [
{
name: 'Login',
path: 'login',
component: () => import('@/views/authentication/login.vue'),
component: Login,
meta: {
ignoreAccess: true,
title: 'Login',
title: $t('page.login'),
},
},
{
name: 'CodeLogin',
path: 'code-login',
component: () => import('@/views/authentication/code-login.vue'),
component: () =>
import('@/views/_essential/authentication/code-login.vue'),
meta: {
ignoreAccess: true,
title: 'CodeLogin',
title: $t('page.code-login'),
},
},
{
name: 'QrCodeLogin',
path: 'qrcode-login',
component: () => import('@/views/authentication/qrcode-login.vue'),
component: () =>
import('@/views/_essential/authentication/qrcode-login.vue'),
meta: {
ignoreAccess: true,
title: 'QrCodeLogin',
title: $t('page.qrcode-login'),
},
},
{
name: 'ForgetPassword',
path: 'forget-password',
component: () => import('@/views/authentication/forget-password.vue'),
component: () =>
import('@/views/_essential/authentication/forget-password.vue'),
meta: {
ignoreAccess: true,
title: 'ForgetPassword',
title: $t('page.forget-password'),
},
},
{
name: 'Register',
path: 'register',
component: () => import('@/views/authentication/register.vue'),
component: () =>
import('@/views/_essential/authentication/register.vue'),
meta: {
ignoreAccess: true,
title: 'Register',
title: $t('page.register'),
},
},
],
@@ -67,6 +74,7 @@ const builtinRoutes: RouteRecordRaw[] = [
hideInBreadcrumb: true,
hideInMenu: true,
hideInTab: true,
ignoreAccess: true,
title: 'Fallback',
},
name: 'Fallback',
@@ -74,4 +82,4 @@ const builtinRoutes: RouteRecordRaw[] = [
},
];
export { builtinRoutes };
export { essentialRoutes };

View File

@@ -1,36 +1,15 @@
import type { RouteRecordRaw } from 'vue-router';
import { BasicLayout } from '@/layouts';
import { builtinRoutes } from './builtin';
import { essentialRoutes } from './_essential';
import { nestedRoutes } from './modules/nested';
import { outsideRoutes } from './modules/outside';
import { rootRoutes } from './modules/root';
import { vbenRoutes } from './modules/vben';
/** 动态路由 */
const dynamicRoutes: RouteRecordRaw[] = [
// 根路由
{
component: BasicLayout,
meta: {
hideChildrenInMenu: true,
title: '首页',
},
name: 'Home',
path: '/',
redirect: '/welcome',
children: [
{
name: 'Welcome',
path: '/welcome',
component: () => import('@/views/dashboard/index.vue'),
meta: {
affixTab: true,
title: 'Welcome',
},
},
],
},
...rootRoutes,
...nestedRoutes,
...outsideRoutes,
...vbenRoutes,
@@ -40,6 +19,6 @@ const dynamicRoutes: RouteRecordRaw[] = [
const externalRoutes: RouteRecordRaw[] = [];
/** 静态路由列表,访问这些页面可以不需要权限 */
const staticRoutes: RouteRecordRaw[] = [...builtinRoutes];
const staticRoutes: RouteRecordRaw[] = [...essentialRoutes];
export { dynamicRoutes, externalRoutes, staticRoutes };

View File

@@ -0,0 +1,29 @@
import type { RouteRecordRaw } from 'vue-router';
import { BasicLayout } from '@/layouts';
const rootRoutes: RouteRecordRaw[] = [
{
component: BasicLayout,
meta: {
hideChildrenInMenu: true,
title: '首页',
},
name: 'Home',
path: '/',
redirect: '/welcome',
children: [
{
name: 'Welcome',
path: '/welcome',
component: () => import('@/views/dashboard/index.vue'),
meta: {
affixTab: true,
title: 'Welcome',
},
},
],
},
];
export { rootRoutes };

View File

@@ -0,0 +1,3 @@
# \_essential
此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。