Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-20 19:09:21 +08:00

perf: 代码优化 所有的 enum 类型命名

This commit is contained in:
pany 2023-05-21 10:47:42 +08:00
parent e4d9673a2b
commit 002bbdec8f
3 changed files with 9 additions and 9 deletions

View File

@ -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)
}
})

View File

@ -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
}

View File

@ -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
}