@tmsfe/tms-core 0.0.206 → 0.0.208
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/src/index.js +3 -0
- package/src/navbarUtils.js +17 -1
- package/src/request.js +4 -2
- package/src/utils/canvas/canvasDrawer.js +1 -3
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -56,6 +56,7 @@ import * as storage from './storage';
|
|
|
56
56
|
import * as uiUtil from './tmsuiUtils';
|
|
57
57
|
import { throttle, debounce } from './funcUtils';
|
|
58
58
|
import { formatAmount } from './priceUtils';
|
|
59
|
+
import { getSystemInfoSync } from './wxApi';
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* @public
|
|
@@ -279,6 +280,8 @@ const api = {
|
|
|
279
280
|
|
|
280
281
|
storage,
|
|
281
282
|
|
|
283
|
+
getSystemInfoSync,
|
|
284
|
+
|
|
282
285
|
...syncApi,
|
|
283
286
|
...uiUtil,
|
|
284
287
|
throttle,
|
package/src/navbarUtils.js
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
2
2
|
* @desc: 获取导航高度的相关函数
|
|
3
3
|
*/
|
|
4
4
|
import { compareVersion } from './compareVersion';
|
|
5
|
-
|
|
5
|
+
let systemInfo = null;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 获取系统信息,有缓存, 返回数据同wx.getSystemInfoSync {@link https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getSystemInfoSync.html}
|
|
9
|
+
* @returns {Object} 系统信息
|
|
10
|
+
*/
|
|
11
|
+
const getSystemInfoSync = () => {
|
|
12
|
+
if (systemInfo) return systemInfo;
|
|
13
|
+
let res;
|
|
14
|
+
try {
|
|
15
|
+
systemInfo = wx.getSystemInfoSync();
|
|
16
|
+
res = systemInfo;
|
|
17
|
+
} catch (_) {
|
|
18
|
+
res = {};
|
|
19
|
+
}
|
|
20
|
+
return res;
|
|
21
|
+
};
|
|
6
22
|
|
|
7
23
|
/**
|
|
8
24
|
* 获取系统信息,有缓存, 返回数据同wx.getSystemInfoSync {@link https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getSystemInfoSync.html}
|
package/src/request.js
CHANGED
|
@@ -416,11 +416,13 @@ export default class Request {
|
|
|
416
416
|
return await this.invokeRequest(path, param, method, header);
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
// 重试case3:处理网关框架码重试 requestRetryFlag?.
|
|
419
|
+
// 重试case3:处理网关框架码重试 requestRetryFlag?.gwCodeReTryPath由七彩石配置
|
|
420
420
|
const { requestRetryFlag } = wx.tmsFlagMap || {};
|
|
421
421
|
// X-Gateway-Code必须首字母大写,否则真机取不到
|
|
422
422
|
const gatewayCode = res?.header?.['X-Gateway-Code'];
|
|
423
|
-
|
|
423
|
+
// 判断网关框架码重试白名单
|
|
424
|
+
const isGwCodeRetryPathWhite = requestRetryFlag?.gwCodeReTryPath.includes(path);
|
|
425
|
+
if (isGwCodeRetryPathWhite && isGatewayCodeNeedRetry(gatewayCode)) {
|
|
424
426
|
return await this.handleReTry(path, param, method, header, {
|
|
425
427
|
reportMsg: {
|
|
426
428
|
gatewayCode,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { getSystemInfoSync } from '../../wxApi';
|
|
2
|
-
|
|
3
1
|
class CanvasDrawer {
|
|
4
2
|
constructor(canvasId, container, instance = '', designWindowWidth = 750) {
|
|
5
3
|
this.canvasId = canvasId; // canvasId
|
|
@@ -18,7 +16,7 @@ class CanvasDrawer {
|
|
|
18
16
|
const canvas = res[0].node;
|
|
19
17
|
this.canvas = canvas;
|
|
20
18
|
this.ctx = canvas.getContext('2d');
|
|
21
|
-
const { pixelRatio: dpr, windowWidth } = getSystemInfoSync();
|
|
19
|
+
const { pixelRatio: dpr, windowWidth } = wx.getSystemInfoSync();
|
|
22
20
|
canvas.width = res[0].width * dpr;
|
|
23
21
|
canvas.height = res[0].height * dpr;
|
|
24
22
|
this.ratio = windowWidth / this.designWindowWidth;
|