This commit is contained in:
zlwu committed 2025-12-26 11:34:37 +08:00
1 parent b0b3da3451
commit 2e8ece94ce
3 files changed
+23 -7

No files matched your search

+17 -1
View File
@@ -188,7 +188,23 @@ defineExpose({
});
const toggleSideBar = () => {
appStore.toggleSideBar(false);
// 点击 hamburger:
// - 移动端:关闭侧边栏(覆盖式)
// - 桌面端:如果当前是隐藏状态 -> 取消隐藏并展开;如果当前可见 -> 隐藏(完全移除)
if (appStore.device === 'mobile') {
appStore.closeSideBar({ withoutAnimation: false });
return;
}
if (appStore.sidebar.hide) {
// 当前被隐藏,显示并展开
appStore.toggleSideBarHide(false);
appStore.openSideBar();
} else {
// 当前可见,先收起(关闭),再隐藏
appStore.closeSideBar({ withoutAnimation: false });
appStore.toggleSideBarHide(true);
}
};
const logout = async () => {
+1 -3
View File
@@ -50,9 +50,7 @@ watchEffect(() => {
appStore.closeSideBar({ withoutAnimation: true });
} else {
appStore.toggleDevice('desktop');
if (!appStore.sidebar.opened) {
appStore.openSideBar();
}
// 桌面端保持用户的侧边栏状态,不自动打开
}
});
+5 -3
View File
@@ -5,11 +5,13 @@ import { useStorage } from '@vueuse/core';
import { ref, reactive, computed } from 'vue';
export const useAppStore = defineStore('app', () => {
const sidebarStatus = useStorage('sidebarStatus', '1');
// 默认隐藏侧边栏(首次打开页面时不渲染侧边栏)
const sidebarStatus = useStorage('sidebarStatus', '0');
const sidebar = reactive({
opened: sidebarStatus.value ? !!+sidebarStatus.value : true,
opened: false,
withoutAnimation: false,
hide: false
hide: true
});
const device = ref<string>('desktop');
const size = useStorage<'large' | 'default' | 'small'>('size', 'default');