refactor: 重构卫星选择器为独立组件,优化代码结构和性能
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { computed, reactive } from 'vue';
|
||||
import { computed, reactive, watch } from 'vue';
|
||||
|
||||
const layoutConfig = reactive({
|
||||
darkTheme: false,
|
||||
@ -8,17 +8,31 @@ const layoutConfig = reactive({
|
||||
surface: null,
|
||||
});
|
||||
|
||||
// 从 localStorage 读取初始状态,如果没有则使用默认值 false
|
||||
const getStoredMenuState = (): boolean => {
|
||||
const stored = localStorage.getItem('staticMenuDesktopInactive');
|
||||
return stored ? JSON.parse(stored) : false;
|
||||
};
|
||||
|
||||
const layoutState = reactive({
|
||||
activeMenuItem: null,
|
||||
configSidebarVisible: false,
|
||||
menuHoverActive: false,
|
||||
overlayMenuActive: false,
|
||||
profileSidebarVisible: false,
|
||||
staticMenuDesktopInactive: false,
|
||||
staticMenuDesktopInactive: getStoredMenuState(),
|
||||
staticMenuMobileActive: false,
|
||||
});
|
||||
|
||||
export function useLayout() {
|
||||
// 监听 staticMenuDesktopInactive 的变化并保存到 localStorage
|
||||
watch(
|
||||
() => layoutState.staticMenuDesktopInactive,
|
||||
(newValue) => {
|
||||
localStorage.setItem('staticMenuDesktopInactive', JSON.stringify(newValue));
|
||||
},
|
||||
);
|
||||
|
||||
const setActiveMenuItem = (item: Record<string, never>) => {
|
||||
layoutState.activeMenuItem = item.value || item;
|
||||
};
|
||||
|
Reference in New Issue
Block a user