diff options
| author | pany <[email protected]> | 2023-05-21 10:47:42 +0800 |
|---|---|---|
| committer | pany <[email protected]> | 2023-05-21 10:47:42 +0800 |
| commit | 002bbdec8ff37d32e760fd244f999b1cc452c388 (patch) | |
| tree | 085536ed6dd296560f5736cd50ad26062c02debe | |
| parent | e4d9673a2bd86e013fbf86b2f6f2ee1715014227 (diff) | |
perf: 代码优化 所有的 enum 类型命名
| -rw-r--r-- | src/layout/hooks/useResize.ts | 8 | ||||
| -rw-r--r-- | src/layout/index.vue | 4 | ||||
| -rw-r--r-- | src/store/modules/app.ts | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/layout/hooks/useResize.ts b/src/layout/hooks/useResize.ts index c1dc55b..1cb7611 100644 --- a/src/layout/hooks/useResize.ts +++ b/src/layout/hooks/useResize.ts @@ -1,6 +1,6 @@ import { watch, onBeforeMount, onMounted, onBeforeUnmount } from "vue" import { useRoute } from "vue-router" -import { useAppStore, DeviceType } from "@/store/modules/app" +import { useAppStore, DeviceEnum } from "@/store/modules/app" /** 参考 Bootstrap 的响应式设计 WIDTH = 992 */ const WIDTH = 992 @@ -18,7 +18,7 @@ export default () => { const _resizeHandler = () => { if (!document.hidden) { const isMobile = _isMobile() - appStore.toggleDevice(isMobile ? DeviceType.Mobile : DeviceType.Desktop) + appStore.toggleDevice(isMobile ? DeviceEnum.Mobile : DeviceEnum.Desktop) if (isMobile) { appStore.closeSidebar(true) } @@ -28,7 +28,7 @@ export default () => { watch( () => route.name, () => { - if (appStore.device === DeviceType.Mobile && appStore.sidebar.opened) { + if (appStore.device === DeviceEnum.Mobile && appStore.sidebar.opened) { appStore.closeSidebar(false) } } @@ -40,7 +40,7 @@ export default () => { onMounted(() => { if (_isMobile()) { - appStore.toggleDevice(DeviceType.Mobile) + appStore.toggleDevice(DeviceEnum.Mobile) appStore.closeSidebar(true) } }) diff --git a/src/layout/index.vue b/src/layout/index.vue index e95bcdb..605df28 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -1,6 +1,6 @@ <script lang="ts" setup> import { computed } from "vue" -import { useAppStore, DeviceType } from "@/store/modules/app" +import { useAppStore, DeviceEnum } from "@/store/modules/app" import { useSettingsStore } from "@/store/modules/settings" import { AppMain, NavigationBar, Settings, Sidebar, TagsView, RightPanel } from "./components" import useResize from "./hooks/useResize" @@ -16,7 +16,7 @@ const classObj = computed(() => { hideSidebar: !appStore.sidebar.opened, openSidebar: appStore.sidebar.opened, withoutAnimation: appStore.sidebar.withoutAnimation, - mobile: appStore.device === DeviceType.Mobile, + mobile: appStore.device === DeviceEnum.Mobile, showGreyMode: showGreyMode.value, showColorWeakness: showColorWeakness.value } diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 793e3f5..e13c73a 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -2,7 +2,7 @@ import { reactive, ref } from "vue" import { defineStore } from "pinia" import { getSidebarStatus, setSidebarStatus } from "@/utils/cache/localStorage" -export enum DeviceType { +export enum DeviceEnum { Mobile, Desktop } @@ -17,7 +17,7 @@ export const useAppStore = defineStore("app", () => { opened: getSidebarStatus() !== "closed", withoutAnimation: false }) - const device = ref<DeviceType>(DeviceType.Desktop) + const device = ref<DeviceEnum>(DeviceEnum.Desktop) const toggleSidebar = (withoutAnimation: boolean) => { sidebar.opened = !sidebar.opened @@ -33,7 +33,7 @@ export const useAppStore = defineStore("app", () => { sidebar.withoutAnimation = withoutAnimation setSidebarStatus("closed") } - const toggleDevice = (value: DeviceType) => { + const toggleDevice = (value: DeviceEnum) => { device.value = value } |
