gio-miniprogram-sdk 4.4.0 → 4.4.2

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.
@@ -1,6 +1,6 @@
1
1
  import { EventHooksType, MinipPageType } from '@@/types/eventHooks';
2
2
  import { GrowingIOType } from '@@/types/growingIO';
3
- import { has, isArray, isFunction, typeOf, unset } from '@@/utils/glodash';
3
+ import { has, isArray, isEmpty, isFunction, typeOf } from '@@/utils/glodash';
4
4
  import { consoleText, getGlobal, niceTry } from '@@/utils/tools';
5
5
 
6
6
  import AppEffects from './appEffects';
@@ -87,95 +87,135 @@ class EventHooks implements EventHooksType {
87
87
  }
88
88
  };
89
89
 
90
- // 生命周期方法effects
90
+ /**
91
+ * 执行生命周期回调并广播事件
92
+ */
93
+ lifeFcEffectsFn = (instance, args, cType, eventName, result = undefined) => {
94
+ // 创建参数数组副本
95
+ const argsArray =
96
+ typeOf(args) === 'array' ? Array.prototype.slice.call(args) : [];
97
+ // 如果有结果,添加到参数列表
98
+ if (!isEmpty(result)) {
99
+ argsArray.push(result);
100
+ }
101
+
102
+ // 执行effects
103
+ this[`def${cType}Cbs`][eventName].apply(instance, argsArray);
104
+
105
+ // 广播生命周期
106
+ this.growingIO.emitter.emit(EMIT_MSG.MINIP_LIFECYCLE, {
107
+ event: `${cType} ${eventName}End`,
108
+ timestamp: Date.now(),
109
+ params: { instance, arguments: Array.from(argsArray) }
110
+ });
111
+
112
+ return result;
113
+ };
114
+
115
+ /**
116
+ * 生命周期方法effects
117
+ */
91
118
  lifeFcEffects = (eventName: string, method: any, cType: 'App' | 'Page') => {
92
119
  const self = this;
93
- if (['onShareTimeline', 'onAddToFavorites'].includes(eventName)) {
94
- // onShareTimeline和onAddToFavorites不能异步执行,单独处理
95
- return function (...args) {
96
- let result = method.apply(this, args);
97
- if (
98
- eventName === 'onShareTimeline' &&
99
- self.growingIO.vdsConfig.followShare
100
- ) {
101
- result = self.currentPage.updateTimelineResult(result ?? {});
102
- }
103
- if (eventName === 'onAddToFavorites') {
104
- result = self.currentPage.updateAddFavoritesResult(result ?? {});
105
- }
106
- const argsArray = Array.prototype.slice.call(args);
107
- if (result) {
108
- argsArray.push(result);
120
+
121
+ return function (...args) {
122
+ let result;
123
+
124
+ // 分享事件单独处理
125
+ if (self.shareEventTypes.includes(eventName)) {
126
+ // 先执行分享的生命周期拿到分享数据
127
+ const originResult = method.apply(this, args) ?? {};
128
+
129
+ // sdk跟踪分享事件时才处理,否则直接返回原结果
130
+ if (!self.growingIO.vdsConfig.followShare) {
131
+ return originResult;
109
132
  }
110
- // 执行effects
111
- self[`def${cType}Cbs`][eventName].apply(this, argsArray);
112
- return result;
113
- };
114
- } else {
115
- // 其他生命周期可以异步执行
116
- return async function (...args) {
117
- let result;
118
- try {
119
- // 分享处理
120
- if (self.shareEventTypes.includes(eventName)) {
121
- // 先执行分享的生命周期拿到分享数据
122
- // 与基础库保持一致,没有返回值时默认使用{}
123
- result = method.apply(this, args) ?? {};
124
- // 如果分享事件是个promise函数,需要等待异步结果
125
- if (typeOf(result) === 'promise') {
126
- result = await result.then((r) => r);
127
- }
128
- // 如果返回的对象中包含promise,要等待异步结果
129
- if (typeOf(result.promise) === 'promise') {
130
- const f = async function () {
131
- let sRes = result;
132
- return new Promise((resolve) => {
133
- // 如果3秒后result.promise没有返回结果,则返回的是默认的result值
134
- // https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#onShareAppMessage-Object-object
135
- let t = setTimeout(() => {
136
- resolve({ ...sRes });
137
- clearTimeout(t);
138
- t = undefined;
139
- }, 3000);
140
- result.promise.then((res) => {
141
- sRes = res;
142
- resolve({ ...sRes });
143
- clearTimeout(t);
144
- t = undefined;
145
- });
146
- });
133
+ const isPromiseResult = typeOf(originResult) === 'promise';
134
+ const hasPromiseProperty = typeOf(originResult.promise) === 'promise';
135
+ // 支付宝的promise会被提前处理过,通过以下两个字段判断是否需要自定义promise
136
+ const isSpecialPromise =
137
+ has(originResult, '_result') && has(originResult, '_state');
138
+
139
+ // 处理异步分享结果
140
+ if (isPromiseResult || hasPromiseProperty || isSpecialPromise) {
141
+ // 创建处理Promise结果的通用函数
142
+ const handlePromiseResult = (promiseResult = {}) => {
143
+ try {
144
+ // 合并原始结果和Promise结果
145
+ const mergedResult = {
146
+ ...originResult,
147
+ ...promiseResult
147
148
  };
148
- result = { ...result, ...((await f()) as any) };
149
- unset(result, 'promise');
150
- }
151
- if (self.growingIO.vdsConfig.followShare) {
152
- result = self.currentPage.updateAppMessageResult(result ?? {});
149
+
150
+ // 更新分享内容
151
+ const updatedResult =
152
+ self.currentPage.updateShareResult(mergedResult);
153
+
154
+ // 执行回调
155
+ self.lifeFcEffectsFn(this, args, cType, eventName, updatedResult);
156
+ } catch (error) {
157
+ consoleText(error, 'error');
153
158
  }
159
+ };
160
+
161
+ // 处理整个返回值是Promise的情况
162
+ if (isPromiseResult) {
163
+ // 如果三秒内不resolve结果,分享会使用原默认参数
164
+ Promise.race([
165
+ originResult,
166
+ new Promise((resolve) => {
167
+ setTimeout(() => {
168
+ resolve({});
169
+ }, 3000);
170
+ })
171
+ ])
172
+ .then(handlePromiseResult)
173
+ .catch((error) => consoleText(error, 'error'));
154
174
  }
155
- const argsArray = Array.prototype.slice.call(args);
156
- if (result) {
157
- argsArray.push(result);
175
+
176
+ // 处理返回值中包含promise属性的情况
177
+ if (hasPromiseProperty) {
178
+ // 如果三秒内不resolve结果,分享会使用原默认参数
179
+ Promise.race([
180
+ originResult.promise,
181
+ new Promise((resolve) => {
182
+ setTimeout(() => {
183
+ resolve({});
184
+ }, 3000);
185
+ })
186
+ ])
187
+ .then(handlePromiseResult)
188
+ .catch((error) => consoleText(error, 'error'));
158
189
  }
159
- // 执行effects
160
- self[`def${cType}Cbs`][eventName].apply(this, argsArray);
161
- } catch (error) {
162
- consoleText(error, 'error');
163
- }
164
- // 执行分享之外的生命周期函数
165
- if (!self.shareEventTypes.includes(eventName)) {
166
- result = method.apply(this, args);
190
+
191
+ // 处理支付宝特有的promise
192
+ if (isSpecialPromise) {
193
+ self.growingIO.minipInstance?.handleSharePromise(
194
+ originResult,
195
+ handlePromiseResult
196
+ );
197
+ }
198
+
199
+ // 直接返回原分享结果继续执行原逻辑
200
+ result = self.currentPage.updateShareResult(originResult, false);
201
+ } else {
202
+ // 没有异步逻辑,直接更新分享内容执行回调
203
+ result = self.currentPage.updateShareResult(originResult);
204
+ self.lifeFcEffectsFn(this, args, cType, eventName, result);
167
205
  }
168
- self.growingIO.emitter.emit(EMIT_MSG.MINIP_LIFECYCLE, {
169
- event: `${cType} ${eventName}End`,
170
- timestamp: Date.now(),
171
- params: { instance: this, arguments: Array.from(args) }
172
- });
173
- return result;
174
- };
175
- }
206
+ } else {
207
+ // 其他生命周期事件:先执行回调,再执行原方法
208
+ self.lifeFcEffectsFn(this, args, cType, eventName);
209
+ result = method.apply(this, args);
210
+ }
211
+
212
+ return result;
213
+ };
176
214
  };
177
215
 
178
- // 自定义方法effects
216
+ /*
217
+ * 自定义方法effects
218
+ */
179
219
  customFcEffects = (eventName: string, method: any) => {
180
220
  const self = this;
181
221
  return function (...args) {
@@ -1,12 +1,4 @@
1
- import {
2
- compact,
3
- has,
4
- head,
5
- isEmpty,
6
- keys,
7
- last,
8
- unset
9
- } from '@@/utils/glodash';
1
+ import { compact, has, isEmpty, keys, last, unset } from '@@/utils/glodash';
10
2
  import { GrowingIOType } from '@@/types/growingIO';
11
3
  import { MinipPageType, PageShareResult } from '@@/types/eventHooks';
12
4
  import {
@@ -17,13 +9,13 @@ import {
17
9
  niceTry,
18
10
  getDynamicAttributes,
19
11
  limitObject,
20
- getLaunchQuery
12
+ getPureParams
21
13
  } from '@@/utils/tools';
22
14
  import { EVENT } from '@@/types/base';
23
15
 
24
16
  class MinipPage implements MinipPageType {
25
17
  // 根据页面存储的页面参数
26
- public queryOption: any;
18
+ public queryOptions: any;
27
19
  // 通过调用wx.setNavigationBarTitle设置的title
28
20
  public configuredTitle: any;
29
21
  // 页面级属性
@@ -36,12 +28,16 @@ class MinipPage implements MinipPageType {
36
28
  public lifeBeforeShow = true;
37
29
 
38
30
  constructor(public growingIO: GrowingIOType) {
39
- this.queryOption = {};
31
+ this.queryOptions = {};
40
32
  this.configuredTitle = {};
41
33
  this.pageProps = {};
42
34
  }
43
35
 
44
- // 获取页面地址
36
+ /**
37
+ * 获取当前页面路径
38
+ * 优先级:页面堆栈路径 > 启动参数路径 > 最近 page 事件路径 > 最近 visit 事件路径
39
+ * 插件环境下无页面时返回插件 appId
40
+ */
45
41
  getPagePath = () => {
46
42
  const { minipInstance, inPlugin, dataStore, trackingId } = this.growingIO;
47
43
  const path = minipInstance.getCurrentPath();
@@ -61,7 +57,10 @@ class MinipPage implements MinipPageType {
61
57
  }
62
58
  };
63
59
 
64
- // 获取页面参数
60
+ /**
61
+ * 获取当前页面参数(query)
62
+ * 优先级:页面堆栈参数 > 生命周期参数 > 启动参数 > 最近 page 事件参数 > 最近 visit 事件参数
63
+ */
65
64
  getPageQuery = () => {
66
65
  const { minipInstance, dataStore, trackingId } = this.growingIO;
67
66
  const stackPage = minipInstance.getCurrentPage();
@@ -71,17 +70,15 @@ class MinipPage implements MinipPageType {
71
70
  const pageParams = stackPage.options ?? stackPage.$taroParams;
72
71
  // 堆栈中有页面信息,则使用堆栈中的页面参数
73
72
  if (!isEmpty(pageParams)) {
74
- // 删掉taro框架中自带的字段
75
- unset(pageParams, '$taroTimestamp');
76
- // 有页面解析的option直接取
77
- return this.qsQuery(pageParams);
78
- } else if (!isEmpty(this.queryOption[stackPath])) {
79
- // 没有option从hook获取的生命周期参数中取
80
- return this.qsQuery(this.queryOption[stackPath]);
73
+ // 有页面解析的 option 直接取
74
+ return qsStringify(getPureParams(pageParams));
75
+ } else if (!isEmpty(this.queryOptions[stackPath])) {
76
+ // 没有 option 从 hook 获取的生命周期参数中取
77
+ return qsStringify(getPureParams(this.queryOptions[stackPath]));
81
78
  } else if (stackPath === enterParams.path) {
82
79
  // 某些小程序虽然有页面堆栈,但是页面还没加载完,兜底取启动参数
83
- return this.qsQuery(
84
- getLaunchQuery(
80
+ return qsStringify(
81
+ getPureParams(
85
82
  enterParams?.query,
86
83
  enterParams?.referrerInfo?.extraData
87
84
  )
@@ -89,20 +86,24 @@ class MinipPage implements MinipPageType {
89
86
  }
90
87
  } else if (enterParams.path) {
91
88
  // 堆栈中没有页面信息,但启动参数中有,说明是小程序刚启动还没加载页面,直接取启动参数
92
- return this.qsQuery(
93
- getLaunchQuery(enterParams?.query, enterParams?.referrerInfo?.extraData)
89
+ return qsStringify(
90
+ getPureParams(enterParams?.query, enterParams?.referrerInfo?.extraData)
94
91
  );
95
92
  } else {
96
- // 作为页面组件时component created生命周期中的埋点会取不到页面堆栈,所以拿最近的一个page事件中的页面信息做兜底
93
+ // 作为页面组件时 component created 生命周期中的埋点会取不到页面堆栈,所以拿最近的一个 page 事件中的页面信息做兜底
97
94
  return dataStore.lastPageEvent[trackingId]?.path
98
95
  ? dataStore.lastPageEvent[trackingId]?.query
99
- : // 没有最近的一个page事件说明在app初始化的生命周期中,有些框架可能会有异步处理逻辑导致事件触发比visit晚,则使用visit事件中的页面信息兜底
96
+ : // 没有最近的一个 page 事件说明在 app 初始化的生命周期中,有些框架可能会有异步处理逻辑导致事件触发比 visit 晚,则使用 visit 事件中的页面信息兜底
100
97
  dataStore.lastVisitEvent[trackingId]?.query;
101
98
  }
102
99
  };
103
100
 
104
- // 获取页面标题
105
- // 页面title (优先级:setNavigationBarTitle > data.gioPageTitle[不保证能取到] > config.js中设置的值 > tabBar配置)
101
+ /**
102
+ * 获取页面标题
103
+ * 优先级:setNavigationBarTitle > data.gioPageTitle > config.js 中设置的值 > tabBar 配置
104
+ * 插件环境下无页面时返回插件 appId
105
+ * @param trackingId 可选,追踪 id
106
+ */
106
107
  getPageTitle = (trackingId?: string) => {
107
108
  const { minipInstance, inPlugin, dataStore } = this.growingIO;
108
109
  const path = minipInstance.getCurrentPath();
@@ -122,14 +123,11 @@ class MinipPage implements MinipPageType {
122
123
  }
123
124
  };
124
125
 
125
- // 格式化页面参数
126
- qsQuery = (query = {}) => {
127
- const slimQuery = { ...query };
128
- unset(slimQuery, 'wxShoppingListScene');
129
- return qsStringify(slimQuery);
130
- };
131
-
132
- // 获取页面来源
126
+ /**
127
+ * 获取页面来源(referrer)
128
+ * 优先级:最近 page 事件路径 > 启动参数 referrerInfo.appId > scene 场景值
129
+ * @param trackingId 追踪 id
130
+ */
133
131
  getReferralPage = (trackingId: string) => {
134
132
  const {
135
133
  minipInstance,
@@ -142,69 +140,68 @@ class MinipPage implements MinipPageType {
142
140
  );
143
141
  };
144
142
 
145
- // 处理分享参数
146
- buildShareQuery(
147
- result: PageShareResult // 客户自定义的参数
148
- ): [string, string] {
149
- // 自定义path的地址参数截取(onShareAppMessage中的页面参数是拼在地址中的)
143
+ /**
144
+ * 处理分享参数,生成分享用的 path 和 query
145
+ * 优先级:result.query > result.path > 当前页面参数(去除 utm_ 开头参数)
146
+ * @param result PageShareResult 客户自定义的参数
147
+ * @returns [path, queryString]
148
+ */
149
+ buildShareQuery(result: PageShareResult): [string, string] {
150
+ // 自定义 path 的地址参数截取(onShareAppMessage 中的页面参数是拼在地址中的)
150
151
  const customSplit = splitPath(result.path ?? '');
151
152
 
152
- let path = this.getPagePath();
153
+ let path = result.path || this.getPagePath();
153
154
  let parsedQuery: any = {};
154
155
  let resultHasPath = has(result, 'path');
155
- // 优先使用自定义的地址
156
- if (resultHasPath) {
157
- path = head(customSplit);
156
+ let resultHasQuery = has(result, 'query');
157
+ // 如果定义了 query 字段则优先取 query 参数
158
+ if (resultHasQuery) {
159
+ parsedQuery = qsParse(result.query ?? '') || {};
160
+ } else if (resultHasPath) {
161
+ // 没有定义 query 字段则尝试取 path 中的参数
158
162
  parsedQuery = qsParse(last(customSplit)) || {};
159
- }
163
+ } else {
164
+ // 只有在没有自定义 path 和 query 的情况下,才使用页面堆栈中的默认参数并删除 utm 参数
165
+ const stackPage = this.growingIO.minipInstance.getCurrentPage();
166
+ // 这里不要直接用对象赋值,下面的 unset 会修改原对象,导致触发一次分享以后当前页面事件中的 utm 参数就会被删除掉
167
+ parsedQuery = {
168
+ ...(stackPage.options || this.queryOptions[stackPage.route] || {})
169
+ };
160
170
 
161
- // 自定义path中没有截取到query说明是在onShareAppMessage中没有参数,或是在onShareTimeline中需要取自定义query
162
- if (isEmpty(parsedQuery)) {
163
- parsedQuery = qsParse(result.query ?? '') || {};
171
+ // 删除 utm_ 参数
164
172
  compact(keys(parsedQuery)).forEach((key) => {
165
- // 删除从默认页面的query中原有的utm参数,防止带入到下一次分享导致渠道统计错误(如果客户质疑参数被删,让他们自己拼回去或者关followShare)
166
173
  if (key.toLowerCase().startsWith('utm_')) {
167
174
  unset(parsedQuery, key);
168
175
  }
169
176
  });
170
177
  }
171
178
 
172
- // 以上两种都是自定义的地址和参数,不做处理直接用,防止出现encode/decode的问题。
173
-
174
- // 自定义query没有值则使用当前页面默认参数
175
- // 如果path存在,但是不携带参数,此时不使用当前页面的默认参数
176
- if (!resultHasPath && isEmpty(parsedQuery)) {
177
- const stackPage = this.growingIO.minipInstance.getCurrentPage();
178
- parsedQuery =
179
- stackPage.options || this.queryOption[stackPage.route] || {};
180
- }
181
-
182
179
  return [path, qsStringify(parsedQuery)];
183
180
  }
184
181
 
185
- // 更新分享结果
186
- updateShareResult = (result: PageShareResult) => {
187
- const [path, queryString] = this.buildShareQuery(result);
188
- result.path = normalPath(path + (queryString ? `?${queryString}` : ''));
189
- result.query = queryString;
190
- return result;
191
- };
192
-
193
- // 更新分享转发事件的结果
194
- updateAppMessageResult = this.updateShareResult;
195
-
196
- // 更新分享朋友圈结果
197
- updateTimelineResult = this.updateShareResult;
198
-
199
- // 更新收藏结果
200
- updateAddFavoritesResult = (result: PageShareResult) => {
182
+ /**
183
+ * 更新分享结果,补全参数
184
+ * @param result PageShareResult 分享参数对象
185
+ * @param fillParams 是否补全参数,默认 true
186
+ * @returns 更新后的 result
187
+ */
188
+ updateShareResult = (result: PageShareResult, fillParams = true) => {
201
189
  const [path, queryString] = this.buildShareQuery(result);
202
- result.path = normalPath(path + (queryString ? `?${queryString}` : ''));
203
- result.query = queryString;
190
+ if (fillParams || has(result, 'path')) {
191
+ result.path = normalPath(path + (queryString ? `?${queryString}` : ''));
192
+ }
193
+ if (fillParams || has(result, 'query')) {
194
+ result.query = queryString;
195
+ }
204
196
  return result;
205
197
  };
206
198
 
207
- // 给事件合并页面属性
199
+ /**
200
+ * 给事件合并页面属性
201
+ * @param trackingId 追踪 id
202
+ * @param event 事件对象
203
+ * @returns 合并后的属性对象
204
+ */
208
205
  eventSetPageProps = (trackingId: string, event: EVENT) => {
209
206
  const pageProps = niceTry(
210
207
  () => this.pageProps[trackingId][this.getPagePath()]
@@ -67,7 +67,7 @@ class PageEffects {
67
67
  switch (event) {
68
68
  case pageListeners.pageLoad: {
69
69
  // 获取一次页面参数存起来,防止类似支付宝小程序只能通过生命周期获取页面参数或页面堆栈拿不到页面参数,做兜底
70
- currentPage.queryOption[path] =
70
+ currentPage.queryOptions[path] =
71
71
  get(page, 'options') ||
72
72
  get(page, '__displayReporter.query') ||
73
73
  get(page, '$page.query') ||
@@ -75,7 +75,10 @@ class PageEffects {
75
75
  get(page, '$taroParams') ||
76
76
  args[0] ||
77
77
  {};
78
- unset(currentPage.queryOption[path], '$taroTimestamp');
78
+ unset(currentPage.queryOptions[path], [
79
+ '$taroTimestamp',
80
+ 'gdpCircleRoomCollectUrl'
81
+ ]);
79
82
  break;
80
83
  }
81
84
  case pageListeners.pageShow: {
@@ -114,6 +117,9 @@ class PageEffects {
114
117
  break;
115
118
  }
116
119
  case pageListeners.shareTime: {
120
+ if (minipInstance.platform === 'xhsp') {
121
+ toggleShareOut(true);
122
+ }
117
123
  trackersExecute((trackingId: string) => {
118
124
  const { followShare } = getTrackerVds(trackingId);
119
125
  if (followShare) {
@@ -582,7 +582,7 @@ class DataStore implements DataStoreType {
582
582
  };
583
583
  event.attributes = limitObject({
584
584
  ...(event.attributes ?? {}),
585
- $from: originResult.from,
585
+ $from: originResult?.from,
586
586
  $target: originResult?.target?.id,
587
587
  $share_title: updateResult?.title,
588
588
  $share_path: head(uri),
@@ -1,4 +1,4 @@
1
- import { compareVersion } from '@@/utils/tools';
1
+ import { compareVersion, consoleText } from '@@/utils/tools';
2
2
  import { GrowingIOType } from '@@/types/growingIO';
3
3
  import { isFunction } from '@@/utils/glodash';
4
4
  import BaseImplements from './base';
@@ -93,6 +93,39 @@ class Alipay extends BaseImplements {
93
93
  }
94
94
  return requestTask;
95
95
  };
96
+
97
+ // 执行支付宝特有的promise分享
98
+ handleSharePromise = (originResult, handlePromiseResult) => {
99
+ // 创建监听_result变化的Promise
100
+ const alipayPromise = new Promise((resolve) => {
101
+ // 如果已有_result直接返回
102
+ if (originResult._result) {
103
+ resolve(originResult._result);
104
+ return;
105
+ }
106
+ // 监听_result属性变化
107
+ Object.defineProperty(originResult, '_result', {
108
+ set(value) {
109
+ this.__result = value;
110
+ resolve(value);
111
+ },
112
+ get() {
113
+ return this.__result;
114
+ }
115
+ });
116
+ });
117
+ // 如果三秒内不resolve结果,分享会使用原默认参数
118
+ Promise.race([
119
+ alipayPromise,
120
+ new Promise((resolve) => {
121
+ setTimeout(() => {
122
+ resolve(originResult._result || {});
123
+ }, 3000);
124
+ })
125
+ ])
126
+ .then(handlePromiseResult)
127
+ .catch((error) => consoleText(error, 'error'));
128
+ };
96
129
  }
97
130
 
98
131
  export default Alipay;
@@ -23,7 +23,7 @@ const Config: PlatformConfigType = {
23
23
  'onReachBottom', // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
24
24
  'onResize' // 实际sdk不会执行,但需要写在hook里,防止被归为自定义事件
25
25
  ],
26
- shareEventTypes: ['onShareAppMessage'],
26
+ shareEventTypes: ['onShareAppMessage', 'onShareTimeline', 'onAddToFavorites'],
27
27
  actionEventTypes: [
28
28
  'onclick',
29
29
  'tap',
@@ -1,5 +1,6 @@
1
1
  import { niceTry, getPlainPlatform } from '@@/utils/tools';
2
2
 
3
+ import XHSConfig from './xhs';
3
4
  import JDConfig from './jd';
4
5
  import KSConfig from './ks';
5
6
  import MyConfig from './my';
@@ -12,6 +13,7 @@ import WXConfig from './wx';
12
13
  const plainPlatform = getPlainPlatform();
13
14
  const FrameworkConfig = niceTry(() => {
14
15
  const INST = {
16
+ xhs: XHSConfig,
15
17
  jd: JDConfig,
16
18
  ks: KSConfig,
17
19
  my: MyConfig,
@@ -6,6 +6,7 @@ const MyConfig = {
6
6
  name: 'Alipay',
7
7
  platform: 'alip',
8
8
  scnPrefix: 'alip_',
9
+ shareEventTypes: ['onShareAppMessage'],
9
10
  hooks: {
10
11
  ...BaseConfig?.hooks,
11
12
  Behavior: false
@@ -2,12 +2,19 @@ import BaseConfig from './base';
2
2
 
3
3
  const XHSConfig = {
4
4
  ...BaseConfig,
5
- pageHandlers: [...BaseConfig.pageHandlers, 'onShareChat', 'onCopyUrl'],
6
- shareEventTypes: ['onShareAppMessage', 'onShareChat'],
5
+ pageHandlers: [
6
+ ...BaseConfig.pageHandlers,
7
+ 'onShareChat',
8
+ 'onCopyUrl',
9
+ 'onShareAppMessage',
10
+ 'onShareTimeline'
11
+ ],
12
+ shareEventTypes: [...BaseConfig.shareEventTypes, 'onShareChat', 'onCopyUrl'],
7
13
  listeners: {
8
14
  ...BaseConfig.listeners,
9
15
  page: {
10
16
  ...BaseConfig.listeners.page,
17
+ shareTime: 'onShareTimeline',
11
18
  shareChat: 'onShareChat',
12
19
  copyUrl: 'onCopyUrl'
13
20
  }