@zfqh/uniapp 0.1.15 → 0.1.16

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.1.16](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.1.15...@zfqh/uniapp@0.1.16) (2026-06-22)
7
+
8
+ **Note:** Version bump only for package @zfqh/uniapp
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.1.15](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.1.14...@zfqh/uniapp@0.1.15) (2026-06-22)
7
15
 
8
16
  **Note:** Version bump only for package @zfqh/uniapp
@@ -10,7 +10,9 @@ webview 承载页 mixin。发布路径:`@zfqh/uniapp/lib/mixins/webview`
10
10
  | `method postMessage(data)` | 向 iframe/App webview 子页面发送 WEBVIEW_MESSAGE。 |
11
11
  | `method initUrl()` | 根据 params.url、link、web 配置生成实际 webview src。 |
12
12
  | `onLoad(params)` | 保存初始 params。 |
13
- | `onShow()` | 参数变化后重新生成 url,并在 H5 非 webview 环境监听 window.onmessage。 |
13
+ | `onShow()` | 参数变化后重新生成 url。 |
14
+ | `onReady()` | H5 非 webview 环境通过 `window.addEventListener('message')` 监听宿主消息。 |
15
+ | `onUnload()` | 移除 H5 message 监听,避免内存泄漏。 |
14
16
 
15
17
  ## 基本使用
16
18
 
@@ -20,5 +20,7 @@ declare const _default: {
20
20
  };
21
21
  onLoad(params: any): void;
22
22
  onShow(): void;
23
+ onReady(): void;
24
+ onUnload(): void;
23
25
  };
24
26
  export default _default;
@@ -206,9 +206,11 @@ export default {
206
206
  this.changed = false;
207
207
  }
208
208
  });
209
+ },
210
+ onReady() {
209
211
  // #ifdef H5
210
212
  if (!IS_WEBVIEW_ENV) {
211
- window.onmessage = (e) => {
213
+ this.__onWindowMessage = (e) => {
212
214
  try {
213
215
  if (e.data.type === 'WEBVIEW_APP_MESSAGE') {
214
216
  this.onMessage({ detail: { data: [e.data.data] } });
@@ -216,6 +218,15 @@ export default {
216
218
  }
217
219
  catch (e) { }
218
220
  };
221
+ window.addEventListener('message', this.__onWindowMessage);
222
+ }
223
+ // #endif
224
+ },
225
+ onUnload() {
226
+ // #ifdef H5
227
+ if (this.__onWindowMessage) {
228
+ window.removeEventListener('message', this.__onWindowMessage);
229
+ this.__onWindowMessage = null;
219
230
  }
220
231
  // #endif
221
232
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zfqh/uniapp",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "uniapp公共模块",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -46,5 +46,5 @@
46
46
  "@types/qs": "^6.9.16",
47
47
  "@types/url-parse": "^1.4.11"
48
48
  },
49
- "gitHead": "b926cc2bedd57fb55c2ad7ab90b9c5c88148c39a"
49
+ "gitHead": "f95a7f2eecf9ddb726ae7f56cf3cda482f7a3947"
50
50
  }