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:
rd
2025-09-15 14:54:55 +08:00
parent e8b16e6541
commit b626f5a35b
4 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<ConfigProvider :locale="zhCN" :theme="redTheme"> <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 /> <LayoutBasic v-else />
</ConfigProvider> </ConfigProvider>
</template> </template>

View File

@ -22,6 +22,7 @@ export const router = createRouter({
meta: { meta: {
requiresAuth: false, requiresAuth: false,
requireLogin: false, requireLogin: false,
withoutLayout: true,
}, },
}, },
{ {
@ -50,6 +51,7 @@ export const router = createRouter({
meta: { meta: {
requiresAuth: false, requiresAuth: false,
requireLogin: true, requireLogin: true,
withoutLayout: true,
}, },
}, },

View File

@ -120,6 +120,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
requireLogin: false, requireLogin: false,
hideFooter: true, hideFooter: true,
hideSidebar: true, hideSidebar: true,
withoutLayout: true,
roles: ['*'], roles: ['*'],
}, },
component: () => import('@/views/material-center/components/finished-products/explore/list/index.vue'), component: () => import('@/views/material-center/components/finished-products/explore/list/index.vue'),
@ -133,6 +134,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
requireLogin: false, requireLogin: false,
hideFooter: true, hideFooter: true,
hideSidebar: true, hideSidebar: true,
withoutLayout: true,
roles: ['*'], roles: ['*'],
}, },
component: () => import('@/views/material-center/components/finished-products/explore/detail/index.vue'), component: () => import('@/views/material-center/components/finished-products/explore/detail/index.vue'),

View File

@ -19,5 +19,6 @@ declare module 'vue-router' {
requireLogin?: boolean; // 是否需要登陆才能访问 requireLogin?: boolean; // 是否需要登陆才能访问
independent?: boolean; // 独立于layout的路由 independent?: boolean; // 独立于layout的路由
group?: string; // 路由分组 group?: string; // 路由分组
withoutLayout?: boolean; // 不使用layout默认false
} }
} }