refactor(frontend): 重构前端第二版

This commit is contained in:
sophie committed 2026-06-11 13:47:06 +08:00
1 parent 2631f78b00
commit 4b562cfa82
205 files changed
+15399 -12015

No files matched your search

@@ -0,0 +1,48 @@
/**
* shared/composables/useReportLayoutStorage.ts
* 报表页面布局偏好 localStorage 持久化。
*/
/**
* useReportLayoutStorage.ts
* 用途:为报表页面提供统一的布局偏好持久化能力(按用户 + 表名隔离)
*/
const getCurrentAuthUser = () => {
let stored = localStorage.getItem('hxops_user');
if (!stored) stored = sessionStorage.getItem('hxops_user');
if (!stored) return null;
try {
const data = JSON.parse(stored);
return data.user || data;
} catch {
return null;
}
};
const getCurrentIdentity = () => {
const user = getCurrentAuthUser();
return user?.id ? `id_${user.id}` : `u_${user?.username || 'guest'}`;
};
const getReportLayoutStorageKey = (table: string) => {
return `hxops_report_layout_v2_${getCurrentIdentity()}_${table}`;
};
export const loadReportLayoutPref = <T = any>(table: string): T | null => {
try {
const raw = localStorage.getItem(getReportLayoutStorageKey(table));
if (!raw) return null;
return JSON.parse(raw) as T;
} catch {
return null;
}
};
export const saveReportLayoutPref = (table: string, payload: unknown) => {
try {
localStorage.setItem(getReportLayoutStorageKey(table), JSON.stringify(payload));
} catch {
// Ignore storage write failure to avoid blocking core report flow.
}
};