perf:发布版本1.0.2

This commit is contained in:
曾文豪
2023-03-06 16:05:24 +08:00
parent 917db45f33
commit 271f873902
7 changed files with 248 additions and 5 deletions

42
src/utils/Storage.js Normal file
View File

@@ -0,0 +1,42 @@
import Common from "./Common";
///////////////////////////////////////// 用户token
/**
* 保存用户token
* @param token
*/
const saveUserToken = (token) => {
save('token', token);
};
const getUserToken = () => {
return get('token') || '';
};
/**
* 保存数据
* @param key
* @param value
*/
const save = (key, value) => {
localStorage.setItem(key, JSON.stringify({data: value}));
};
/**
* 获取数据
* @param key
* @returns {string}
*/
const get = (key) => {
return Common.parseJSON(localStorage.getItem(key), {data: ""}).data;
};
///////////////////////////////////////// 导出模块
export default {
save,
get,
saveUserToken,
getUserToken,
};