Skip to content

Commit 5e0b01c

Browse files
committed
feat: add @vben/hooks and @vben-core/constants
1 parent daa31f7 commit 5e0b01c

34 files changed

+161
-44
lines changed

apps/web-antd/src/forward/access.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import { getAllMenus } from '#/apis';
1212
import { BasicLayout, IFrameView } from '#/layouts';
1313
import { $t } from '#/locales';
1414

15-
const forbiddenComponent = () =>
16-
import('#/views/_essential/fallback/forbidden.vue');
15+
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
1716

1817
async function generateAccess(options: GenerateMenuAndRoutesOptions) {
1918
const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');

apps/web-antd/src/router/guard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useTitle } from '@vueuse/core';
88

99
import { generateAccess } from '#/forward';
1010
import { $t } from '#/locales';
11-
import { dynamicRoutes, essentialsRouteNames } from '#/router/routes';
11+
import { coreRouteNames, dynamicRoutes } from '#/router/routes';
1212
import { useAccessStore } from '#/store';
1313

1414
/**
@@ -63,7 +63,7 @@ function setupAccessGuard(router: Router) {
6363
if (!accessToken) {
6464
if (
6565
// 基本路由,这些路由不需要进入权限拦截
66-
essentialsRouteNames.includes(to.name as string) ||
66+
coreRouteNames.includes(to.name as string) ||
6767
// 明确声明忽略权限访问权限,则可以访问
6868
to.meta.ignoreAccess
6969
) {

apps/web-antd/src/router/routes/_essentials.ts renamed to apps/web-antd/src/router/routes/core.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { DEFAULT_HOME_PATH } from '@vben/constants';
44

55
import { AuthPageLayout } from '#/layouts';
66
import { $t } from '#/locales';
7-
import Login from '#/views/_essential/authentication/login.vue';
7+
import Login from '#/views/_core/authentication/login.vue';
88

99
/** 全局404页面 */
1010
const fallbackNotFoundRoute: RouteRecordRaw = {
11-
component: () => import('#/views/_essential/fallback/not-found.vue'),
11+
component: () => import('#/views/_core/fallback/not-found.vue'),
1212
meta: {
1313
hideInBreadcrumb: true,
1414
hideInMenu: true,
@@ -20,7 +20,7 @@ const fallbackNotFoundRoute: RouteRecordRaw = {
2020
};
2121

2222
/** 基本路由,这些路由是必须存在的 */
23-
const essentialsRoutes: RouteRecordRaw[] = [
23+
const coreRoutes: RouteRecordRaw[] = [
2424
{
2525
meta: {
2626
title: 'Root',
@@ -42,47 +42,45 @@ const essentialsRoutes: RouteRecordRaw[] = [
4242
path: 'login',
4343
component: Login,
4444
meta: {
45-
title: $t('page.essentials.login'),
45+
title: $t('page.core.login'),
4646
},
4747
},
4848
{
4949
name: 'CodeLogin',
5050
path: 'code-login',
51-
component: () =>
52-
import('#/views/_essential/authentication/code-login.vue'),
51+
component: () => import('#/views/_core/authentication/code-login.vue'),
5352
meta: {
54-
title: $t('page.essentials.codeLogin'),
53+
title: $t('page.core.codeLogin'),
5554
},
5655
},
5756
{
5857
name: 'QrCodeLogin',
5958
path: 'qrcode-login',
6059
component: () =>
61-
import('#/views/_essential/authentication/qrcode-login.vue'),
60+
import('#/views/_core/authentication/qrcode-login.vue'),
6261
meta: {
63-
title: $t('page.essentials.qrcodeLogin'),
62+
title: $t('page.core.qrcodeLogin'),
6463
},
6564
},
6665
{
6766
name: 'ForgetPassword',
6867
path: 'forget-password',
6968
component: () =>
70-
import('#/views/_essential/authentication/forget-password.vue'),
69+
import('#/views/_core/authentication/forget-password.vue'),
7170
meta: {
72-
title: $t('page.essentials.forgetPassword'),
71+
title: $t('page.core.forgetPassword'),
7372
},
7473
},
7574
{
7675
name: 'Register',
7776
path: 'register',
78-
component: () =>
79-
import('#/views/_essential/authentication/register.vue'),
77+
component: () => import('#/views/_core/authentication/register.vue'),
8078
meta: {
81-
title: $t('page.essentials.register'),
79+
title: $t('page.core.register'),
8280
},
8381
},
8482
],
8583
},
8684
];
8785

88-
export { essentialsRoutes, fallbackNotFoundRoute };
86+
export { coreRoutes, fallbackNotFoundRoute };

apps/web-antd/src/router/routes/index.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { RouteRecordRaw } from 'vue-router';
33
import { traverseTreeValues } from '@vben/utils';
44
import { mergeRouteModules } from '@vben-core/helpers';
55

6-
import { essentialsRoutes, fallbackNotFoundRoute } from './_essentials';
6+
import { coreRoutes, fallbackNotFoundRoute } from './core';
77

88
const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
99
eager: true,
@@ -21,15 +21,12 @@ const staticRoutes: RouteRecordRaw[] = [];
2121

2222
/** 路由列表,由基本路由+静态路由组成 */
2323
const routes: RouteRecordRaw[] = [
24-
...essentialsRoutes,
24+
...coreRoutes,
2525
...staticRoutes,
2626
fallbackNotFoundRoute,
2727
];
2828

2929
/** 基本路由列表,这些路由不需要进入权限拦截 */
30-
const essentialsRouteNames = traverseTreeValues(
31-
essentialsRoutes,
32-
(route) => route.name,
33-
);
30+
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
3431

35-
export { dynamicRoutes, essentialsRouteNames, routes };
32+
export { coreRouteNames, dynamicRoutes, routes };

apps/web-antd/src/router/routes/modules/demos.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ const routes: RouteRecordRaw[] = [
141141
{
142142
name: 'Fallback403',
143143
path: '403',
144-
component: () =>
145-
import('#/views/_essential/fallback/forbidden.vue'),
144+
component: () => import('#/views/_core/fallback/forbidden.vue'),
146145
meta: {
147146
icon: 'mdi:do-not-disturb-alt',
148147
title: '403',
@@ -151,8 +150,7 @@ const routes: RouteRecordRaw[] = [
151150
{
152151
name: 'Fallback404',
153152
path: '404',
154-
component: () =>
155-
import('#/views/_essential/fallback/not-found.vue'),
153+
component: () => import('#/views/_core/fallback/not-found.vue'),
156154
meta: {
157155
icon: 'mdi:table-off',
158156
title: '404',
@@ -162,7 +160,7 @@ const routes: RouteRecordRaw[] = [
162160
name: 'Fallback500',
163161
path: '500',
164162
component: () =>
165-
import('#/views/_essential/fallback/internal-error.vue'),
163+
import('#/views/_core/fallback/internal-error.vue'),
166164
meta: {
167165
icon: 'mdi:server-network-off',
168166
title: '500',
@@ -171,7 +169,7 @@ const routes: RouteRecordRaw[] = [
171169
{
172170
name: 'FallbackOffline',
173171
path: 'offline',
174-
component: () => import('#/views/_essential/fallback/offline.vue'),
172+
component: () => import('#/views/_core/fallback/offline.vue'),
175173
meta: {
176174
icon: 'mdi:offline',
177175
title: $t('fallback.offline'),

apps/web-antd/src/router/routes/modules/vben.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { RouteRecordRaw } from 'vue-router';
22

3-
import { VBEN_GITHUB_URL, VBEN_LOGO } from '@vben/constants';
3+
import { VBEN_GITHUB_URL, VBEN_LOGO_URL } from '@vben/constants';
44

55
import { BasicLayout, IFrameView } from '#/layouts';
66
import { $t } from '#/locales';
@@ -10,7 +10,7 @@ const routes: RouteRecordRaw[] = [
1010
component: BasicLayout,
1111
meta: {
1212
badgeType: 'dot',
13-
icon: VBEN_LOGO,
13+
icon: VBEN_LOGO_URL,
1414
order: 9999,
1515
title: 'Vben Admin',
1616
},
@@ -21,7 +21,7 @@ const routes: RouteRecordRaw[] = [
2121
{
2222
name: 'VbenAbout',
2323
path: 'about',
24-
component: () => import('#/views/_essential/vben/about/index.vue'),
24+
component: () => import('#/views/_core/vben/about/index.vue'),
2525
meta: {
2626
badgeType: 'dot',
2727
icon: 'mdi:creative-commons',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# \_essential
1+
# \_core
22

33
此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。

0 commit comments

Comments
 (0)