mirror of
https://gitee.com/bootx/dax-pay-ui.git
synced 2025-09-26 05:38:15 +00:00
fix: ensure that storage is deleted correctly close #292
This commit is contained in:
@@ -103,10 +103,10 @@
|
|||||||
"vite-plugin-imagemin": "^0.2.8",
|
"vite-plugin-imagemin": "^0.2.8",
|
||||||
"vite-plugin-mock": "^2.1.5",
|
"vite-plugin-mock": "^2.1.5",
|
||||||
"vite-plugin-purge-icons": "^0.7.0",
|
"vite-plugin-purge-icons": "^0.7.0",
|
||||||
"vite-plugin-pwa": "^0.5.4",
|
"vite-plugin-pwa": "^0.5.5",
|
||||||
"vite-plugin-style-import": "^0.7.5",
|
"vite-plugin-style-import": "^0.7.5",
|
||||||
"vite-plugin-theme": "^0.4.8",
|
"vite-plugin-theme": "^0.4.8",
|
||||||
"vite-plugin-windicss": "0.5.0",
|
"vite-plugin-windicss": "0.5.3",
|
||||||
"vue-eslint-parser": "^7.5.0",
|
"vue-eslint-parser": "^7.5.0",
|
||||||
"yargs": "^16.2.0"
|
"yargs": "^16.2.0"
|
||||||
},
|
},
|
||||||
|
20
src/utils/cache/storageCache.ts
vendored
20
src/utils/cache/storageCache.ts
vendored
@@ -4,6 +4,8 @@ import type { EncryptionParams } from '/@/utils/cipher';
|
|||||||
|
|
||||||
import { AesEncryption } from '/@/utils/cipher';
|
import { AesEncryption } from '/@/utils/cipher';
|
||||||
|
|
||||||
|
import { isNullOrUnDef } from '/@/utils/is';
|
||||||
|
|
||||||
export interface CreateStorageParams extends EncryptionParams {
|
export interface CreateStorageParams extends EncryptionParams {
|
||||||
prefixKey: string;
|
prefixKey: string;
|
||||||
storage: Storage;
|
storage: Storage;
|
||||||
@@ -61,7 +63,8 @@ export const createStorage = ({
|
|||||||
set(key: string, value: any, expire: number | null = timeout) {
|
set(key: string, value: any, expire: number | null = timeout) {
|
||||||
const stringData = JSON.stringify({
|
const stringData = JSON.stringify({
|
||||||
value,
|
value,
|
||||||
expire: expire !== null ? new Date().getTime() + expire * 1000 : null,
|
time: Date.now(),
|
||||||
|
expire: !isNullOrUnDef(expire) ? new Date().getTime() + expire * 1000 : null,
|
||||||
});
|
});
|
||||||
const stringifyValue = this.hasEncrypt
|
const stringifyValue = this.hasEncrypt
|
||||||
? this.encryption.encryptByAES(stringData)
|
? this.encryption.encryptByAES(stringData)
|
||||||
@@ -75,22 +78,21 @@ export const createStorage = ({
|
|||||||
* @memberof Cache
|
* @memberof Cache
|
||||||
*/
|
*/
|
||||||
get(key: string, def: any = null): any {
|
get(key: string, def: any = null): any {
|
||||||
const item = this.storage.getItem(this.getKey(key));
|
const val = this.storage.getItem(this.getKey(key));
|
||||||
if (item) {
|
if (!val) return def;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const decItem = this.hasEncrypt ? this.encryption.decryptByAES(item) : item;
|
const decVal = this.hasEncrypt ? this.encryption.decryptByAES(val) : val;
|
||||||
const data = JSON.parse(decItem);
|
const data = JSON.parse(decVal);
|
||||||
const { value, expire } = data;
|
const { value, expire } = data;
|
||||||
if (expire === null || expire >= new Date().getTime()) {
|
if (isNullOrUnDef(expire) || expire >= new Date().getTime()) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
this.remove(this.getKey(key));
|
this.remove(key);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete cache based on key
|
* Delete cache based on key
|
||||||
|
33
yarn.lock
33
yarn.lock
@@ -1718,12 +1718,12 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
vue-demi latest
|
vue-demi latest
|
||||||
|
|
||||||
"@windicss/plugin-utils@0.5.0":
|
"@windicss/plugin-utils@0.5.3":
|
||||||
version "0.5.0"
|
version "0.5.3"
|
||||||
resolved "https://registry.npmjs.org/@windicss/plugin-utils/-/plugin-utils-0.5.0.tgz#dab121dd33074eccb4b7c85e7757eb5704f1c76e"
|
resolved "https://registry.npmjs.org/@windicss/plugin-utils/-/plugin-utils-0.5.3.tgz#5302864cb2f94dd3d71bb5af958dab6ce3f74dab"
|
||||||
integrity sha512-d2oi4cY+PV0mcQ2wij1nI+Ku0s6Zw2/+zllxX8TtMyEknYqe5zHE69DbUyCjIyVg2DYCje2vIc8XnTWYDFEkjQ==
|
integrity sha512-BXNvMSRmi1TyM8j3EnF/li9HViJPN4EPeGKTiIDWemxrfkRNlgN+Gmv31CFtZwnjiAlXRO58B6LIqVTSVYaTfQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
esbuild "^0.8.50"
|
esbuild "^0.8.52"
|
||||||
esbuild-register "^2.0.0"
|
esbuild-register "^2.0.0"
|
||||||
fast-glob "^3.2.5"
|
fast-glob "^3.2.5"
|
||||||
micromatch "^4.0.2"
|
micromatch "^4.0.2"
|
||||||
@@ -3616,6 +3616,11 @@ esbuild@^0.8.50:
|
|||||||
resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.50.tgz#ebf24fde0cdad1a369789dd6fd7a820b0a01e46c"
|
resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.50.tgz#ebf24fde0cdad1a369789dd6fd7a820b0a01e46c"
|
||||||
integrity sha512-oidFLXssA7IccYzkqLVZSqNJDwDq8Mh/vqvrW+3fPWM7iUiC5O2bCllhnO8+K9LlyL/2Z6n+WwRJAz9fqSIVRg==
|
integrity sha512-oidFLXssA7IccYzkqLVZSqNJDwDq8Mh/vqvrW+3fPWM7iUiC5O2bCllhnO8+K9LlyL/2Z6n+WwRJAz9fqSIVRg==
|
||||||
|
|
||||||
|
esbuild@^0.8.52:
|
||||||
|
version "0.8.52"
|
||||||
|
resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.52.tgz#6dabf11c517af449a96d66da20dfc204ee7b5294"
|
||||||
|
integrity sha512-b5KzFweLLXoXQwdC/e2+Z80c8uo2M5MgP7yQEEebkFw6In4T9CvYcNoM2ElvJt8ByO04zAZUV0fZkXmXoi2s9A==
|
||||||
|
|
||||||
escalade@^3.1.1:
|
escalade@^3.1.1:
|
||||||
version "3.1.1"
|
version "3.1.1"
|
||||||
resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
|
resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
|
||||||
@@ -8935,10 +8940,10 @@ vite-plugin-purge-icons@^0.7.0:
|
|||||||
"@purge-icons/generated" "^0.7.0"
|
"@purge-icons/generated" "^0.7.0"
|
||||||
rollup-plugin-purge-icons "^0.7.0"
|
rollup-plugin-purge-icons "^0.7.0"
|
||||||
|
|
||||||
vite-plugin-pwa@^0.5.4:
|
vite-plugin-pwa@^0.5.5:
|
||||||
version "0.5.4"
|
version "0.5.5"
|
||||||
resolved "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.5.4.tgz#ce6fb85da140359057290e5eba3c22548392bea5"
|
resolved "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.5.5.tgz#f6bcaf6f6f1af0882fff7a9334aec685b798cceb"
|
||||||
integrity sha512-Zcr190GixdvvHBS1poTevtuw0irRvRi9rLFdXUbkPyY5hozQ+JhR8i/ORRvl6a9wV6Gl/mVwJ3IaY5IjTf3zFw==
|
integrity sha512-gwPg+pDm87iMOLORz/fOZiNNWNXhHFrMPW34XpX3F9JLl6ytcNZ6cJMYJ1FRKQPtVADqkbZjk3g3AOi1oI6HKQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
debug "^4.3.2"
|
debug "^4.3.2"
|
||||||
fast-glob "^3.2.5"
|
fast-glob "^3.2.5"
|
||||||
@@ -8968,12 +8973,12 @@ vite-plugin-theme@^0.4.8:
|
|||||||
es-module-lexer "^0.3.26"
|
es-module-lexer "^0.3.26"
|
||||||
tinycolor2 "^1.4.2"
|
tinycolor2 "^1.4.2"
|
||||||
|
|
||||||
vite-plugin-windicss@0.5.0:
|
vite-plugin-windicss@0.5.3:
|
||||||
version "0.5.0"
|
version "0.5.3"
|
||||||
resolved "https://registry.npmjs.org/vite-plugin-windicss/-/vite-plugin-windicss-0.5.0.tgz#63189c772feab50b3860ddec4c8a0ac69555f9d2"
|
resolved "https://registry.npmjs.org/vite-plugin-windicss/-/vite-plugin-windicss-0.5.3.tgz#7929b5fbaed7f0530cbe79947e7bc9e4f471b683"
|
||||||
integrity sha512-8mT03wppL3/ehyNEIJHVpMlWsS8jlSBaW/zSUuGjFiUC0zhB0GSzTbQkvtpJLqlFvvU4oHF4uhvN9tb7Uoq1ww==
|
integrity sha512-hVfj0QjgxBch4j5M6BfMj9Dsm7iKioP9uQUvs00RGkuUdG+Gc0PQcT9SuLrcZJjUE/2Tp9+J44BEbOYxjesqlA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@windicss/plugin-utils" "0.5.0"
|
"@windicss/plugin-utils" "0.5.3"
|
||||||
windicss "^2.2.0"
|
windicss "^2.2.0"
|
||||||
|
|
||||||
vite@2.0.3:
|
vite@2.0.3:
|
||||||
|
Reference in New Issue
Block a user