@tmsfe/tms-core 0.0.180 → 0.0.182
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/report/helper.ts +3 -3
- package/src/report/types.ts +3 -0
- package/src/request.js +21 -13
package/package.json
CHANGED
package/src/report/helper.ts
CHANGED
|
@@ -42,10 +42,10 @@ let systemInfo: ISystemInfo;
|
|
|
42
42
|
*/
|
|
43
43
|
function getSystemInfo(): ISystemInfo {
|
|
44
44
|
if (!systemInfo) {
|
|
45
|
-
const
|
|
45
|
+
const currentSystemInfo = wx.getSystemInfoSync() as any;
|
|
46
46
|
// eslint-disable-next-line
|
|
47
|
-
const { model = '', version: wxVersion = '', platform = '', SDKVersion = '', host } =
|
|
48
|
-
systemInfo = { model, wxVersion, platform, SDKVersion, host };
|
|
47
|
+
const { model = '', version: wxVersion = '', platform = '', SDKVersion = '', host, benchmarkLevel, system, memorySize } = currentSystemInfo;
|
|
48
|
+
systemInfo = { model, wxVersion, platform, SDKVersion, host, benchmarkLevel, system, memorySize };
|
|
49
49
|
}
|
|
50
50
|
return systemInfo;
|
|
51
51
|
}
|
package/src/report/types.ts
CHANGED
package/src/request.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* 框架判断在不同的运行环境,切换调用不同运行环境提供的方法。
|
|
10
10
|
*/
|
|
11
11
|
import md5 from './md5';
|
|
12
|
-
import { getEnvInfo } from './env';
|
|
12
|
+
import { getEnvInfo, getAuthInfo } from './env';
|
|
13
13
|
import { safeJsonParse } from './objUtils';
|
|
14
14
|
import { encryptObjInit } from './encrypt/index';
|
|
15
15
|
import reporter from './report/index';
|
|
@@ -125,10 +125,18 @@ const composeParam = async (param = {}, withAuth = true, baseParam = {}) => {
|
|
|
125
125
|
const modifyAuthParam = async (param, withAuth) => {
|
|
126
126
|
const requestParam = { ...param };
|
|
127
127
|
if (withAuth) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
// 优先使用wx.tmsLoginPromise获取鉴权信息,否则调用getAuthInfo()
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
130
|
+
const authInfo = wx.tmsLoginPromise
|
|
131
|
+
? await wx.tmsLoginPromise
|
|
132
|
+
: await getAuthInfo();
|
|
133
|
+
|
|
134
|
+
// 统一处理鉴权参数赋值
|
|
135
|
+
Object.assign(requestParam, {
|
|
136
|
+
userId: authInfo.uid || authInfo.userId,
|
|
137
|
+
token: authInfo.token,
|
|
138
|
+
openId: authInfo.openId,
|
|
139
|
+
});
|
|
132
140
|
return requestParam;
|
|
133
141
|
}
|
|
134
142
|
delete requestParam.userId;
|
|
@@ -459,28 +467,28 @@ const isPathNeedRetryLogin = (path) => {
|
|
|
459
467
|
];
|
|
460
468
|
|
|
461
469
|
// 检查路径是否在白名单中
|
|
462
|
-
return
|
|
470
|
+
return noRetryPaths.every(noRetryPath => !path.includes(noRetryPath));
|
|
463
471
|
};
|
|
464
472
|
|
|
465
|
-
|
|
466
|
-
let refreshFlag = false;
|
|
473
|
+
let refreshPromise;
|
|
467
474
|
async function loginRefresh() {
|
|
468
|
-
if (!
|
|
475
|
+
if (!refreshPromise) {
|
|
469
476
|
// 调用runtime的login方法刷新token
|
|
470
477
|
const { tms } = getApp();
|
|
471
478
|
wx.tmsLoginPromise = undefined;
|
|
472
479
|
try {
|
|
473
|
-
|
|
474
|
-
await
|
|
480
|
+
refreshPromise = tms.login();
|
|
481
|
+
await refreshPromise;
|
|
475
482
|
// 登录成功,清除Promise
|
|
476
|
-
|
|
483
|
+
refreshPromise = undefined;
|
|
477
484
|
} catch (err) {
|
|
478
485
|
// 登录失败重试
|
|
479
486
|
setTimeout(() => {
|
|
480
|
-
|
|
487
|
+
refreshPromise = undefined;
|
|
481
488
|
}, 100);
|
|
482
489
|
}
|
|
483
490
|
}
|
|
491
|
+
return await refreshPromise;
|
|
484
492
|
}
|
|
485
493
|
|
|
486
494
|
// 统一返回格式
|