feat: 记住左侧栏宽度,下次打开还原

This commit is contained in:
Frankie Huang 2025-05-07 00:47:20 +08:00
parent 9a2685c0ed
commit e3e7efedcf

View File

@ -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';