feature: 新增书架页组件与项目页新架构(书架视图、侧边栏折叠记忆、URL 视图参数切换)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const SIDEBAR_COLLAPSED_STORAGE_KEY = 'mumu_sidebar_collapsed';
|
||||
|
||||
export const getStoredSidebarCollapsed = (): boolean => {
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return localStorage.getItem(SIDEBAR_COLLAPSED_STORAGE_KEY) === '1';
|
||||
} catch (error) {
|
||||
console.warn('读取侧边栏状态失败:', error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const setStoredSidebarCollapsed = (collapsed: boolean): void => {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
localStorage.setItem(SIDEBAR_COLLAPSED_STORAGE_KEY, collapsed ? '1' : '0');
|
||||
} catch (error) {
|
||||
console.warn('保存侧边栏状态失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
export const getSidebarCollapsedStorageKey = (): string => SIDEBAR_COLLAPSED_STORAGE_KEY;
|
||||
Reference in New Issue
Block a user