xctc-utils 1.6.6 → 1.6.7

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 CHANGED
@@ -175,7 +175,7 @@ useUtils.date.formatStrTime(str) // 返回时间戳 秒
175
175
  #### 计算当前富文本内容高度
176
176
  ```
177
177
  var option = {
178
- id:"ueditor" , // 富文本DOM容器 id
178
+ id:"ueditor" , // 富文本DOM容器 id 默认不传
179
179
  content:"" , // ueditor 富文本内容
180
180
  }
181
181
  // 返回的富文本内容包含input dom元素,input元素的content-data-height属性计算富文本高度
@@ -8,6 +8,8 @@ interface configOption {
8
8
  cryptokey?: string;
9
9
  isPassLogin?: boolean;
10
10
  redirectUri?: string;
11
+ appIdKey?: string;
12
+ jsCodeKey?: string;
11
13
  }
12
14
  export declare function getUrlCode(config: configOption): void;
13
15
  export declare function envSDK(): any;
@@ -19,6 +21,8 @@ interface ShareConfig {
19
21
  jsApiList?: string[];
20
22
  openTagList?: string[];
21
23
  url?: string;
24
+ urlKey?: string;
25
+ appIdKey?: string;
22
26
  }
23
27
  export declare function configReady(config: ShareConfig): void;
24
28
  interface ShareOptions {
@@ -103,7 +103,8 @@ function cryptoConfig(key, iv) {
103
103
  }
104
104
  // 执行微信登录
105
105
  function login(code) {
106
- var appId = weixinConfig.appId, http = weixinConfig.http, stateKey = weixinConfig.stateKey, redirectUri = weixinConfig.redirectUri;
106
+ var _a;
107
+ var appId = weixinConfig.appId, http = weixinConfig.http, redirectUri = weixinConfig.redirectUri, _b = weixinConfig.appIdKey, appIdKey = _b === void 0 ? "app_id" : _b, _c = weixinConfig.jsCodeKey, jsCodeKey = _c === void 0 ? "js_code" : _c;
107
108
  if (!appId) {
108
109
  console.error("未正常传入微信公众号appId");
109
110
  return;
@@ -112,10 +113,10 @@ function login(code) {
112
113
  console.error("未获取到微信授权的code参数");
113
114
  return;
114
115
  }
115
- var obj = {
116
- "app_id": appId,
117
- "js_code": code
118
- };
116
+ var obj = (_a = {},
117
+ _a[appIdKey] = appId,
118
+ _a[jsCodeKey] = code,
119
+ _a);
119
120
  if (!http) {
120
121
  console.error("未正常传入微信授权登录http函数");
121
122
  return;
@@ -275,23 +276,25 @@ var defaultOpenTagList = [
275
276
  "wx-open-audio"
276
277
  ];
277
278
  function configReady(config) {
278
- if (!config['http'])
279
+ var _a;
280
+ var _b = config || {}, appId = _b.appId, url = _b.url, _c = _b.urlKey, urlKey = _c === void 0 ? "url" : _c, _d = _b.appIdKey, appIdKey = _d === void 0 ? "appId" : _d, cb = _b.cb, _e = _b.jsApiList, jsApiList = _e === void 0 ? [] : _e, _f = _b.openTagList, openTagList = _f === void 0 ? [] : _f, _g = _b.http, http = _g === void 0 ? "" : _g;
281
+ if (!http)
279
282
  return;
280
- var url = loc.origin;
281
- if (config['url']) {
282
- url = config['url'];
283
+ var currentUrl = loc.origin;
284
+ if (url) {
285
+ currentUrl = url;
283
286
  }
284
- var param = {
285
- url: url,
286
- appId: config.appId,
287
- };
288
- var jsApiList = defaultJsApiList;
289
- var openTagList = defaultOpenTagList;
290
- if (config && config['jsApiList'] && config.jsApiList.length) {
291
- jsApiList = config.jsApiList;
287
+ var param = (_a = {},
288
+ _a[urlKey] = currentUrl,
289
+ _a[appIdKey] = appId,
290
+ _a);
291
+ var jsApiListData = defaultJsApiList;
292
+ var openTagListData = defaultOpenTagList;
293
+ if (jsApiList === null || jsApiList === void 0 ? void 0 : jsApiList.length) {
294
+ jsApiListData = jsApiListData;
292
295
  }
293
- if (config && config['openTagList'] && config.openTagList.length) {
294
- openTagList = config.openTagList;
296
+ if (openTagList === null || openTagList === void 0 ? void 0 : openTagList.length) {
297
+ openTagListData = openTagList;
295
298
  }
296
299
  config.http(param).then(function (res) {
297
300
  if (res.code == 0) {
@@ -303,8 +306,8 @@ function configReady(config) {
303
306
  timestamp: data.timestamp,
304
307
  nonceStr: data.noncestr,
305
308
  signature: data.signature,
306
- jsApiList: jsApiList,
307
- openTagList: openTagList,
309
+ jsApiList: jsApiListData,
310
+ openTagList: openTagListData,
308
311
  });
309
312
  wx.ready(function (res) {
310
313
  console.log("加载微信分享配置完成:", res);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
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",