mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-12-26 15:00:16 +08:00
refactor(projects): 完善路由配置
This commit is contained in:
2
src/utils/storage/index.ts
Normal file
2
src/utils/storage/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { setLocal, getLocal } from './local';
|
||||
export { setSession, getSession } from './session';
|
||||
@@ -0,0 +1,12 @@
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
export function setSession(key: string, value: unknown) {
|
||||
const json = JSON.stringify(value);
|
||||
sessionStorage.setItem(key, json);
|
||||
}
|
||||
|
||||
export function getSession<T>(key: string) {
|
||||
const json = sessionStorage.getItem(key);
|
||||
if (json) {
|
||||
return JSON.parse(json) as T;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user