@10yun/cv-mobile-ui 0.5.60 → 0.5.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugins/storage.js +2 -2
- package/libs/storage2.js +0 -165
- /package/{js-sdk → libs}/QS-SharePoster/QRCodeAlg.js +0 -0
- /package/{js-sdk → libs}/QS-SharePoster/QS-SharePoster.js +0 -0
- /package/{js-sdk → libs}/QS-SharePoster/QS-SharePoster2.js +0 -0
- /package/{js-sdk → libs}/QS-SharePoster/app.js +0 -0
- /package/{js-sdk → libs}/QS-SharePoster/app2.js +0 -0
- /package/{js-sdk → libs}/QS-SharePoster/image-tools.js +0 -0
- /package/{js-sdk → libs}/QS-SharePoster/package.json +0 -0
- /package/{js-sdk → libs}/Sansnn-uQRCode/uqrcode.js +0 -0
- /package/{js-sdk → libs}/clipboard.min.js +0 -0
- /package/{js-sdk → libs}/gprint/encoding-indexes.js +0 -0
- /package/{js-sdk → libs}/gprint/encoding.js +0 -0
- /package/{js-sdk → libs}/gprint/esc.js +0 -0
- /package/{js-sdk → libs}/gprint/tsc.js +0 -0
- /package/{js-sdk → libs}/ican-H5Api/ican-H5Api.js +0 -0
- /package/libs/{amap-wx.130.js → maps/amap-wx.130.js} +0 -0
- /package/libs/{amap-wx.js → maps/amap-wx.js} +0 -0
- /package/libs/{amqp-wx.js → maps/amqp-wx.js} +0 -0
- /package/libs/{qqmap-wx-jssdk.js → maps/qqmap-wx-jssdk.js} +0 -0
- /package/libs/{qqmap.js → maps/qqmap.js} +0 -0
package/package.json
CHANGED
package/plugins/storage.js
CHANGED
|
@@ -11,7 +11,7 @@ class StorageClass {
|
|
|
11
11
|
constructor(options = {}) {
|
|
12
12
|
this.config = Object.assign(
|
|
13
13
|
{
|
|
14
|
-
cache_keys: '
|
|
14
|
+
cache_keys: '___keys',
|
|
15
15
|
expiration: 7 * 86400, // 60 * 60 * 24 * 7,// 默认7天
|
|
16
16
|
prefix: '',
|
|
17
17
|
suffix: ''
|
|
@@ -19,7 +19,7 @@ class StorageClass {
|
|
|
19
19
|
options
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
this.KEYS_CACHE_FLAG = this.__getFullKeyName(this.config.cache_keys)
|
|
22
|
+
this.KEYS_CACHE_FLAG = this.__getFullKeyName(this.config.cache_keys);
|
|
23
23
|
|
|
24
24
|
// 内存缓存层
|
|
25
25
|
this.cacheMap = new Map();
|
package/libs/storage2.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import CryptoJS from 'crypto-js';
|
|
2
|
-
// 十六位十六进制数作为密钥
|
|
3
|
-
const SECRET_KEY = CryptoJS.enc.Utf8.parse('3333e6e143439161');
|
|
4
|
-
// 十六位十六进制数作为密钥偏移量
|
|
5
|
-
const SECRET_IV = CryptoJS.enc.Utf8.parse('e3bbe7e3ba84431a');
|
|
6
|
-
|
|
7
|
-
const config = {
|
|
8
|
-
type: 'localStorage', // 本地存储类型localStorage、 sessionStorage
|
|
9
|
-
prefix: 'SDF_0.0.1', // 名称前缀 建议:项目名 + 项目版本
|
|
10
|
-
expire: 1, //过期时间 单位:秒
|
|
11
|
-
isEncrypt: true // 默认加密 为了调试方便, 开发过程中可以不加密
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// 判断是否支持 Storage
|
|
15
|
-
export const isSupportStorage = () => {
|
|
16
|
-
return typeof Storage !== 'undefined' ? true : false;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// 设置 setStorage
|
|
20
|
-
export const setStorage = (key, value, expire = 0) => {
|
|
21
|
-
if (value === '' || value === null || value === undefined) {
|
|
22
|
-
value = null;
|
|
23
|
-
}
|
|
24
|
-
if (isNaN(expire) || expire < 0) throw new Error('Expire must be a number');
|
|
25
|
-
expire = (expire ? expire : config.expire) * 1000;
|
|
26
|
-
let data = {
|
|
27
|
-
value: value, // 存储值
|
|
28
|
-
time: Date.now(), //存值时间戳
|
|
29
|
-
expire: expire // 过期时间
|
|
30
|
-
};
|
|
31
|
-
const encryptString = config.isEncrypt ? encrypt(JSON.stringify(data)) : JSON.stringify(data);
|
|
32
|
-
window[config.type].setItem(autoAddPrefix(key), encryptString);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// 获取 getStorage
|
|
36
|
-
export const getStorage = (key) => {
|
|
37
|
-
key = autoAddPrefix(key);
|
|
38
|
-
// key 不存在判断
|
|
39
|
-
if (!window[config.type].getItem(key) || JSON.stringify(window[config.type].getItem(key)) === 'null') {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
// 优化 持续使用中续期
|
|
43
|
-
const storage = config.isEncrypt
|
|
44
|
-
? JSON.parse(decrypt(window[config.type].getItem(key)))
|
|
45
|
-
: JSON.parse(window[config.type].getItem(key));
|
|
46
|
-
|
|
47
|
-
let nowTime = Date.now();
|
|
48
|
-
|
|
49
|
-
// 过期删除
|
|
50
|
-
if (storage.expire && config.expire * 6000 < nowTime - storage.time) {
|
|
51
|
-
removeStorage(key);
|
|
52
|
-
return null;
|
|
53
|
-
} else {
|
|
54
|
-
// 未过期期间被调用 则自动续期 进行保活
|
|
55
|
-
setStorage(autoRemovePrefix(key), storage.value);
|
|
56
|
-
return storage.value;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// 是否存在 hasStorage
|
|
61
|
-
export const hasStorage = (key) => {
|
|
62
|
-
key = autoAddPrefix(key);
|
|
63
|
-
let arr = getStorageAll().filter((item) => {
|
|
64
|
-
return item.key === key;
|
|
65
|
-
});
|
|
66
|
-
return arr.length ? true : false;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// 获取所有key
|
|
70
|
-
export const getStorageKeys = () => {
|
|
71
|
-
let items = getStorageAll();
|
|
72
|
-
let keys = [];
|
|
73
|
-
for (let index = 0; index < items.length; index++) {
|
|
74
|
-
keys.push(items[index].key);
|
|
75
|
-
}
|
|
76
|
-
return keys;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// 根据索引获取key
|
|
80
|
-
export const getStorageForIndex = (index) => {
|
|
81
|
-
return window[config.type].key(index);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// 获取localStorage长度
|
|
85
|
-
export const getStorageLength = () => {
|
|
86
|
-
return window[config.type].length;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// 获取全部 getAllStorage
|
|
90
|
-
export const getStorageAll = () => {
|
|
91
|
-
let len = window[config.type].length; // 获取长度
|
|
92
|
-
let arr = new Array(); // 定义数据集
|
|
93
|
-
for (let i = 0; i < len; i++) {
|
|
94
|
-
// 获取key 索引从0开始
|
|
95
|
-
let getKey = window[config.type].key(i);
|
|
96
|
-
// 获取key对应的值
|
|
97
|
-
let getVal = window[config.type].getItem(getKey);
|
|
98
|
-
// 放进数组
|
|
99
|
-
arr[i] = { key: getKey, val: getVal };
|
|
100
|
-
}
|
|
101
|
-
return arr;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// 删除 removeStorage
|
|
105
|
-
export const removeStorage = (key) => {
|
|
106
|
-
window[config.type].removeItem(autoAddPrefix(key));
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// 清空 clearStorage
|
|
110
|
-
export const clearStorage = () => {
|
|
111
|
-
window[config.type].clear();
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// 名称前自动添加前缀
|
|
115
|
-
const autoAddPrefix = (key) => {
|
|
116
|
-
const prefix = config.prefix ? config.prefix + '_' : '';
|
|
117
|
-
return prefix + key;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// 移除已添加的前缀
|
|
121
|
-
const autoRemovePrefix = (key) => {
|
|
122
|
-
const len = config.prefix ? config.prefix.length + 1 : '';
|
|
123
|
-
return key.substr(len);
|
|
124
|
-
// const prefix = config.prefix ? config.prefix + '_' : '';
|
|
125
|
-
// return prefix + key;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* 加密方法
|
|
130
|
-
* @param data
|
|
131
|
-
* @returns {string}
|
|
132
|
-
*/
|
|
133
|
-
const encrypt = (data) => {
|
|
134
|
-
if (typeof data === 'object') {
|
|
135
|
-
try {
|
|
136
|
-
data = JSON.stringify(data);
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.log('encrypt error:', error);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const dataHex = CryptoJS.enc.Utf8.parse(data);
|
|
142
|
-
const encrypted = CryptoJS.AES.encrypt(dataHex, SECRET_KEY, {
|
|
143
|
-
iv: SECRET_IV,
|
|
144
|
-
mode: CryptoJS.mode.CBC,
|
|
145
|
-
padding: CryptoJS.pad.Pkcs7
|
|
146
|
-
});
|
|
147
|
-
return encrypted.ciphertext.toString();
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* 解密方法
|
|
152
|
-
* @param data
|
|
153
|
-
* @returns {string}
|
|
154
|
-
*/
|
|
155
|
-
const decrypt = (data) => {
|
|
156
|
-
const encryptedHexStr = CryptoJS.enc.Hex.parse(data);
|
|
157
|
-
const str = CryptoJS.enc.Base64.stringify(encryptedHexStr);
|
|
158
|
-
const decrypt = CryptoJS.AES.decrypt(str, SECRET_KEY, {
|
|
159
|
-
iv: SECRET_IV,
|
|
160
|
-
mode: CryptoJS.mode.CBC,
|
|
161
|
-
padding: CryptoJS.pad.Pkcs7
|
|
162
|
-
});
|
|
163
|
-
const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
|
|
164
|
-
return decryptedStr.toString();
|
|
165
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|