feat: active

This commit is contained in:
EleanorMao
2023-04-30 23:07:43 +08:00
parent abc53d3eef
commit 1c232948ed
46 changed files with 1796 additions and 129 deletions

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

@ -0,0 +1,33 @@
const NameSpace = 'ihealth-kit-registration_';
function getData<T>(key: string, defaultValue?: T): T | null {
const rawData = window.localStorage.getItem(NameSpace + key);
try {
if (rawData) {
return JSON.parse(rawData);
} else {
return defaultValue || null
}
} catch (e) {
return defaultValue || null;
}
}
function setData<T>(key: string, data: T): void {
window.localStorage.setItem(NameSpace + key, JSON.stringify(data));
}
function clearData(key?: string): void {
if (key) {
window.localStorage.removeItem(NameSpace + key);
} else {
window.localStorage.clear()
}
}
const storage = {
get: getData,
set: setData,
clear: clearData
}
export default storage