@tmsfe/tms-core 0.0.90 → 0.0.91

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tms-core",
3
- "version": "0.0.90",
3
+ "version": "0.0.91",
4
4
  "description": "tms运行时框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  const maxArrLen = 10;
6
- const maxStrLen = 30;
6
+ const maxStrLen = 200;
7
7
  const maxFieldLen = 20;
8
8
 
9
9
  function isBasicsType(obj: any): { isBasics: boolean, value: any } {
@@ -13,7 +13,13 @@ function isBasicsType(obj: any): { isBasics: boolean, value: any } {
13
13
  return { isBasics: true, value: obj };
14
14
  }
15
15
  if (type === 'string') {
16
- const value = obj.substr(0, maxStrLen);
16
+ // 简单判断是否encodeURIComponent字段,如果时的话则抛弃掉
17
+ // 因为在后端会被decode导致反序列化时语法错误
18
+ if (obj.match(/%/g)?.length >= 2) {
19
+ return { isBasics: true, value: '' };
20
+ }
21
+
22
+ const value = obj.substring(0, maxStrLen);
17
23
  return { isBasics: true, value };
18
24
  }
19
25
  if (type === 'function' || type === 'symbol') {
@@ -4,6 +4,7 @@
4
4
 
5
5
  // / <reference path='./types.ts'/>
6
6
  import syncApi from '../syncfnmanager';
7
+ import clone from './clone';
7
8
 
8
9
  function getTms(): any {
9
10
  // 如果是在app.js的onLaunch中调用,则没有getApp().tms为空
@@ -33,7 +34,8 @@ function init(options: IInitOptions): void {
33
34
  };
34
35
 
35
36
  wx.onAppShow((options) => {
36
- launchOptions = options;
37
+ // 克隆函数内会限制对象字段
38
+ launchOptions = clone.deepClone(options);
37
39
  });
38
40
  }
39
41
 
@@ -145,6 +147,10 @@ function getPageInfo(): IPage {
145
147
  options = page?.options;
146
148
  depth = pages.length;
147
149
  }
150
+
151
+ // 克隆函数内会限制对象字段
152
+ options = clone.deepClone(options);
153
+
148
154
  // wx_navigate_before埋点上报时可能route是一个很大的对象而不是字符串,原因不详
149
155
  if (typeof route as any !== 'string') {
150
156
  route = '';
@@ -160,6 +166,8 @@ let launchOptions: any = null;
160
166
  function getLaunchOptions(): any {
161
167
  if (launchOptions === null) {
162
168
  launchOptions = syncApi.getLaunchOptionsSync();
169
+ // 克隆函数内会限制对象字段
170
+ launchOptions = clone.deepClone(launchOptions);
163
171
  }
164
172
  return launchOptions;
165
173
  }
@@ -17,7 +17,16 @@ function proxyNavigateApi(api: string): void {
17
17
  value(...args: any) {
18
18
  const { url = '' } = args[0] || {};
19
19
  const [path, params = ''] = url.split('?');
20
- helper.reportData(`wx_${api}_before`, path, params);
20
+ const data = {};
21
+ params.split('&').map((str: string) => {
22
+ let [key, value = ''] = str.split('=');
23
+ if (value.indexOf('%') !== -1) {
24
+ value = '';
25
+ }
26
+ // @ts-ignore
27
+ data[key] = value;
28
+ });
29
+ helper.reportData(`wx_${api}_before`, path, data);
21
30
 
22
31
  originalApi.apply(this, args);
23
32
  },
@@ -4,8 +4,8 @@
4
4
 
5
5
  // / <reference path='./types.ts'/>
6
6
 
7
+ import clone from '../clone';
7
8
  import helper from './helper';
8
- import clone from './clone';
9
9
 
10
10
  let originalComponent: any = null;
11
11
 
@@ -4,8 +4,8 @@
4
4
 
5
5
  // / <reference path='./types.ts'/>
6
6
 
7
+ import clone from '../clone';
7
8
  import helper from './helper';
8
- import clone from './clone';
9
9
 
10
10
  // 工具为页面根节点插入的触摸事件
11
11
  const pageTouchEvent = 'onReportPageTouch';