mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-11-12 03:33:41 +08:00
refactor(projects): all file and folder use kebab-case
This commit is contained in:
@@ -1,31 +1,5 @@
|
||||
import { decrypto, encrypto } from '../crypto';
|
||||
|
||||
export function setSession(key: string, value: unknown) {
|
||||
const json = encrypto(value);
|
||||
sessionStorage.setItem(key, json);
|
||||
}
|
||||
|
||||
export function getSession<T>(key: string) {
|
||||
const json = sessionStorage.getItem(key);
|
||||
let data: T | null = null;
|
||||
if (json) {
|
||||
try {
|
||||
data = decrypto(json);
|
||||
} catch {
|
||||
// 防止解析失败
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
export function removeSession(key: string) {
|
||||
window.sessionStorage.removeItem(key);
|
||||
}
|
||||
|
||||
export function clearSession() {
|
||||
window.sessionStorage.clear();
|
||||
}
|
||||
|
||||
function createSessionStorage<T extends StorageInterface.Session = StorageInterface.Session>() {
|
||||
function set<K extends keyof T>(key: K, value: T[K]) {
|
||||
const json = encrypto(value);
|
||||
|
||||
Reference in New Issue
Block a user