mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
21 lines
452 B
TypeScript
21 lines
452 B
TypeScript
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;
|
|
}
|
|
|
|
export function removeSession(key: string) {
|
|
window.sessionStorage.removeItem(key);
|
|
}
|
|
|
|
export function clearSession() {
|
|
window.sessionStorage.clear();
|
|
}
|