UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

49 lines (46 loc) 1.68 kB
import { b as __awaiter, c as __generator } from '../tslib.es6-096fffdd.js'; import { getGameletPixuiFrame } from './gamelet.mjs'; import { isBrowserInPixui } from './validator.mjs'; /** * 读取本地数据,IDE中不生效,在真机上才生效 * 数据以 app + roleId 为维度隔离存储,。存储的信息如15天不更新,会自动清除。 * @param key 键 */ var getLocalStorageInPixui = function getLocalStorageInPixui(key) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: if (isBrowserInPixui()) { return [2 /*return*/, localStorage.getItem(key) || '']; } return [4 /*yield*/, getGameletPixuiFrame().GameletAPI.readRoleCookie(key)]; case 1: return [2 /*return*/, _a.sent()]; } }); }); }; /** * 设置本地数据,IDE中不生效,在真机上才生效 * 数据以 app + roleId 为维度隔离存储,。存储的信息如15天不更新,会自动清除。 * @param key 键 * @param value 值 */ var setLocalStorageInPixui = function setLocalStorageInPixui(key, value) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: if (isBrowserInPixui()) { return [2 /*return*/, localStorage.setItem(key, value)]; } return [4 /*yield*/, getGameletPixuiFrame().GameletAPI.writeRoleCookie(key, value)]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }; export { getLocalStorageInPixui, setLocalStorageInPixui };