xctc-utils 1.3.7 → 1.3.9
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/README.md +12 -2
- package/app.ts +2 -2
- package/dist/weixin/index.d.ts +1 -0
- package/dist/weixin/index.js +11 -2
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -25,6 +25,15 @@ isAll:boolean 为true时删除调用方法的所有缓存,否则只删除当
|
|
|
25
25
|
删除临时缓存: utils.removeSessionStorage(key,isAll)
|
|
26
26
|
删除永久缓存: utils.removeLocalStorage(key,isAll)
|
|
27
27
|
|
|
28
|
+
```
|
|
29
|
+
#### AES 加密、解密,同一个数据的加密和解密传入的key 和 iv保持一致。
|
|
30
|
+
```
|
|
31
|
+
work: 需要加密的对象,如传入的是对象,该方法默认进行JSON序列化处理。
|
|
32
|
+
key:16位或者32位字符串作为密钥
|
|
33
|
+
iv:16位或者32位字符串作为密钥偏移量
|
|
34
|
+
data: encrypt方法加密后返回的数据
|
|
35
|
+
加密:utils.encrypt( work:any , key:string , iv:string )
|
|
36
|
+
解密:utils.decrypt( data:string , key:string , iv:string )
|
|
28
37
|
```
|
|
29
38
|
#### 类型判断
|
|
30
39
|
```
|
|
@@ -53,13 +62,14 @@ utils.type.isWindow(val) // 是否在浏览器环境下运行
|
|
|
53
62
|
word: 需要加密的数据,数据可是字符串,对象等
|
|
54
63
|
key: 加密 密钥
|
|
55
64
|
iv: 密钥偏移量
|
|
65
|
+
data:encrypt方法加密后返回的数据
|
|
56
66
|
对同一个数据进行加密、解密时,encrypt和decrypt的iv和key保持一致
|
|
57
67
|
对word进行CryptoJS.enc.Utf8.parse转义
|
|
58
68
|
CryptoJS.AES.encrypt加密,加密模式:CBC ; padding: CryptoJS.pad.Pkcs7
|
|
59
69
|
对数据进行加密
|
|
60
|
-
utils.encrypt(word:any,key:
|
|
70
|
+
utils.encrypt(word:any,key:string,iv:string)
|
|
61
71
|
// 对数据进行解密
|
|
62
|
-
utils.decrypt(
|
|
72
|
+
utils.decrypt(data:string,key:string,iv:string)
|
|
63
73
|
|
|
64
74
|
```
|
|
65
75
|
#### 微信H5使用方法集合
|
package/app.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import {formatTimeStamp,formatStrTime} from "./src/time"
|
|
9
9
|
import {weixinUrlCode} from "./src/weixin"
|
|
10
10
|
import {decrypt,encrypt} from "./src/crypto"
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
|
|
13
13
|
const congif = {
|
|
14
14
|
path:"/setting/setting-config/setting-config-index",
|
|
15
15
|
id:12,
|
package/dist/weixin/index.d.ts
CHANGED
package/dist/weixin/index.js
CHANGED
|
@@ -214,6 +214,10 @@ var defaultJsApiList = [
|
|
|
214
214
|
"onVoiceRecordEnd", "playVoice", "pauseVoice", "stopVoice", "onVoicePlayEnd", "uploadVoice", "downloadVoice", "chooseImage", "previewImage", "uploadImage", "openProductSpecificView", "addCard",
|
|
215
215
|
"downloadImage", "translateVoice", "getNetworkType", "openLocation", "getLocation", "hideOptionMenu", "showOptionMenu", "hideMenuItems", "showMenuItems", "hideAllNonBaseMenuItem", "showAllNonBaseMenuItem",
|
|
216
216
|
];
|
|
217
|
+
var defaultOpenTagList = [
|
|
218
|
+
"wx-open-subscribe", "wx-open-launch-app", "wx-open-launch-weapp",
|
|
219
|
+
"wx-open-audio"
|
|
220
|
+
];
|
|
217
221
|
function weixinShareConfig(config) {
|
|
218
222
|
if (!config['http'])
|
|
219
223
|
return;
|
|
@@ -223,9 +227,13 @@ function weixinShareConfig(config) {
|
|
|
223
227
|
appId: config.appId,
|
|
224
228
|
};
|
|
225
229
|
var jsApiList = defaultJsApiList;
|
|
226
|
-
|
|
230
|
+
var openTagList = defaultOpenTagList;
|
|
231
|
+
if (config && config['jsApiList'] && config.jsApiList.length) {
|
|
227
232
|
jsApiList = config.jsApiList;
|
|
228
233
|
}
|
|
234
|
+
if (config && config['openTagList'] && config.openTagList.length) {
|
|
235
|
+
openTagList = config.openTagList;
|
|
236
|
+
}
|
|
229
237
|
config.http(param).then(function (res) {
|
|
230
238
|
if (res.code == 0) {
|
|
231
239
|
var data = res['data'] || {};
|
|
@@ -236,7 +244,8 @@ function weixinShareConfig(config) {
|
|
|
236
244
|
timestamp: data.timestamp,
|
|
237
245
|
nonceStr: data.noncestr,
|
|
238
246
|
signature: data.signature,
|
|
239
|
-
jsApiList: jsApiList
|
|
247
|
+
jsApiList: jsApiList,
|
|
248
|
+
openTagList: openTagList,
|
|
240
249
|
});
|
|
241
250
|
wx.ready(function (res) {
|
|
242
251
|
console.log("加载微信分享配置完成:", res);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xctc-utils",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "localStorage存储\r ```\r sessionStorage存储\r ```\r crypto-js加密、解密\r ```\r 微信授权登录、微信分享\r ```\r 设备环境获取\r ```\r 是否是微信浏览器\r ```\r 时间戳转时间,字符串转时间戳",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/crypto-js": "^4.1.1",
|
|
16
16
|
"@types/node": "^18.11.19",
|
|
17
|
-
"ts-node": "^10.9.1",
|
|
18
17
|
"typescript": "^4.9.5"
|
|
19
18
|
},
|
|
20
19
|
"dependencies": {
|