同步操作将从 众邦科技/CRMEB_Java电商系统 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import { EXPIRE } from '../config/app';class Cache {constructor(handler) {this.cacheSetHandler = uni.setStorageSync;this.cacheGetHandler = uni.getStorageSync;this.cacheClearHandler = uni.removeStorageSync;this.cacheExpire = '_expire_2019_12_17_18_44';}/*** 获取当前时间戳*/time(){return Math.round(new Date() / 1000);}/*** 设置过期时间缓存* @param {Object} key* @param {Object} expire*/setExpireCahe(key,expire){expire = expire !== undefined ? expire : EXPIRE;if (expire) {this.cacheSetHandler(key + this.cacheExpire,this.time() + expire)}}/*** 缓存是否过期,过期自动删除* @param {Object} key* @param {Object} $bool true = 删除,false = 不删除*/getExpireCahe(key,$bool){try{let time = this.cacheGetHandler(key + this.cacheExpire);if (time) {let newTime = parseInt(time);if (time && time < this.time() && !Number.isNaN(newTime)) {if ($bool === undefined || $bool === true) {this.cacheClearHandler(key);this.cacheClearHandler(key + this.cacheExpire);}return false;} elsereturn true;} else {return !!this.cacheGetHandler(key);}}catch(e){return false;}}/*** 设置缓存* @param {Object} key* @param {Object} data*/set(key,data,expire){if(typeof data === 'object')data = JSON.stringify(data);try{this.setExpireCahe(key,expire);return this.cacheSetHandler(key,data);}catch(e){return false;}}/*** 检测缓存是否存在* @param {Object} key*/has(key){return this.getExpireCahe(key);}/*** 获取缓存* @param {Object} key* @param {Object} $default* @param {Object} expire*/get(key,$default,expire){try{let isBe = this.getExpireCahe(key);let data = this.cacheGetHandler(key);if (data && isBe) {if (typeof $default === 'boolean')return JSON.parse(data);elsereturn data;} else {if (typeof $default === 'function') {let value = $default();this.set(key,value,expire);return value;} else {this.set(key,$default,expire);return $default;}}}catch(e){return null;}}/*** 删除缓存* @param {Object} key*/clear(key){try{let cahceValue = this.cacheGetHandler(key + this.cacheExpire);if(cahceValue)this.cacheClearHandler(key + this.cacheExpire);return this.cacheClearHandler(key);}catch(e){return false;}}/*** 清除过期缓存*/clearOverdue(){// let cacheList = uni.getStorageInfoSync(),that = this;// if (typeof cacheList.keys === 'object'){// cacheList.keys.forEach(item=>{// that.getExpireCahe(item);// })// }}}export default new Cache;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。