perf: 代码优化 layout/index
This commit is contained in:
parent
07bde250ff
commit
d4f6f5b717
@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from "vue"
|
import { computed } from "vue"
|
||||||
|
import { storeToRefs } from "pinia"
|
||||||
import { useAppStore } from "@/store/modules/app"
|
import { useAppStore } from "@/store/modules/app"
|
||||||
import { useSettingsStore } from "@/store/modules/settings"
|
import { useSettingsStore } from "@/store/modules/settings"
|
||||||
import { AppMain, NavigationBar, Settings, Sidebar, TagsView, RightPanel } from "./components"
|
import { AppMain, NavigationBar, Settings, Sidebar, TagsView, RightPanel } from "./components"
|
||||||
@ -9,6 +10,8 @@ import { DeviceEnum } from "@/constants/app-key"
|
|||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
|
|
||||||
|
const { showGreyMode, showColorWeakness, showSettings, showTagsView, fixedHeader } = storeToRefs(settingsStore)
|
||||||
|
|
||||||
/** Layout 布局响应式 */
|
/** Layout 布局响应式 */
|
||||||
useResize()
|
useResize()
|
||||||
|
|
||||||
@ -19,21 +22,11 @@ const layoutClasses = computed(() => {
|
|||||||
openSidebar: appStore.sidebar.opened,
|
openSidebar: appStore.sidebar.opened,
|
||||||
withoutAnimation: appStore.sidebar.withoutAnimation,
|
withoutAnimation: appStore.sidebar.withoutAnimation,
|
||||||
mobile: appStore.device === DeviceEnum.Mobile,
|
mobile: appStore.device === DeviceEnum.Mobile,
|
||||||
showGreyMode: settingsStore.showGreyMode,
|
showGreyMode: showGreyMode.value,
|
||||||
showColorWeakness: settingsStore.showColorWeakness
|
showColorWeakness: showColorWeakness.value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const showSettings = computed(() => {
|
|
||||||
return settingsStore.showSettings
|
|
||||||
})
|
|
||||||
const showTagsView = computed(() => {
|
|
||||||
return settingsStore.showTagsView
|
|
||||||
})
|
|
||||||
const fixedHeader = computed(() => {
|
|
||||||
return settingsStore.fixedHeader
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 用于处理点击 mobile 端侧边栏遮罩层的事件 */
|
/** 用于处理点击 mobile 端侧边栏遮罩层的事件 */
|
||||||
const handleClickOutside = () => {
|
const handleClickOutside = () => {
|
||||||
appStore.closeSidebar(false)
|
appStore.closeSidebar(false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user