project-general-tools
Version:
项目开发通用工具类封装
65 lines (64 loc) • 2.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/*
* @Author: Mad Dragon 395548460@qq.com
* @Date: 2020年3月21日
* @explanatory: sessionStorage 存储
*/
exports.default = {
// 保存数据到sessionStorage
setItem(key, content) {
if (!key && typeof window === 'undefined')
return;
sessionStorage.setItem(key, JSON.stringify(content));
},
// 从sessionStorage获取数据
getItem(key) {
if (!key && typeof window === 'undefined')
return;
return JSON.parse(sessionStorage.getItem(key) || '');
},
// 从sessionStorage删除保存的数据
removeItem(key) {
if (!key && typeof window === 'undefined')
return;
sessionStorage.removeItem(key);
},
// 从sessionStorage删除所有保存的数据
clear() {
sessionStorage.clear();
}
};
/**
* _ooOoo_
* o8888888o
* 88" . "88
* (| -_- |)
* O\ = /O
* ____/`---'\____
* .' \\| |// `.
* / \\||| : |||// \
* / _||||| -:- |||||- \
* | | \\\ - /// | |
* | \_| ''\---/'' | |
* \ .-\__ `-` ___/-. /
* ___`. .' /--.--\ `. . __
* ."" '< `.___\_<|>_/___.' >'"".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `-. \_ __\ /__ _/ .-` / /
* ======`-.____`-.___\_____/___.-`____.-'======
* `=---='
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 佛祖保佑 永无BUG
* 佛曰:
* 写字楼里写字间,写字间里程序员;
* 程序人员写程序,又拿程序换酒钱。
* 酒醒只在网上坐,酒醉还来网下眠;
* 酒醉酒醒日复日,网上网下年复年。
* 但愿老死电脑间,不愿鞠躬老板前;
* 奔驰宝马贵者趣,公交自行程序员。
* 别人笑我忒疯癫,我笑自己命太贱;
* 不见满街漂亮妹,哪个归得程序员?
*
* Mad Dragon 395548460@qq.com
*/