feat: 记住左侧栏宽度,下次打开还原
This commit is contained in:
parent
9a2685c0ed
commit
e3e7efedcf
@ -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';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user