家谱现有接口调试50%
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
(function (root, factory) {
|
||||
// 存储工具同时支持浏览器页面和 Node 测试。
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
module.exports = factory();
|
||||
return;
|
||||
}
|
||||
|
||||
root.StorageUtil = factory();
|
||||
})(typeof globalThis !== 'undefined' ? globalThis : window, function () {
|
||||
'use strict';
|
||||
|
||||
function read(storage, key) {
|
||||
try {
|
||||
return storage && storage.getItem(key);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function write(storage, key, value) {
|
||||
try {
|
||||
if (storage) storage.setItem(key, value);
|
||||
} catch (error) {
|
||||
// localStorage 可能因为隐私模式或配额限制失败,调用方无需因此中断页面。
|
||||
}
|
||||
}
|
||||
|
||||
function remove(storage, key) {
|
||||
try {
|
||||
if (storage) storage.removeItem(key);
|
||||
} catch (error) {
|
||||
// 删除失败时保持静默,避免影响退出登录等后续流程。
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
read: read,
|
||||
write: write,
|
||||
remove: remove
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user