refactor(layout): 优化页面布局显示逻辑
- 在 App.vue 中使用 route.meta.withoutLayout 替代原有的 route.path 和 route.name判断逻辑 - 在 router/index.ts 和 materialCenter.ts 中为需要独立布局的路由添加 withoutLayout: true 标记 - 更新 router/typeings.d.ts,添加 withoutLayout属性定义
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<ConfigProvider :locale="zhCN" :theme="redTheme">
|
||||
<router-view v-if="$route.path === '/login' || ['ExploreList', 'ExploreDetail', 'Trial'].includes($route.name)" />
|
||||
<router-view v-if="$route.meta.withoutLayout" />
|
||||
<LayoutBasic v-else />
|
||||
</ConfigProvider>
|
||||
</template>
|
||||
|
||||
@ -22,6 +22,7 @@ export const router = createRouter({
|
||||
meta: {
|
||||
requiresAuth: false,
|
||||
requireLogin: false,
|
||||
withoutLayout: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -50,6 +51,7 @@ export const router = createRouter({
|
||||
meta: {
|
||||
requiresAuth: false,
|
||||
requireLogin: true,
|
||||
withoutLayout: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@ -120,6 +120,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
||||
requireLogin: false,
|
||||
hideFooter: true,
|
||||
hideSidebar: true,
|
||||
withoutLayout: true,
|
||||
roles: ['*'],
|
||||
},
|
||||
component: () => import('@/views/material-center/components/finished-products/explore/list/index.vue'),
|
||||
@ -133,6 +134,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
||||
requireLogin: false,
|
||||
hideFooter: true,
|
||||
hideSidebar: true,
|
||||
withoutLayout: true,
|
||||
roles: ['*'],
|
||||
},
|
||||
component: () => import('@/views/material-center/components/finished-products/explore/detail/index.vue'),
|
||||
|
||||
1
src/router/typeings.d.ts
vendored
1
src/router/typeings.d.ts
vendored
@ -19,5 +19,6 @@ declare module 'vue-router' {
|
||||
requireLogin?: boolean; // 是否需要登陆才能访问
|
||||
independent?: boolean; // 独立于layout的路由
|
||||
group?: string; // 路由分组
|
||||
withoutLayout?: boolean; // 不使用layout,默认false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user