af-mobile-client-vue3 1.3.37 → 1.3.38
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 +1 -1
- package/src/utils/mobileUtil.ts +13 -8
package/package.json
CHANGED
package/src/utils/mobileUtil.ts
CHANGED
|
@@ -19,15 +19,20 @@ interface Param {
|
|
|
19
19
|
export class mobileUtil {
|
|
20
20
|
// 执行flutter端函数
|
|
21
21
|
static execute(locationParam: Param): any {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
try {
|
|
23
|
+
locationParam.callBackMethodName = `mobile_func_${Math.random().toString(36).substring(7)}`
|
|
24
|
+
if (window.__MICRO_APP_ENVIRONMENT__) {
|
|
25
|
+
console.warn('Page Load in _MICRO_APP_');
|
|
26
|
+
// 微前端应用中需要绑定函数到真实的window中
|
|
27
|
+
(window as any).rawWindow[locationParam.callBackMethodName] = locationParam.callbackFunc
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
window[locationParam.callBackMethodName] = locationParam.callbackFunc
|
|
31
|
+
}
|
|
32
|
+
window[locationParam.funcName].postMessage(JSON.stringify(locationParam))
|
|
27
33
|
}
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
catch (e) {
|
|
35
|
+
locationParam.callbackFunc({ status: 'error', msg: '手机端函数调用失败!!!' })
|
|
30
36
|
}
|
|
31
|
-
window[locationParam.funcName].postMessage(JSON.stringify(locationParam))
|
|
32
37
|
}
|
|
33
38
|
}
|