feat 搭建架构骨架

This commit is contained in:
Ironsp
2026-09-24 09:09:47 +08:00
parent dd9f6b77a4
commit 7a2efa3fea
180 changed files with 18967 additions and 9 deletions

34
src/utils/storage.ts Normal file
View File

@@ -0,0 +1,34 @@
// localStorage/sessionStorage 泛型封装(无 Vue 依赖)
const PREFIX = 'cz:'
function parse<T>(raw: string | null): T | null {
if (raw === null) return null
try {
return JSON.parse(raw) as T
}
catch {
return null
}
}
export const storage = {
get<T>(key: string): T | null {
return parse<T>(localStorage.getItem(PREFIX + key))
},
set<T>(key: string, value: T): void {
localStorage.setItem(PREFIX + key, JSON.stringify(value))
},
remove(key: string): void {
localStorage.removeItem(PREFIX + key)
},
sessionGet<T>(key: string): T | null {
return parse<T>(sessionStorage.getItem(PREFIX + key))
},
sessionSet<T>(key: string, value: T): void {
sessionStorage.setItem(PREFIX + key, JSON.stringify(value))
},
sessionRemove(key: string): void {
sessionStorage.removeItem(PREFIX + key)
},
}