123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- "use strict";
- const common_vendor = require("../common/vendor.js");
- const config_config = require("../config/config.js");
- const framework_log = require("./log.js");
- const framework_tools = require("./tools.js");
- class util {
- /**
- * 获取本地数据
- */
- static getStorage(key) {
- let d = common_vendor.index.getStorageSync(key);
- if (util.isNull(d)) {
- return null;
- }
- return d;
- }
- /**
- * 设置本地数据
- */
- static setStorage(key, value) {
- common_vendor.index.setStorageSync(key, value);
- }
- /**
- * 清除本地key数据
- */
- static clearStorageForKey(key) {
- let d = util.getStorage(key);
- if (util.isNull(d)) {
- framework_log.log.Error(`${key} is null!`);
- } else {
- util.setStorage(key, null);
- }
- }
- /**
- * 清除本地数据
- */
- static clearAllStorage() {
- common_vendor.index.clearStorageSync();
- }
- static isNull(v) {
- if (v == null || v == void 0 || v == "") {
- return true;
- }
- return false;
- }
- static alert(v) {
- let Platform = framework_tools.tools.getCurPlatform();
- if (Platform == config_config.config.Platform.H5) {
- alert(v);
- } else if (Platform == config_config.config.Platform.TOUTIAO) {
- framework_log.log.Debug("TOUTIAO", v);
- } else if (Platform == config_config.config.Platform.WEIXIN) {
- framework_log.log.Debug("WEIXIN", v);
- }
- }
- }
- exports.util = util;
|