@zfqh/uniapp 0.2.4 → 0.2.6

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,22 @@
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.2.6](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.5...@zfqh/uniapp@0.2.6) (2026-06-23)
7
+
8
+ **Note:** Version bump only for package @zfqh/uniapp
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.2.5](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.4...@zfqh/uniapp@0.2.5) (2026-06-23)
15
+
16
+ **Note:** Version bump only for package @zfqh/uniapp
17
+
18
+
19
+
20
+
21
+
6
22
  ## [0.2.4](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.3...@zfqh/uniapp@0.2.4) (2026-06-23)
7
23
 
8
24
  **Note:** Version bump only for package @zfqh/uniapp
@@ -7,7 +7,6 @@ declare const _default: {
7
7
  webview: boolean;
8
8
  };
9
9
  computed: {
10
- loginInfo(): any;
11
10
  queryString(): string;
12
11
  };
13
12
  watch: {
@@ -19,11 +19,8 @@ export default {
19
19
  };
20
20
  },
21
21
  computed: {
22
- loginInfo() {
23
- return this.$store.state.login?.info || {};
24
- },
25
22
  queryString() {
26
- const { accessToken, storeId, userId, tenantId, storeName, tenantName, nickName, username, } = this.loginInfo;
23
+ const { accessToken, storeId, userId, tenantId, storeName, tenantName, nickName, username, } = this.$store.state.login?.info || {};
27
24
  const q = {
28
25
  token: accessToken,
29
26
  storeId,
@@ -134,15 +131,19 @@ export default {
134
131
  try {
135
132
  if (!this.__webView) {
136
133
  // #ifdef H5
137
- this.__webView = document.querySelector('iframe')?.contentWindow;
134
+ let ele = this.$el;
135
+ if (ele.tagName !== 'IFRAME') {
136
+ ele = this.$el.querySelector?.('iframe') || document.querySelector('iframe');
137
+ }
138
+ this.__webView = ele?.contentWindow;
138
139
  this.__postMessage = (data) => {
139
- this.__webView.postMessage({ type: 'WEBVIEW_MESSAGE', data }, '*');
140
+ this.__webView?.postMessage({ type: 'WEBVIEW_MESSAGE', data }, '*');
140
141
  };
141
142
  // #endif
142
143
  // #ifdef APP-PLUS
143
144
  this.__webView = this.$scope.$getAppWebview().children()[0];
144
145
  this.__postMessage = (data) => {
145
- this.__webView.evalJS(`window.onmessage({ data: { type: 'WEBVIEW_MESSAGE', data: ${JSON.stringify(data)} } })`);
146
+ this.__webView?.evalJS(`window.onmessage({ data: { type: 'WEBVIEW_MESSAGE', data: ${JSON.stringify(data)} } })`);
146
147
  };
147
148
  // #endif
148
149
  }
@@ -226,6 +227,23 @@ export default {
226
227
  if (e.data.type === 'WEBVIEW_APP_MESSAGE') {
227
228
  this.onMessage({ detail: { data: [e.data.data] } });
228
229
  }
230
+ else if (e.data.type === 'WEB_INVOKE_APPSERVICE') {
231
+ // webview页面自定义iframe,嵌套页面中调用uni.webView[xx](),必须实现如下功能,否则无效
232
+ if (this.__iframe == null) {
233
+ if (this.$el.tagName === 'IFRAME' || this.$el.querySelector?.('iframe')) {
234
+ this.__iframe = true;
235
+ }
236
+ else {
237
+ this.__iframe = false;
238
+ }
239
+ }
240
+ if (this.__iframe) {
241
+ const { name, arg } = e.data.data || {};
242
+ if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab', 'navigateBack'].includes(name)) {
243
+ uni[name](arg);
244
+ }
245
+ }
246
+ }
229
247
  }
230
248
  catch (e) { }
231
249
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zfqh/uniapp",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
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": "515cf9d5d8d76b10180fbd117d56f798b5c89bcb"
49
+ "gitHead": "d2abc06f15cf1915b7c24dd3006360a49ab5752c"
50
50
  }