From 0344f46c9377acfb52c28cf373a5416845d1aa1b Mon Sep 17 00:00:00 2001 From: Soybean <2570172956@qq.com> Date: Fri, 19 Nov 2021 21:39:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(components):=20=E4=BF=AE=E5=A4=8DBaseLayout?= =?UTF-8?q?=E7=9A=84HorizontalLayout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/HorizontalLayout/index.vue | 14 +++++++------- src/main.ts | 4 ++-- src/router/modules/dashboard.ts | 4 ++-- src/router/permission/index.ts | 8 +++++--- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/layouts/BaseLayout/components/HorizontalLayout/index.vue b/src/layouts/BaseLayout/components/HorizontalLayout/index.vue index 9ef461a9..1e15efc4 100644 --- a/src/layouts/BaseLayout/components/HorizontalLayout/index.vue +++ b/src/layouts/BaseLayout/components/HorizontalLayout/index.vue @@ -1,18 +1,18 @@ diff --git a/src/main.ts b/src/main.ts index 1ba9a0a4..eb651fb0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,13 +20,13 @@ async function setupApp() { setupStore(app); // 优先挂载一下 appProvider 解决路由守卫,Axios中可使用,LoadingBar,Dialog,Message 等之类组件 - appProvider.mount('#appProvider', true); + appProvider.mount('#appProvider'); // 挂载路由 await setupRouter(app); // 路由准备就绪后挂载APP实例 - app.mount('#app', true); + app.mount('#app'); } setupPlugins(); diff --git a/src/router/modules/dashboard.ts b/src/router/modules/dashboard.ts index 6993572b..07cbfe6d 100644 --- a/src/router/modules/dashboard.ts +++ b/src/router/modules/dashboard.ts @@ -1,5 +1,5 @@ import type { CustomRoute } from '@/interface'; -import { BasicLayout } from '@/layouts'; +import { BaseLayout } from '@/layouts'; import { setRouterCacheName } from '@/utils'; import DashboardWorkbench from '@/views/dashboard/workbench/index.vue'; import { ROUTE_HOME } from '../routes'; @@ -10,7 +10,7 @@ setRouterCacheName(DashboardWorkbench, routeName('dashboard_workbench')); const DASHBOARD: CustomRoute = { name: routeName('dashboard'), path: routePath('dashboard'), - component: BasicLayout, + component: BaseLayout, redirect: { name: routeName('dashboard_analysis') }, meta: { title: routeTitle('dashboard_analysis'), diff --git a/src/router/permission/index.ts b/src/router/permission/index.ts index 22840009..f16cce6c 100644 --- a/src/router/permission/index.ts +++ b/src/router/permission/index.ts @@ -22,12 +22,14 @@ export default function createRouterGuide(router: Router) { }); } +type RouterAction = [boolean, () => void]; + function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) { const token = getToken(); const isLogin = Boolean(token); const needLogin = Boolean(to.meta?.requiresAuth); - const routerAction: [boolean, () => void][] = [ + const routerAction: RouterAction[] = [ // 已登录状态跳转登录页,跳转至首页 [ isLogin && to.name === routeName('login'), @@ -60,9 +62,9 @@ function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNorm ]; routerAction.some(item => { - const flag = item[0]; + const [flag, callback] = item; if (flag) { - item[1](); + callback(); } return flag; });