mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-19 01:56:38 +08:00
13 lines
286 B
TypeScript
13 lines
286 B
TypeScript
export function setLocal(key: string, value: unknown) {
|
|
const json = JSON.stringify(value);
|
|
localStorage.setItem(key, json);
|
|
}
|
|
|
|
export function getLocal<T>(key: string) {
|
|
const json = localStorage.getItem(key);
|
|
if (json) {
|
|
return JSON.parse(json) as T;
|
|
}
|
|
return json;
|
|
}
|