diff --git a/src/App.vue b/src/App.vue index f2c9f5e..07633a7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -39,16 +39,19 @@ async function greet() { // 使用 Split 组件动态控制页面左右布局 const defaultSplit = 0.15; // 默认左侧边栏和右侧区域的比例为 1.5:8.5 -const split = ref(defaultSplit); +const initSplit = localStorage.getItem('splitValueOfFolderTree'); +const split = initSplit === null ? ref(defaultSplit) : ref(Number(initSplit)); const splitTrigger = useTemplateRef('splitTrigger'); const splitRight = useTemplateRef('splitRight'); const splitRightWidth = ref(0); const hiddenSplitLeft = ref(''); -const leftSidebarState = ref('open'); +const leftSidebarState = split.value > 0 ? ref('open') : ref('close'); watch(split, (newSplit) => { + localStorage.setItem('splitValueOfFolderTree', newSplit); splitRightWidth.value = splitRight.value.offsetWidth; // 当 split 小于某个值时,隐藏左边布局 if (newSplit < 0.05) { + split.value = 0; leftSidebarState.value = 'close'; if (hiddenSplitLeft.value == '') { hiddenSplitLeft.value = 'hidden';