2025-03-20 08:46:07 +08:00
|
|
|
"use strict";
|
|
|
|
|
const common_vendor = require("../common/vendor.js");
|
|
|
|
|
const TOKEN_NAME = "fcc-token";
|
|
|
|
|
const USER_KEY = "fcc-user-key";
|
|
|
|
|
const USER_DATA = "fcc-user-data";
|
|
|
|
|
const USER_LOGIN_TIME = "fcc-login-time";
|
|
|
|
|
function setStorageFun(key, value, sync = true) {
|
|
|
|
|
try {
|
|
|
|
|
if (sync) {
|
|
|
|
|
return common_vendor.index.setStorageSync(key, value);
|
|
|
|
|
} else {
|
|
|
|
|
common_vendor.index.setStorage({
|
|
|
|
|
key,
|
|
|
|
|
data: value
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function getStorageFun(key, sync = true) {
|
|
|
|
|
try {
|
|
|
|
|
if (sync) {
|
|
|
|
|
return common_vendor.index.getStorageSync(key);
|
|
|
|
|
} else {
|
|
|
|
|
let data = "";
|
|
|
|
|
common_vendor.index.getStorage({
|
|
|
|
|
key,
|
|
|
|
|
success: function(res) {
|
|
|
|
|
data = res.data;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-07 09:54:33 +08:00
|
|
|
function clear(sync = true) {
|
|
|
|
|
try {
|
|
|
|
|
if (sync) {
|
|
|
|
|
return common_vendor.index.clearStorageSync();
|
|
|
|
|
} else {
|
|
|
|
|
common_vendor.index.clearStorage();
|
|
|
|
|
}
|
|
|
|
|
common_vendor.index.removeStorage({
|
|
|
|
|
key: "isForcedLogin"
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-20 08:46:07 +08:00
|
|
|
exports.TOKEN_NAME = TOKEN_NAME;
|
|
|
|
|
exports.USER_DATA = USER_DATA;
|
|
|
|
|
exports.USER_KEY = USER_KEY;
|
|
|
|
|
exports.USER_LOGIN_TIME = USER_LOGIN_TIME;
|
2025-05-07 09:54:33 +08:00
|
|
|
exports.clear = clear;
|
2025-03-20 08:46:07 +08:00
|
|
|
exports.getStorageFun = getStorageFun;
|
|
|
|
|
exports.setStorageFun = setStorageFun;
|
|
|
|
|
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/auth.js.map
|