Browse Source

style: format code

nian 2 months ago
parent
commit
a5338dc39a

+ 2 - 2
src/layout/header/Actions/component/ConfigureDrawer.vue

@@ -156,11 +156,11 @@ const showNoiseModal = () => {
             <div class="flex items-center justify-between">
               <span>显示顶部加载条</span>
               <NSwitch
-                :value="configure.showRouteLoadingBar"
+                :value="configure.showTopLoadingBar"
                 @update-value="
                   (value) =>
                     modify({
-                      showRouteLoadingBar: value,
+                      showTopLoadingBar: value,
                     })
                 "
               />

+ 5 - 5
src/layout/main/index.vue

@@ -24,7 +24,7 @@ const configureStore = useConfigureStore()
 
 const { tabs, tabActiveKey, tabsKeepAlive } = storeToRefs(tabsStore)
 
-const { configure, isRouterLoading } = storeToRefs(configureStore)
+const { configure, isNavigating } = storeToRefs(configureStore)
 
 const { create, setActive } = tabsStore
 
@@ -43,7 +43,7 @@ function createTab(route: RouteLocationNormalizedLoaded) {
   create({
     compName,
     icon,
-    name: name as string,
+    name,
     key: fullPath,
     label,
     pinned,
@@ -95,14 +95,14 @@ watch(
 watch(
   (): [RouteLocationNormalizedLoaded, boolean] => [
     router.currentRoute.value,
-    isRouterLoading.value,
+    isNavigating.value,
   ],
-  ([newRoute, isRouterLoading], [oldRoute]) => {
+  ([newRoute, isNavigating], [oldRoute]) => {
     const { name, meta } = newRoute
     const { showTab, multiTab } = meta
     const findTab = tabs.value.find((item) => item.name === name)
 
-    if (!isRouterLoading && newRoute.fullPath !== oldRoute?.fullPath) {
+    if (!isNavigating && newRoute.fullPath !== oldRoute?.fullPath) {
       if (showTab && (!findTab || multiTab)) {
         createTab(newRoute)
       } else if (!isEmpty(findTab)) {

+ 4 - 4
src/router/guard.ts

@@ -14,9 +14,9 @@ const configureStore = useConfigureStore(createPinia())
 
 export function setupRouterGuard(router: Router) {
   router.beforeEach(async (to, from, next) => {
-    configureStore.setRouterLoading(true)
+    configureStore.setNavigating(true)
 
-    if (configureStore.configure.showRouteLoadingBar) {
+    if (configureStore.configure.showTopLoadingBar) {
       loadingBar.start()
     }
 
@@ -65,9 +65,9 @@ export function setupRouterGuard(router: Router) {
   })
 
   router.afterEach(() => {
-    configureStore.setRouterLoading(false)
+    configureStore.setNavigating(false)
 
-    if (configureStore.configure.showRouteLoadingBar) {
+    if (configureStore.configure.showTopLoadingBar) {
       loadingBar.finish()
     }
   })

+ 7 - 7
src/stores/configure.ts

@@ -15,7 +15,7 @@ export interface ConfigureOptions {
   showBreadcrumb: boolean
   showWatermark: boolean
   showNoise: boolean
-  showRouteLoadingBar: boolean
+  showTopLoadingBar: boolean
   enableRouteTransition: boolean
   enableTextSelect: boolean
   watermarkOptions: Partial<WatermarkProps>
@@ -32,7 +32,7 @@ const DEFAULT_CONFIGURE_OPTIONS: ConfigureOptions = {
   showWatermark: false,
   showNavigation: true,
   showBreadcrumb: true,
-  showRouteLoadingBar: true,
+  showTopLoadingBar: true,
   enableRouteTransition: true,
   enableTextSelect: true,
   watermarkOptions: {
@@ -63,7 +63,7 @@ const DEFAULT_CONFIGURE_OPTIONS: ConfigureOptions = {
 export const useConfigureStore = defineStore('configureStore', () => {
   const configure = useStorage<ConfigureOptions>('configure', DEFAULT_CONFIGURE_OPTIONS)
 
-  const isRouterLoading = ref(false)
+  const isNavigating = ref(false)
 
   const modify = (options: Partial<ConfigureOptions>) => {
     configure.value = mergeWith({}, configure.value, options, (objValue, srcValue) => {
@@ -77,8 +77,8 @@ export const useConfigureStore = defineStore('configureStore', () => {
     configure.value = structuredClone(DEFAULT_CONFIGURE_OPTIONS)
   }
 
-  const setRouterLoading = (value: boolean) => {
-    isRouterLoading.value = value
+  const setNavigating = (value: boolean) => {
+    isNavigating.value = value
   }
 
   watch(
@@ -93,10 +93,10 @@ export const useConfigureStore = defineStore('configureStore', () => {
 
   return {
     configure,
-    isRouterLoading,
+    isNavigating,
     reset,
     modify,
-    setRouterLoading,
+    setNavigating,
   }
 })
 

+ 3 - 1
src/stores/tabs.ts

@@ -1,9 +1,11 @@
 import { useStorage } from '@vueuse/core'
 import { acceptHMRUpdate, defineStore } from 'pinia'
 
+import type { RouteRecordNameGeneric } from 'vue-router'
+
 export interface Tab {
   compName?: string
-  name?: string
+  name?: RouteRecordNameGeneric
   icon?: string
   key: string
   label?: string