@tmsfe/tms-core 0.0.83 → 0.0.86
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 +6 -13
- package/src/index-proxy.js +2 -1
- package/src/index.js +3 -1
- package/src/navbarUtils.js +1 -0
- package/src/utils/canvas/canvasDrawer.js +3 -2
- package/src/utils/location/index.js +18 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmsfe/tms-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.86",
|
|
4
4
|
"description": "tms运行时框架",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,27 +17,20 @@
|
|
|
17
17
|
"esm"
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
|
-
"whiteDependencies": {
|
|
21
|
-
"@babel/core": "ignore",
|
|
22
|
-
"@babel/plugin-proposal-optional-chaining": "ignore",
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "ignore",
|
|
24
|
-
"@typescript-eslint/parser": "ignore",
|
|
25
|
-
"miniprogram-api-typings": "ignore"
|
|
26
|
-
},
|
|
27
20
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.
|
|
21
|
+
"@babel/core": "^7.17.9",
|
|
29
22
|
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
|
30
23
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2",
|
|
31
|
-
"@babel/plugin-proposal-optional-chaining": "^7.14.
|
|
24
|
+
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
|
|
32
25
|
"@rollup/plugin-babel": "^5.0.2",
|
|
33
26
|
"@rollup/plugin-commonjs": "^19.0.0",
|
|
34
27
|
"@rollup/plugin-dynamic-import-vars": "^1.1.1",
|
|
35
28
|
"@rollup/plugin-json": "^4.0.3",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
37
|
-
"@typescript-eslint/parser": "^
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
|
30
|
+
"@typescript-eslint/parser": "^5.2.0",
|
|
38
31
|
"babel-core": "^6.26.3",
|
|
39
32
|
"babel-preset-env": "^1.7.0",
|
|
40
|
-
"miniprogram-api-typings": "
|
|
33
|
+
"miniprogram-api-typings": "latest",
|
|
41
34
|
"rimraf": "^3.0.2",
|
|
42
35
|
"rollup": "^2.6.1",
|
|
43
36
|
"rollup-plugin-node-resolve": "^5.2.0",
|
package/src/index-proxy.js
CHANGED
|
@@ -10,7 +10,7 @@ import AutoReport from './report/proxy/index';
|
|
|
10
10
|
import md5 from './md5';
|
|
11
11
|
import { serialize } from './objUtils';
|
|
12
12
|
import { calCoordinateDistance, formatDistance } from './distanceUtils';
|
|
13
|
-
import { getNavBarConfigData } from './navbarUtils';
|
|
13
|
+
import { getNavBarConfigData, compareVersion } from './navbarUtils';
|
|
14
14
|
import * as uiUtil from './tmsuiUtils';
|
|
15
15
|
import * as rpxUtil from './rpx';
|
|
16
16
|
import * as stringUtils from './stringUtils';
|
|
@@ -216,6 +216,7 @@ const api = {
|
|
|
216
216
|
calCoordinateDistance,
|
|
217
217
|
formatDistance,
|
|
218
218
|
getNavBarConfigData,
|
|
219
|
+
compareVersion,
|
|
219
220
|
createRequest,
|
|
220
221
|
getEnvInfo,
|
|
221
222
|
isAppPageExist,
|
package/src/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import EventDispatcher from './eventDispatcher';
|
|
|
12
12
|
import { serialize } from './objUtils';
|
|
13
13
|
import { calCoordinateDistance, formatDistance } from './distanceUtils';
|
|
14
14
|
import { rpxToPx, pxToRpx } from './rpx';
|
|
15
|
-
import { getNavBarConfigData } from './navbarUtils';
|
|
15
|
+
import { getNavBarConfigData, compareVersion } from './navbarUtils';
|
|
16
16
|
import {
|
|
17
17
|
formatPlate,
|
|
18
18
|
subStr,
|
|
@@ -196,6 +196,8 @@ const api = {
|
|
|
196
196
|
rpxToPx,
|
|
197
197
|
pxToRpx,
|
|
198
198
|
|
|
199
|
+
/** 版本比较 */
|
|
200
|
+
compareVersion,
|
|
199
201
|
getNavBarConfigData,
|
|
200
202
|
|
|
201
203
|
storage,
|
package/src/navbarUtils.js
CHANGED
|
@@ -125,14 +125,15 @@ class CanvasDrawer {
|
|
|
125
125
|
* @memberof Wxml2Poster
|
|
126
126
|
*/
|
|
127
127
|
drawText(text, x, y, size, color, align = 'left', bold = 'normal', baseLine = 'middle', calWidth = false) {
|
|
128
|
+
const str = `${text}`; // 避免某些环境下字体宽度计算异常(如手图),这里统一将绘制文本转为字符串
|
|
128
129
|
this.ctx.save();
|
|
129
130
|
this.ctx.fillStyle = color;
|
|
130
131
|
this.ctx.font = `normal ${bold} ${~~(this.toPx(size))}px sans-serif`;
|
|
131
132
|
let width = 0;
|
|
132
|
-
if (calWidth) width = this.ctx.measureText(
|
|
133
|
+
if (calWidth) width = this.ctx.measureText(str).width; // 必须在设置字体属性后未绘制前计算才能拿到准确值; 无需计算时避免耗费性能
|
|
133
134
|
this.ctx.textAlign = align;
|
|
134
135
|
this.ctx.textBaseline = baseLine;
|
|
135
|
-
this.ctx.fillText(
|
|
136
|
+
this.ctx.fillText(str, this.toPx(x), this.toPx(y));
|
|
136
137
|
this.ctx.restore();
|
|
137
138
|
return width;
|
|
138
139
|
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @desc: 位置工具方法语法糖
|
|
3
|
+
* @author: fenggangsun
|
|
4
|
+
* @date: 2022-06-27 11:46:25
|
|
5
|
+
* @lastEditors: fenggangsun
|
|
6
|
+
* @lastEditTime: 2022-06-29 17:34:24
|
|
7
|
+
* @copyright 2022-present, Tencent, Inc. All rights reserved.
|
|
8
|
+
*/
|
|
1
9
|
const defaultLoc = {
|
|
2
10
|
province: '广东省',
|
|
3
11
|
cityName: '深圳市',
|
|
@@ -29,6 +37,7 @@ const locTypeEnum = { // 位置类型
|
|
|
29
37
|
* @param {String} option.authTip 获取实时定位,发起授权时的提示语
|
|
30
38
|
* @param {Boolean} option.ipCache 是否使用缓存的 ip 位置,默认 true;ipCache = false 时会重新发起 ip 定位
|
|
31
39
|
* @returns {Promise<Object>} { loc, locType }
|
|
40
|
+
* loc: { adCode, provinceCode, cityCode, province, cityName, longitude, latitude }
|
|
32
41
|
*/
|
|
33
42
|
const getPrioritizedLocation = async (typeOrders, option) => {
|
|
34
43
|
const { showAuth, authTip, ipCache = true } = option || {};
|
|
@@ -39,7 +48,15 @@ const getPrioritizedLocation = async (typeOrders, option) => {
|
|
|
39
48
|
getLocProm = defaultLoc;
|
|
40
49
|
break;
|
|
41
50
|
case locTypeEnum.ip:
|
|
42
|
-
getLocProm = getLocManager().getIpLocation(!ipCache)
|
|
51
|
+
getLocProm = getLocManager().getIpLocation(!ipCache)
|
|
52
|
+
.then((data) => {
|
|
53
|
+
const { ad_info: { adcode, cityCode, province, city }, location: { lng, lat } } = data;
|
|
54
|
+
return {
|
|
55
|
+
adCode: adcode, cityCode, provinceCode: `${cityCode.slice(0, 4)}00`,
|
|
56
|
+
province, cityName: city, longitude: lng, latitude: lat,
|
|
57
|
+
...data,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
43
60
|
break;
|
|
44
61
|
case locTypeEnum.real: // 实时位置
|
|
45
62
|
getLocProm = getLocManager().getLocationDetail(showAuth, undefined, authTip);
|