fix(components): 修复BaseLayout的HorizontalLayout

This commit is contained in:
Soybean 2021-11-19 21:39:29 +08:00
parent e70a328284
commit 0344f46c93
4 changed files with 16 additions and 14 deletions

View File

@ -1,18 +1,18 @@
<template> <template>
<n-layout class="h-full"> <n-layout class="h-full" :native-scrollbar="false">
<n-layout-header :inverted="headerInverted" :position="headerPosition" class="z-11">
<global-header :show-logo="true" :show-menu-collape="false" :show-menu="true" class="relative z-2" />
<global-tab v-if="theme.multiTabStyle.visible" />
</n-layout-header>
<header-placeholder />
<n-layout-content <n-layout-content
:native-scrollbar="false" :native-scrollbar="false"
:content-style="{ height: routeProps.fullPage ? '100%' : 'auto' }" :content-style="{ height: routeProps.fullPage ? '100%' : 'auto' }"
class="bg-[#f6f9f8] dark:bg-deep-dark" class="bg-[#f6f9f8] dark:bg-deep-dark"
> >
<n-layout-header :inverted="headerInverted" :position="headerPosition" class="z-11">
<global-header :show-logo="true" :show-menu-collape="false" :show-menu="true" class="relative z-2" />
<global-tab v-if="theme.multiTabStyle.visible" />
</n-layout-header>
<header-placeholder />
<global-content /> <global-content />
<global-footer />
</n-layout-content> </n-layout-content>
<global-footer />
</n-layout> </n-layout>
</template> </template>

View File

@ -20,13 +20,13 @@ async function setupApp() {
setupStore(app); setupStore(app);
// 优先挂载一下 appProvider 解决路由守卫Axios中可使用LoadingBarDialogMessage 等之类组件 // 优先挂载一下 appProvider 解决路由守卫Axios中可使用LoadingBarDialogMessage 等之类组件
appProvider.mount('#appProvider', true); appProvider.mount('#appProvider');
// 挂载路由 // 挂载路由
await setupRouter(app); await setupRouter(app);
// 路由准备就绪后挂载APP实例 // 路由准备就绪后挂载APP实例
app.mount('#app', true); app.mount('#app');
} }
setupPlugins(); setupPlugins();

View File

@ -1,5 +1,5 @@
import type { CustomRoute } from '@/interface'; import type { CustomRoute } from '@/interface';
import { BasicLayout } from '@/layouts'; import { BaseLayout } from '@/layouts';
import { setRouterCacheName } from '@/utils'; import { setRouterCacheName } from '@/utils';
import DashboardWorkbench from '@/views/dashboard/workbench/index.vue'; import DashboardWorkbench from '@/views/dashboard/workbench/index.vue';
import { ROUTE_HOME } from '../routes'; import { ROUTE_HOME } from '../routes';
@ -10,7 +10,7 @@ setRouterCacheName(DashboardWorkbench, routeName('dashboard_workbench'));
const DASHBOARD: CustomRoute = { const DASHBOARD: CustomRoute = {
name: routeName('dashboard'), name: routeName('dashboard'),
path: routePath('dashboard'), path: routePath('dashboard'),
component: BasicLayout, component: BaseLayout,
redirect: { name: routeName('dashboard_analysis') }, redirect: { name: routeName('dashboard_analysis') },
meta: { meta: {
title: routeTitle('dashboard_analysis'), title: routeTitle('dashboard_analysis'),

View File

@ -22,12 +22,14 @@ export default function createRouterGuide(router: Router) {
}); });
} }
type RouterAction = [boolean, () => void];
function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) { function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) {
const token = getToken(); const token = getToken();
const isLogin = Boolean(token); const isLogin = Boolean(token);
const needLogin = Boolean(to.meta?.requiresAuth); const needLogin = Boolean(to.meta?.requiresAuth);
const routerAction: [boolean, () => void][] = [ const routerAction: RouterAction[] = [
// 已登录状态跳转登录页,跳转至首页 // 已登录状态跳转登录页,跳转至首页
[ [
isLogin && to.name === routeName('login'), isLogin && to.name === routeName('login'),
@ -60,9 +62,9 @@ function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNorm
]; ];
routerAction.some(item => { routerAction.some(item => {
const flag = item[0]; const [flag, callback] = item;
if (flag) { if (flag) {
item[1](); callback();
} }
return flag; return flag;
}); });