@tmsfe/tms-core 0.0.77 → 0.0.78

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.77",
3
+ "version": "0.0.78",
4
4
  "description": "tms运行时框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -139,9 +139,41 @@ function proxyNavigateApi(api: string): void {
139
139
  });
140
140
  }
141
141
 
142
+ // 劫持消息订阅接口
143
+ function proxySubscribeMessage(): void {
144
+ const originalApi = wx.requestSubscribeMessage;
145
+ Object.defineProperty(wx, 'requestSubscribeMessage', {
146
+ writable: true,
147
+ enumerable: true,
148
+ configurable: true,
149
+ value(options: any) {
150
+ const { tmplIds } = options;
151
+ const originalSuccess = options.success || helper.emptyFunc;
152
+ const originalFail = options.fail || helper.emptyFunc;
153
+ // eslint-disable-next-line
154
+ options.success = function(res: any) {
155
+ for (const tmplId of tmplIds) {
156
+ const result = res[tmplId];
157
+ if (result) {
158
+ helper.reportData('wx_requestSubscribeMessage_result', tmplId, result);
159
+ }
160
+ }
161
+ originalSuccess.call(this, res);
162
+ };
163
+ // eslint-disable-next-line
164
+ options.fail = function(err: any) {
165
+ helper.reportData('wx_requestSubscribeMessage_fail', tmplIds, err.errMsg);
166
+ originalFail.fail(this, err);
167
+ };
168
+ originalApi.call(this, options);
169
+ },
170
+ });
171
+ }
172
+
142
173
  // 劫持Page
143
174
  function init(): void {
144
175
  proxyPage();
176
+ proxySubscribeMessage();
145
177
  proxyNavigateApi('navigateTo');
146
178
  proxyNavigateApi('redirectTo');
147
179
  proxyNavigateApi('reLaunch');