Skip to content

Commit 1ad5456

Browse files
authored
feat: add noBasicLayout in route meta (#5386)
所有菜单数据无需配置component为BasicLayout,它们将会默认使用基础布局,也可以通过meta.noBasicLayout来阻止这一行为
1 parent 42e3220 commit 1ad5456

File tree

22 files changed

+128
-84
lines changed

22 files changed

+128
-84
lines changed

apps/backend-mock/utils/mock-data.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export const MOCK_CODES = [
5353

5454
const dashboardMenus = [
5555
{
56-
component: 'BasicLayout',
5756
meta: {
5857
order: -1,
5958
title: 'page.dashboard.title',
@@ -116,7 +115,6 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
116115

117116
return [
118117
{
119-
component: 'BasicLayout',
120118
meta: {
121119
icon: 'ic:baseline-view-in-ar',
122120
keepAlive: true,

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

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

33
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
44

5-
import { AuthPageLayout } from '#/layouts';
5+
import { AuthPageLayout, BasicLayout } from '#/layouts';
66
import { $t } from '#/locales';
77
import Login from '#/views/_core/authentication/login.vue';
88

@@ -21,13 +21,23 @@ const fallbackNotFoundRoute: RouteRecordRaw = {
2121

2222
/** 基本路由,这些路由是必须存在的 */
2323
const coreRoutes: RouteRecordRaw[] = [
24+
/**
25+
* 根路由
26+
* 使用基础布局,作为所有页面的父级容器,子级就不必配置BasicLayout。
27+
* 此路由必须存在,且不应修改
28+
*/
2429
{
30+
component: BasicLayout,
2531
meta: {
32+
hideInBreadcrumb: true,
33+
hideInMenu: true,
34+
hideInTab: true,
2635
title: 'Root',
2736
},
2837
name: 'Root',
2938
path: '/',
3039
redirect: DEFAULT_HOME_PATH,
40+
children: [],
3141
},
3242
{
3343
component: AuthPageLayout,

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

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

3-
import { BasicLayout } from '#/layouts';
43
import { $t } from '#/locales';
54

65
const routes: RouteRecordRaw[] = [
76
{
8-
component: BasicLayout,
97
meta: {
108
icon: 'lucide:layout-dashboard',
119
order: -1,

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

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

3-
import { BasicLayout } from '#/layouts';
43
import { $t } from '#/locales';
54

65
const routes: RouteRecordRaw[] = [
76
{
8-
component: BasicLayout,
97
meta: {
108
icon: 'ic:baseline-view-in-ar',
119
keepAlive: true,

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,20 @@ import {
88
VBEN_NAIVE_PREVIEW_URL,
99
} from '@vben/constants';
1010

11-
import { BasicLayout, IFrameView } from '#/layouts';
11+
import { IFrameView } from '#/layouts';
1212
import { $t } from '#/locales';
1313

1414
const routes: RouteRecordRaw[] = [
1515
{
16-
component: BasicLayout,
1716
meta: {
1817
badgeType: 'dot',
1918
icon: VBEN_LOGO_URL,
20-
order: 9999,
19+
order: 9998,
2120
title: $t('demos.vben.title'),
2221
},
2322
name: 'VbenProject',
2423
path: '/vben-admin',
2524
children: [
26-
{
27-
name: 'VbenAbout',
28-
path: '/vben-admin/about',
29-
component: () => import('#/views/_core/about/index.vue'),
30-
meta: {
31-
icon: 'lucide:copyright',
32-
title: $t('demos.vben.about'),
33-
},
34-
},
3525
{
3626
name: 'VbenDocument',
3727
path: '/vben-admin/document',
@@ -76,6 +66,16 @@ const routes: RouteRecordRaw[] = [
7666
},
7767
],
7868
},
69+
{
70+
name: 'VbenAbout',
71+
path: '/vben-admin/about',
72+
component: () => import('#/views/_core/about/index.vue'),
73+
meta: {
74+
icon: 'lucide:copyright',
75+
title: $t('demos.vben.about'),
76+
order: 9999,
77+
},
78+
},
7979
];
8080

8181
export default routes;

apps/web-ele/src/router/routes/core.ts

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

33
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
44

5-
import { AuthPageLayout } from '#/layouts';
5+
import { AuthPageLayout, BasicLayout } from '#/layouts';
66
import { $t } from '#/locales';
77
import Login from '#/views/_core/authentication/login.vue';
88

@@ -21,13 +21,23 @@ const fallbackNotFoundRoute: RouteRecordRaw = {
2121

2222
/** 基本路由,这些路由是必须存在的 */
2323
const coreRoutes: RouteRecordRaw[] = [
24+
/**
25+
* 根路由
26+
* 使用基础布局,作为所有页面的父级容器,子级就不必配置BasicLayout。
27+
* 此路由必须存在,且不应修改
28+
*/
2429
{
30+
component: BasicLayout,
2531
meta: {
32+
hideInBreadcrumb: true,
33+
hideInMenu: true,
34+
hideInTab: true,
2635
title: 'Root',
2736
},
2837
name: 'Root',
2938
path: '/',
3039
redirect: DEFAULT_HOME_PATH,
40+
children: [],
3141
},
3242
{
3343
component: AuthPageLayout,

apps/web-ele/src/router/routes/modules/dashboard.ts

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

3-
import { BasicLayout } from '#/layouts';
43
import { $t } from '#/locales';
54

65
const routes: RouteRecordRaw[] = [
76
{
8-
component: BasicLayout,
97
meta: {
108
icon: 'lucide:layout-dashboard',
119
order: -1,

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

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

3-
import { BasicLayout } from '#/layouts';
43
import { $t } from '#/locales';
54

65
const routes: RouteRecordRaw[] = [
76
{
8-
component: BasicLayout,
97
meta: {
108
icon: 'ic:baseline-view-in-ar',
119
keepAlive: true,

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,20 @@ import {
99
} from '@vben/constants';
1010
import { SvgAntdvLogoIcon } from '@vben/icons';
1111

12-
import { BasicLayout, IFrameView } from '#/layouts';
12+
import { IFrameView } from '#/layouts';
1313
import { $t } from '#/locales';
1414

1515
const routes: RouteRecordRaw[] = [
1616
{
17-
component: BasicLayout,
1817
meta: {
1918
badgeType: 'dot',
2019
icon: VBEN_LOGO_URL,
21-
order: 9999,
20+
order: 9998,
2221
title: $t('demos.vben.title'),
2322
},
2423
name: 'VbenProject',
2524
path: '/vben-admin',
2625
children: [
27-
{
28-
name: 'VbenAbout',
29-
path: '/vben-admin/about',
30-
component: () => import('#/views/_core/about/index.vue'),
31-
meta: {
32-
icon: 'lucide:copyright',
33-
title: $t('demos.vben.about'),
34-
},
35-
},
3626
{
3727
name: 'VbenDocument',
3828
path: '/vben-admin/document',
@@ -77,6 +67,16 @@ const routes: RouteRecordRaw[] = [
7767
},
7868
],
7969
},
70+
{
71+
name: 'VbenAbout',
72+
path: '/vben-admin/about',
73+
component: () => import('#/views/_core/about/index.vue'),
74+
meta: {
75+
icon: 'lucide:copyright',
76+
title: $t('demos.vben.about'),
77+
order: 9999,
78+
},
79+
},
8080
];
8181

8282
export default routes;

apps/web-naive/src/router/routes/core.ts

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

33
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
44

5-
import { AuthPageLayout } from '#/layouts';
5+
import { AuthPageLayout, BasicLayout } from '#/layouts';
66
import { $t } from '#/locales';
77
import Login from '#/views/_core/authentication/login.vue';
88

@@ -21,13 +21,23 @@ const fallbackNotFoundRoute: RouteRecordRaw = {
2121

2222
/** 基本路由,这些路由是必须存在的 */
2323
const coreRoutes: RouteRecordRaw[] = [
24+
/**
25+
* 根路由
26+
* 使用基础布局,作为所有页面的父级容器,子级就不必配置BasicLayout。
27+
* 此路由必须存在,且不应修改
28+
*/
2429
{
30+
component: BasicLayout,
2531
meta: {
32+
hideInBreadcrumb: true,
33+
hideInMenu: true,
34+
hideInTab: true,
2635
title: 'Root',
2736
},
2837
name: 'Root',
2938
path: '/',
3039
redirect: DEFAULT_HOME_PATH,
40+
children: [],
3141
},
3242
{
3343
component: AuthPageLayout,

0 commit comments

Comments
 (0)