UNPKG

t-comm

Version:

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

54 lines (49 loc) 1.87 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib_es6 = require('../tslib.es6-01322ba9.js'); var pixui_gamelet = require('./gamelet.js'); var pixui_validator = require('./validator.js'); /** * 读取本地数据,IDE中不生效,在真机上才生效 * 数据以 app + roleId 为维度隔离存储,。存储的信息如15天不更新,会自动清除。 * @param key 键 */ var getLocalStorageInPixui = function getLocalStorageInPixui(key) { return tslib_es6.__awaiter(this, void 0, void 0, function () { return tslib_es6.__generator(this, function (_a) { switch (_a.label) { case 0: if (pixui_validator.isBrowserInPixui()) { return [2 /*return*/, localStorage.getItem(key) || '']; } return [4 /*yield*/, pixui_gamelet.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 tslib_es6.__awaiter(this, void 0, void 0, function () { return tslib_es6.__generator(this, function (_a) { switch (_a.label) { case 0: if (pixui_validator.isBrowserInPixui()) { return [2 /*return*/, localStorage.setItem(key, value)]; } return [4 /*yield*/, pixui_gamelet.getGameletPixuiFrame().GameletAPI.writeRoleCookie(key, value)]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }; exports.getLocalStorageInPixui = getLocalStorageInPixui; exports.setLocalStorageInPixui = setLocalStorageInPixui;