From 10dfffbd828fd779cbfd7be59c034b0757f93d98 Mon Sep 17 00:00:00 2001 From: Gaoxs Date: Tue, 19 Jul 2022 23:21:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dh5=E7=99=BB=E9=99=86=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 7 +++---- utils/store/cookie.js | 26 +++++++++++--------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/main.js b/main.js index 8abffd1..c5fe14b 100644 --- a/main.js +++ b/main.js @@ -14,7 +14,7 @@ Vue.component('cu-custom', cuCustom) Vue.config.productionTip = false Vue.config.devtools = process.env.NODE_ENV !== 'production' -Vue.prototype.$validator = function(rule) { +Vue.prototype.$validator = function (rule) { return new schema(rule) } @@ -67,11 +67,10 @@ deviceType = 'routine' import { wechat, clearAuthStatus, oAuth, auth, toAuth, pay, openAddress, openShareAll, openShareAppMessage, openShareTimeline, wechatEvevt, ready, wxShowLocation } from '@/libs/wechat' import { isWeixin } from '@/utils' -const CACHE_KEY = 'clear_0.0.1' -if (!cookie.has(CACHE_KEY)) { +if (!cookie.has(cookie.CACHE_KEY)) { cookie.clearAll() - cookie.set(CACHE_KEY, 1) + cookie.set(cookie.CACHE_KEY, 1) } var urlSpread = parseQuery()['spread'] diff --git a/utils/store/cookie.js b/utils/store/cookie.js index e51b15f..510287d 100644 --- a/utils/store/cookie.js +++ b/utils/store/cookie.js @@ -1,12 +1,10 @@ -import { trim, isType } from "@/utils"; +import { trim, isType } from '@/utils' -const doc = null; +const doc = null +const CACHE_KEY = 'clear_0.0.1' // const doc = window.document; function get(key) { - if (!key || !_has(key)) { - return ''; - } return uni.getStorageSync(key) } @@ -16,29 +14,26 @@ function all() { function set(key, data, time) { if (!key) { - return; + return } uni.setStorageSync(key, data) } function remove(key) { if (!key || !_has(key)) { - return; + return } uni.removeStorageSync(key) } function clearAll() { - const res = uni.getStorageInfoSync(); - res.keys.map((item) => { - if (item == 'redirect' || item == 'spread') { + const res = uni.getStorageInfoSync() + res.keys.map(item => { + if (item == 'redirect' || item == 'spread' || item == CACHE_KEY) { return } remove(item) }) - console.log(res) - // debugger - // uni.clearStorageSync() } function _has(key) { @@ -58,5 +53,6 @@ export default { set, remove, clearAll, - has: _has -}; + has: _has, + CACHE_KEY, +}