Browse Source

refactor: rename code

nian 2 months ago
parent
commit
50a5305bf8
3 changed files with 8 additions and 12 deletions
  1. 6 9
      src/layout/main/index.vue
  2. 2 2
      src/stores/tabs.ts
  3. 0 1
      src/theme/common.ts

+ 6 - 9
src/layout/main/index.vue

@@ -26,7 +26,7 @@ const { tabs, tabActiveKey, tabsKeepAlive } = storeToRefs(tabsStore)
 
 const { configure, isNavigating } = storeToRefs(configureStore)
 
-const { create, setActive } = tabsStore
+const { createTab, setActive } = tabsStore
 
 const isMounted = ref(false)
 
@@ -35,12 +35,12 @@ let oldTabs: Tab[] = []
 
 const transitionName = ref('')
 
-function createTab(route: RouteLocationNormalizedLoaded) {
+function doCreateTab(route: RouteLocationNormalizedLoaded) {
   const { pinned, componentName, icon = 'iconify ph--browser', label = '未命名标签' } = route.meta
 
   const { fullPath, name } = route
 
-  create({
+  createTab({
     componentName,
     icon,
     name,
@@ -93,10 +93,7 @@ watch(
 )
 
 watch(
-  (): [RouteLocationNormalizedLoaded, boolean] => [
-    router.currentRoute.value,
-    isNavigating.value,
-  ],
+  (): [RouteLocationNormalizedLoaded, boolean] => [router.currentRoute.value, isNavigating.value],
   ([newRoute, isNavigating], [oldRoute]) => {
     const { name, meta } = newRoute
     const { showTab, multiTab } = meta
@@ -104,7 +101,7 @@ watch(
 
     if (!isNavigating && newRoute.fullPath !== oldRoute?.fullPath) {
       if (showTab && (!findTab || multiTab)) {
-        createTab(newRoute)
+        doCreateTab(newRoute)
       } else if (!isEmpty(findTab)) {
         setActive(findTab.key)
       } else {
@@ -123,7 +120,7 @@ onMounted(() => {
   if (name === 'layout' && tabActiveKey.value) {
     router.replace(tabActiveKey.value)
   } else if (showTab && (!findTab || multiTab)) {
-    createTab(currentRoute)
+    doCreateTab(currentRoute)
   } else if (!isEmpty(findTab)) {
     setActive(findTab.key)
   }

+ 2 - 2
src/stores/tabs.ts

@@ -122,7 +122,7 @@ export const useTabsStore = defineStore('tabsStore', () => {
     tabActiveKey.value = key
   }
 
-  function create(tab: Tab) {
+  function createTab(tab: Tab) {
     const index = tabs.value.findIndex((item) => item.key === tab.key)
 
     if (index === -1) {
@@ -187,7 +187,7 @@ export const useTabsStore = defineStore('tabsStore', () => {
     tabs,
     tabActiveKey,
     tabsKeepAlive,
-    create,
+    createTab,
     getUnlockedTabKeys,
     getUnlockedTabKeysBefore,
     getUnlockedTabKeysExcept,

+ 0 - 1
src/theme/common.ts

@@ -5,7 +5,6 @@ import twc from '@/utils/tailwindColor'
 import type { GlobalThemeOverrides } from 'naive-ui'
 
 export function cc(primaryColor: string, color1: string, color2: string) {
-  // This should be 4.5
   return chroma.contrast(primaryColor, '#fff') > 4.4 ? color1 : color2
 }