+
@@ -19,13 +19,12 @@
diff --git a/src/layouts/index.ts b/src/layouts/index.ts
index b6ca9d17..42c5dca9 100644
--- a/src/layouts/index.ts
+++ b/src/layouts/index.ts
@@ -1,6 +1,5 @@
-import BaseLayout from './BaseLayout/index.vue';
import BasicLayout from './BasicLayout/index.vue';
import BlankLayout from './BlankLayout/index.vue';
import RouterViewLayout from './RouterViewLayout/index.vue';
-export { BaseLayout, BasicLayout, BlankLayout, RouterViewLayout };
+export { BasicLayout, BlankLayout, RouterViewLayout };
diff --git a/src/router/export/index.ts b/src/router/export/index.ts
deleted file mode 100644
index dbb33e49..00000000
--- a/src/router/export/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { getCacheRoutes, transformRouteToMenu } from '@/utils';
-import { customRoutes, routes } from '../routes';
-
-export const cacheRoutes = getCacheRoutes(routes);
-export const menus = transformRouteToMenu(customRoutes);
diff --git a/src/router/guide/index.ts b/src/router/guide/index.ts
new file mode 100644
index 00000000..6abaff0f
--- /dev/null
+++ b/src/router/guide/index.ts
@@ -0,0 +1,27 @@
+import type { Router } from 'vue-router';
+import { useTitle } from '@vueuse/core';
+import { useAppStore } from '@/store';
+import { handlePagePermission } from './permission';
+
+/**
+ * 路由守卫函数
+ * @param router - 路由实例
+ */
+export function createRouterGuide(router: Router) {
+ const { resetScrollBehavior } = useAppStore();
+
+ router.beforeEach((to, from, next) => {
+ // 开始 loadingBar
+ window.$loadingBar?.start();
+ // 页面跳转逻辑
+ handlePagePermission(to, from, next);
+ });
+ router.afterEach(to => {
+ // 设置document title
+ useTitle(to.meta.title as string);
+ // 结束 loadingBar
+ window.$loadingBar?.finish();
+ // 重置滚动条行为
+ resetScrollBehavior();
+ });
+}
diff --git a/src/router/permission/index.ts b/src/router/guide/permission.ts
similarity index 61%
rename from src/router/permission/index.ts
rename to src/router/guide/permission.ts
index f16cce6c..252de0a5 100644
--- a/src/router/permission/index.ts
+++ b/src/router/guide/permission.ts
@@ -1,30 +1,15 @@
-import type { Router, RouteLocationNormalized, NavigationGuardNext } from 'vue-router';
-import { useTitle } from '@vueuse/core';
+import type { RouteLocationNormalized, NavigationGuardNext } from 'vue-router';
import { routeName } from '@/router';
import { getToken, getLoginRedirectUrl } from '@/utils';
-/**
- * 路由守卫函数
- * @param router - 路由实例
- */
-export default function createRouterGuide(router: Router) {
- router.beforeEach((to, from, next) => {
- // 开始 loadingBar
- window.$loadingBar?.start();
- // 页面跳转逻辑
- handleRouterAction(to, from, next);
- });
- router.afterEach(to => {
- // 设置document title
- useTitle(to.meta.title as string);
- // 结束 loadingBar
- window.$loadingBar?.finish();
- });
-}
-
type RouterAction = [boolean, () => void];
-function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) {
+/** 处理页面的权限 */
+export function handlePagePermission(
+ to: RouteLocationNormalized,
+ from: RouteLocationNormalized,
+ next: NavigationGuardNext
+) {
const token = getToken();
const isLogin = Boolean(token);
const needLogin = Boolean(to.meta?.requiresAuth);
diff --git a/src/router/index.ts b/src/router/index.ts
index 226962ac..f9b8362b 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -1,4 +1,3 @@
export * from './const';
export * from './routes';
export * from './setup';
-export * from './export';
diff --git a/src/router/modules/dashboard.ts b/src/router/modules/dashboard.ts
index 6993572b..416d5512 100644
--- a/src/router/modules/dashboard.ts
+++ b/src/router/modules/dashboard.ts
@@ -13,7 +13,7 @@ const DASHBOARD: CustomRoute = {
component: BasicLayout,
redirect: { name: routeName('dashboard_analysis') },
meta: {
- title: routeTitle('dashboard_analysis'),
+ title: routeTitle('dashboard'),
icon: 'carbon:dashboard'
},
children: [
diff --git a/src/router/setup/index.ts b/src/router/setup/index.ts
index 832309ed..b17cb273 100644
--- a/src/router/setup/index.ts
+++ b/src/router/setup/index.ts
@@ -1,7 +1,8 @@
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
import type { App } from 'vue';
-import { routes } from '../routes';
-import createRouterGuide from '../permission';
+import { getCacheRoutes, transformRouteToMenu } from '@/utils';
+import { routes, customRoutes } from '../routes';
+import { createRouterGuide } from '../guide';
/** 用于部署vercel托管服务 */
const isStaging = import.meta.env.VITE_HTTP_ENV === 'STAGING';
@@ -16,3 +17,9 @@ export async function setupRouter(app: App) {
createRouterGuide(router);
await router.isReady();
}
+
+/** 缓存的路由对应vue页面的名称 */
+export const cacheRoutes = getCacheRoutes(routes);
+
+/** 菜单 */
+export const menus = transformRouteToMenu(customRoutes);
diff --git a/src/store/modules/app/index.ts b/src/store/modules/app/index.ts
index 45a484c4..8c380b25 100644
--- a/src/store/modules/app/index.ts
+++ b/src/store/modules/app/index.ts
@@ -1,11 +1,13 @@
-import { defineStore } from 'pinia';
import { nextTick } from 'vue';
import type { RouteLocationNormalizedLoaded } from 'vue-router';
+import type { ScrollbarInst } from 'naive-ui';
+import { defineStore } from 'pinia';
import { store } from '@/store';
import { router, ROUTE_HOME } from '@/router';
/** app状态 */
interface AppState {
+ layout: LayoutState;
menu: MenuState;
multiTab: MultiTab;
/** 重新加载标记 */
@@ -13,6 +15,11 @@ interface AppState {
settingDrawer: SettingDrawer;
}
+/** 布局状态 */
+interface LayoutState {
+ scrollbar: ScrollbarInst | null;
+}
+
/** 菜单状态 */
interface MenuState {
/** 菜单折叠 */
@@ -21,16 +28,15 @@ interface MenuState {
fixedMix: boolean;
}
-type MultiTabRoute = Partial & {
- path: string;
- fullPath: string;
-};
-
/** 多页签 */
interface MultiTab {
routes: MultiTabRoute[];
activeRoute: string;
}
+type MultiTabRoute = Partial & {
+ path: string;
+ fullPath: string;
+};
/** 项目配置抽屉的状态 */
interface SettingDrawer {
@@ -41,6 +47,9 @@ interface SettingDrawer {
const appStore = defineStore({
id: 'app-store',
state: (): AppState => ({
+ layout: {
+ scrollbar: null
+ },
menu: {
collapsed: false,
fixedMix: false
@@ -61,6 +70,19 @@ const appStore = defineStore({
}
},
actions: {
+ /** 设置scrollbar的实例 */
+ setScrollbarInstance(scrollbar: ScrollbarInst) {
+ this.layout.scrollbar = scrollbar;
+ },
+ /**
+ * 重置滚动条行为
+ */
+ resetScrollBehavior() {
+ const { scrollbar } = this.layout;
+ setTimeout(() => {
+ scrollbar?.scrollTo({ left: 0, top: 0 });
+ }, 250);
+ },
/** 折叠/展开菜单 */
handleMenuCollapse(collapsed: boolean) {
this.menu.collapsed = collapsed;
@@ -184,6 +206,7 @@ const appStore = defineStore({
this.reloadFlag = false;
nextTick(() => {
this.reloadFlag = true;
+ this.resetScrollBehavior();
});
},
/** 打开配置抽屉 */
diff --git a/src/views/dashboard/analysis/components/BottomPart/index.vue b/src/views/dashboard/analysis/components/BottomPart/index.vue
index a810a0c4..a62e6d3e 100644
--- a/src/views/dashboard/analysis/components/BottomPart/index.vue
+++ b/src/views/dashboard/analysis/components/BottomPart/index.vue
@@ -109,7 +109,7 @@ const tableData: TableData[] = [
name: 'Soybean',
age: 25,
address: 'China Shenzhen',
- tags: ['handsome', 'peogrammer']
+ tags: ['handsome', 'programmer']
},
{
key: 4,
diff --git a/windi.config.ts b/windi.config.ts
index 86b6ca65..b60c27af 100644
--- a/windi.config.ts
+++ b/windi.config.ts
@@ -55,7 +55,7 @@ export default defineConfig({
dark: '#18181c',
'deep-dark': '#101014'
},
- transitionProperty: ['width', 'height', 'background', 'background-color', 'border-color', 'fill']
+ transitionProperty: ['width', 'height', 'background', 'background-color', 'border-color', 'right', 'fill']
}
},
variants: {},