@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 +8 -0
- package/docs/api/mixins/webview.md +3 -1
- package/lib/mixins/webview.d.ts +2 -0
- package/lib/mixins/webview.js +12 -1
- package/package.json +2 -2
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
|
|
13
|
+
| `onShow()` | 参数变化后重新生成 url。 |
|
|
14
|
+
| `onReady()` | H5 非 webview 环境通过 `window.addEventListener('message')` 监听宿主消息。 |
|
|
15
|
+
| `onUnload()` | 移除 H5 message 监听,避免内存泄漏。 |
|
|
14
16
|
|
|
15
17
|
## 基本使用
|
|
16
18
|
|
package/lib/mixins/webview.d.ts
CHANGED
package/lib/mixins/webview.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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": "
|
|
49
|
+
"gitHead": "f95a7f2eecf9ddb726ae7f56cf3cda482f7a3947"
|
|
50
50
|
}
|