Initial CMPP frontend prototype

This commit is contained in:
hectorzhao
2026-06-30 16:09:46 +08:00
commit 2f3c274a30
98 changed files with 25255 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
const STORAGE_PREFIX = 'cmpp-platform-v2';
export function readLocalData<T>(key: string, fallback: T): T {
if (typeof window === 'undefined') {
return fallback;
}
const rawValue = window.localStorage.getItem(`${STORAGE_PREFIX}:${key}`);
if (!rawValue) {
return fallback;
}
try {
return JSON.parse(rawValue) as T;
} catch {
return fallback;
}
}
export function writeLocalData<T>(key: string, value: T) {
if (typeof window === 'undefined') {
return;
}
window.localStorage.setItem(`${STORAGE_PREFIX}:${key}`, JSON.stringify(value));
}
export function resetLocalData(key: string) {
if (typeof window === 'undefined') {
return;
}
window.localStorage.removeItem(`${STORAGE_PREFIX}:${key}`);
}