@skyfox2000/webui 1.4.2 → 1.4.3
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/lib/assets/modules/{baseLayout-CeyN__cz.js → baseLayout-C92mDmCL.js} +3 -3
- package/lib/assets/modules/{file-upload-DiUcAspb.js → file-upload-DGCoBLP3.js} +1 -1
- package/lib/assets/modules/{index-DbgSOuIs.js → index-BrDxf94o.js} +1 -1
- package/lib/assets/modules/{index-C5X-1A4m.js → index-C_7galsG.js} +2 -2
- package/lib/assets/modules/{index-YIIA7qm8.js → index-ChjM1bSE.js} +2 -2
- package/lib/assets/modules/{menuTabs-hVwE4xrx.js → menuTabs-Boe_4pzK.js} +2 -2
- package/lib/assets/modules/{toolIcon-BHWHHyOp.js → toolIcon-BddslNsJ.js} +1 -1
- package/lib/assets/modules/{uploadList-1qFfdb6_.js → uploadList-3sClH7Na.js} +4 -4
- package/lib/assets/modules/{uploadList-EbG8acej.js → uploadList-ZGWKyite.js} +218 -216
- package/lib/es/AceEditor/index.js +3 -3
- package/lib/es/BasicLayout/index.js +2 -2
- package/lib/es/Error403/index.js +1 -1
- package/lib/es/Error404/index.js +1 -1
- package/lib/es/ExcelForm/index.js +5 -5
- package/lib/es/MenuLayout/index.js +2 -2
- package/lib/es/UploadForm/index.js +4 -4
- package/lib/utils/micro-openapis.d.ts +23 -10
- package/lib/webui.es.js +12 -12
- package/package.json +2 -2
- package/src/utils/micro-openapis.ts +108 -86
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { defineComponent as F, defineAsyncComponent as M, ref as m, watch as V, onMounted as J, createElementBlock as x, openBlock as p, Fragment as K, createElementVNode as v, createVNode as _, toDisplayString as W, unref as i, createBlock as P, withKeys as f, normalizeClass as N, withModifiers as w, withCtx as z, createCommentVNode as L } from "vue";
|
|
2
2
|
import "ant-design-vue";
|
|
3
|
-
import { _ as q } from "../../assets/modules/toolIcon-
|
|
3
|
+
import { _ as q } from "../../assets/modules/toolIcon-BddslNsJ.js";
|
|
4
4
|
import "@skyfox2000/fapi";
|
|
5
|
-
import "../../assets/modules/uploadList-
|
|
5
|
+
import "../../assets/modules/uploadList-ZGWKyite.js";
|
|
6
6
|
import "@skyfox2000/microbase";
|
|
7
7
|
import "vue-m-message";
|
|
8
8
|
import "async-validator";
|
|
9
9
|
import "dayjs";
|
|
10
|
-
import { _ as D } from "../../assets/modules/index-
|
|
10
|
+
import { _ as D } from "../../assets/modules/index-C_7galsG.js";
|
|
11
11
|
import "vue-draggable-next";
|
|
12
12
|
const h = async (s) => window.ace ? window.ace : new Promise((l, t) => {
|
|
13
13
|
const o = document.createElement("script");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as f, ref as d, watch as _, onMounted as v, resolveComponent as h, createBlock as o, openBlock as t, withCtx as s, createElementVNode as C, normalizeClass as x, createVNode as w, KeepAlive as y, unref as n, resolveDynamicComponent as I } from "vue";
|
|
2
|
-
import { _ as g } from "../../assets/modules/baseLayout-
|
|
3
|
-
import { af as A, a as S } from "../../assets/modules/uploadList-
|
|
2
|
+
import { _ as g } from "../../assets/modules/baseLayout-C92mDmCL.js";
|
|
3
|
+
import { af as A, a as S } from "../../assets/modules/uploadList-ZGWKyite.js";
|
|
4
4
|
import "@skyfox2000/microbase";
|
|
5
5
|
import "@skyfox2000/fapi";
|
|
6
6
|
import b from "vue-m-message";
|
package/lib/es/Error403/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as i, createBlock as p, openBlock as m, unref as r, withCtx as e, createVNode as n, createTextVNode as a } from "vue";
|
|
2
|
-
import { r as s } from "../../assets/modules/uploadList-
|
|
2
|
+
import { r as s } from "../../assets/modules/uploadList-ZGWKyite.js";
|
|
3
3
|
import "@skyfox2000/microbase";
|
|
4
4
|
import "@skyfox2000/fapi";
|
|
5
5
|
import "vue-m-message";
|
package/lib/es/Error404/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as i, createBlock as p, openBlock as m, unref as r, withCtx as e, createVNode as n, createTextVNode as a } from "vue";
|
|
2
|
-
import { r as s } from "../../assets/modules/uploadList-
|
|
2
|
+
import { r as s } from "../../assets/modules/uploadList-ZGWKyite.js";
|
|
3
3
|
import "@skyfox2000/microbase";
|
|
4
4
|
import "@skyfox2000/fapi";
|
|
5
5
|
import "vue-m-message";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { defineComponent as we, ref as f, computed as T, watch as W, onMounted as be, createBlock as H, openBlock as d, unref as n, withCtx as S, renderSlot as J, createElementBlock as g, createCommentVNode as K, createElementVNode as h, createVNode as C, createTextVNode as X, toDisplayString as E, normalizeClass as Ce, Fragment as ie, renderList as ne } from "vue";
|
|
2
|
-
import { _ as Y } from "../../assets/modules/index-
|
|
2
|
+
import { _ as Y } from "../../assets/modules/index-BrDxf94o.js";
|
|
3
3
|
import { Modal as Fe, Upload as ue, Space as _e } from "ant-design-vue";
|
|
4
4
|
import { httpGet as Ue, ResStatus as fe } from "@skyfox2000/fapi";
|
|
5
|
-
import { E as Te, a2 as Se, a8 as Ee } from "../../assets/modules/uploadList-
|
|
6
|
-
import { A as Re, p as De, U as ce } from "../../assets/modules/file-upload-
|
|
5
|
+
import { E as Te, a2 as Se, a8 as Ee } from "../../assets/modules/uploadList-ZGWKyite.js";
|
|
6
|
+
import { A as Re, p as De, U as ce } from "../../assets/modules/file-upload-DGCoBLP3.js";
|
|
7
7
|
import "@skyfox2000/microbase";
|
|
8
8
|
import p from "vue-m-message";
|
|
9
|
-
import { c as ke, _ as Z, h as Le, p as Ne, i as Ke } from "../../assets/modules/index-
|
|
9
|
+
import { c as ke, _ as Z, h as Le, p as Ne, i as Ke } from "../../assets/modules/index-ChjM1bSE.js";
|
|
10
10
|
import "dayjs";
|
|
11
11
|
import "vue-draggable-next";
|
|
12
12
|
import "async-validator";
|
|
@@ -306,7 +306,7 @@ const Be = (l) => l.includes(",") || l.includes(`
|
|
|
306
306
|
return p.error(v), ue.LIST_IGNORE;
|
|
307
307
|
try {
|
|
308
308
|
if (A(), y.value = t.name, q.value = u ? "text/csv" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", u) {
|
|
309
|
-
const w = await t.arrayBuffer(), O = new TextDecoder("utf-8").decode(w), { csvToExcelView: G } = await import("../../assets/modules/index-
|
|
309
|
+
const w = await t.arrayBuffer(), O = new TextDecoder("utf-8").decode(w), { csvToExcelView: G } = await import("../../assets/modules/index-ChjM1bSE.js").then((he) => he.j), M = await G(O, t.name);
|
|
310
310
|
if (!M.success)
|
|
311
311
|
throw new Error(M.error || "CSV文件处理失败");
|
|
312
312
|
const oe = await (await fetch(M.blobUrl)).arrayBuffer();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as f, ref as d, watch as _, onMounted as v, resolveComponent as h, createBlock as o, openBlock as t, withCtx as s, createElementVNode as C, normalizeClass as x, createVNode as w, KeepAlive as I, unref as n, resolveDynamicComponent as g } from "vue";
|
|
2
|
-
import { _ as y } from "../../assets/modules/baseLayout-
|
|
3
|
-
import { af as A, a as S } from "../../assets/modules/uploadList-
|
|
2
|
+
import { _ as y } from "../../assets/modules/baseLayout-C92mDmCL.js";
|
|
3
|
+
import { af as A, a as S } from "../../assets/modules/uploadList-ZGWKyite.js";
|
|
4
4
|
import "@skyfox2000/microbase";
|
|
5
5
|
import "@skyfox2000/fapi";
|
|
6
6
|
import k from "vue-m-message";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { defineComponent as y, ref as f, watch as S, onMounted as z, createBlock as D, openBlock as F, unref as u, withCtx as s, createVNode as m, createTextVNode as C } from "vue";
|
|
2
|
-
import { _ as c } from "../../assets/modules/index-
|
|
2
|
+
import { _ as c } from "../../assets/modules/index-BrDxf94o.js";
|
|
3
3
|
import { Modal as _, Space as k } from "ant-design-vue";
|
|
4
4
|
import { ResStatus as E } from "@skyfox2000/fapi";
|
|
5
|
-
import { a4 as h } from "../../assets/modules/uploadList-
|
|
5
|
+
import { a4 as h } from "../../assets/modules/uploadList-ZGWKyite.js";
|
|
6
6
|
import "@skyfox2000/microbase";
|
|
7
7
|
import L from "vue-m-message";
|
|
8
8
|
import "async-validator";
|
|
9
9
|
import "dayjs";
|
|
10
|
-
import { A as N } from "../../assets/modules/file-upload-
|
|
10
|
+
import { A as N } from "../../assets/modules/file-upload-DGCoBLP3.js";
|
|
11
11
|
import "vue-draggable-next";
|
|
12
|
-
import { U as B } from "../../assets/modules/uploadList-
|
|
12
|
+
import { U as B } from "../../assets/modules/uploadList-3sClH7Na.js";
|
|
13
13
|
const K = /* @__PURE__ */ y({
|
|
14
14
|
__name: "uploadForm",
|
|
15
15
|
props: {
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
declare class MicroAppSDK {
|
|
2
|
+
private static messageId;
|
|
3
|
+
private static callbacks;
|
|
4
|
+
static isInMicroApp(): boolean;
|
|
5
|
+
private static callMainAppMethod;
|
|
6
|
+
static handleResponseData(data: any): void;
|
|
7
|
+
static init(): void;
|
|
8
|
+
static getAppInfo(): Promise<any>;
|
|
9
|
+
static getHostInfo(): Promise<any>;
|
|
10
|
+
static getUserInfo(): Promise<any>;
|
|
11
|
+
static getToken(): Promise<any>;
|
|
12
|
+
static userLogout(): Promise<any>;
|
|
13
|
+
static mainAppPush(params: any): Promise<any>;
|
|
14
|
+
}
|
|
15
|
+
export declare const MicroOpenApis: {
|
|
16
|
+
getAppInfo: typeof MicroAppSDK.getAppInfo;
|
|
17
|
+
getHostInfo: typeof MicroAppSDK.getHostInfo;
|
|
18
|
+
getUserInfo: typeof MicroAppSDK.getUserInfo;
|
|
19
|
+
getToken: typeof MicroAppSDK.getToken;
|
|
20
|
+
userLogout: typeof MicroAppSDK.userLogout;
|
|
21
|
+
mainAppPush: typeof MicroAppSDK.mainAppPush;
|
|
22
|
+
isInMicroApp: typeof MicroAppSDK.isInMicroApp;
|
|
10
23
|
};
|
|
11
|
-
export {
|
|
24
|
+
export {};
|
package/lib/webui.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as Ee, i as Z, a as me, L as Xe, c as Ze, P as j, o as Pe, b as ea, d as aa, e as Fe, r as ce, f as ta, g as la, h as Ne, j as sa, k as ke, l as ra, _ as oa, m as na, O as Me, q as Be, n as ia, p as ca, s as L, t as ua, v as da, w as pa, x as fa, y as va, z as ma, A as Y, B as ha, C as ga, D as ba, E as Re } from "./assets/modules/uploadList-
|
|
2
|
-
import { aa as $l, Q as Il, ac as Dl, R as El, V as Pl, a9 as Fl, a7 as Nl, a8 as Ml, ab as Bl, Y as Rl, T as Ol, a5 as Al, a2 as Ll, M as zl, a4 as Ul, U as Vl, G as Yl, $ as Kl, a3 as Wl, a6 as Hl, N as jl, S as Ql, ad as ql, F as Gl, a1 as Jl, ae as Xl, X as Zl, Z as es, W as as, af as ts, H as ls, I as ss, ag as rs, K as os, ah as ns, J as is, a0 as cs } from "./assets/modules/uploadList-
|
|
3
|
-
import { A as ds, U as ps, p as fs } from "./assets/modules/file-upload-
|
|
1
|
+
import { u as Ee, i as Z, a as me, L as Xe, c as Ze, P as j, o as Pe, b as ea, d as aa, e as Fe, r as ce, f as ta, g as la, h as Ne, j as sa, k as ke, l as ra, _ as oa, m as na, O as Me, q as Be, n as ia, p as ca, s as L, t as ua, v as da, w as pa, x as fa, y as va, z as ma, A as Y, B as ha, C as ga, D as ba, E as Re } from "./assets/modules/uploadList-ZGWKyite.js";
|
|
2
|
+
import { aa as $l, Q as Il, ac as Dl, R as El, V as Pl, a9 as Fl, a7 as Nl, a8 as Ml, ab as Bl, Y as Rl, T as Ol, a5 as Al, a2 as Ll, M as zl, a4 as Ul, U as Vl, G as Yl, $ as Kl, a3 as Wl, a6 as Hl, N as jl, S as Ql, ad as ql, F as Gl, a1 as Jl, ae as Xl, X as Zl, Z as es, W as as, af as ts, H as ls, I as ss, ag as rs, K as os, ah as ns, J as is, a0 as cs } from "./assets/modules/uploadList-ZGWKyite.js";
|
|
3
|
+
import { A as ds, U as ps, p as fs } from "./assets/modules/file-upload-DGCoBLP3.js";
|
|
4
4
|
import { EnvConfig as we } from "@skyfox2000/microbase";
|
|
5
5
|
import { FrontCache as re, httpPost as Oe, ResStatus as Ae, SERVER_HOST as _a, fieldMapping as oe } from "@skyfox2000/fapi";
|
|
6
6
|
import he from "vue-m-message";
|
|
@@ -9,15 +9,15 @@ import "async-validator";
|
|
|
9
9
|
import fe from "dayjs";
|
|
10
10
|
import { Popover as Ca, theme as ze, Drawer as Ta, Space as te, Form as Ue, message as $a, FormItem as Ve, ConfigProvider as Ce, Popconfirm as Ia, Button as Ye, DropdownButton as Da, Menu as _e, MenuItem as xe, Dropdown as ve, Checkbox as Ea, Table as Ke, Tree as Pa, Cascader as Fa, DatePicker as Na, Input as ee, InputPassword as Ma, InputNumber as Ba, RangePicker as Ra, Textarea as Oa, TimePicker as Aa, Transfer as La, TreeSelect as za, LayoutContent as Ua } from "ant-design-vue";
|
|
11
11
|
import { VueDraggableNext as Va } from "vue-draggable-next";
|
|
12
|
-
import { d as We } from "./assets/modules/uploadList-
|
|
13
|
-
import { C as ms, U as hs, a as gs, p as bs } from "./assets/modules/uploadList-
|
|
14
|
-
import { c as He } from "./assets/modules/index-
|
|
15
|
-
import { _ as xs, h as ys, b as ks, a as ws, d as Ss, e as Cs, g as Ts, f as $s, n as Is, p as Ds, t as Es, v as Ps } from "./assets/modules/index-
|
|
16
|
-
import { _ as A } from "./assets/modules/index-
|
|
17
|
-
import { _ as U } from "./assets/modules/toolIcon-
|
|
18
|
-
import { a as Ns } from "./assets/modules/toolIcon-
|
|
19
|
-
import { _ as Bs, b as Rs, c as Os, d as As, e as Ls, I as zs, f as Us, g as Vs, a as Ys } from "./assets/modules/menuTabs-
|
|
20
|
-
import { _ as Ws } from "./assets/modules/index-
|
|
12
|
+
import { d as We } from "./assets/modules/uploadList-3sClH7Na.js";
|
|
13
|
+
import { C as ms, U as hs, a as gs, p as bs } from "./assets/modules/uploadList-3sClH7Na.js";
|
|
14
|
+
import { c as He } from "./assets/modules/index-ChjM1bSE.js";
|
|
15
|
+
import { _ as xs, h as ys, b as ks, a as ws, d as Ss, e as Cs, g as Ts, f as $s, n as Is, p as Ds, t as Es, v as Ps } from "./assets/modules/index-ChjM1bSE.js";
|
|
16
|
+
import { _ as A } from "./assets/modules/index-BrDxf94o.js";
|
|
17
|
+
import { _ as U } from "./assets/modules/toolIcon-BddslNsJ.js";
|
|
18
|
+
import { a as Ns } from "./assets/modules/toolIcon-BddslNsJ.js";
|
|
19
|
+
import { _ as Bs, b as Rs, c as Os, d as As, e as Ls, I as zs, f as Us, g as Vs, a as Ys } from "./assets/modules/menuTabs-Boe_4pzK.js";
|
|
20
|
+
import { _ as Ws } from "./assets/modules/index-C_7galsG.js";
|
|
21
21
|
import { _ as q } from "./assets/modules/_plugin-vue_export-helper-CHgC5LLL.js";
|
|
22
22
|
const Te = (s, a, e, t = "remove") => {
|
|
23
23
|
if (!e)
|
package/package.json
CHANGED
|
@@ -1,145 +1,167 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 微前端通信工具
|
|
3
|
+
* 提供与主应用的通信接口,基于micro-app框架
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
//
|
|
6
|
-
interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
userLogin: (params: any) => Promise<any>;
|
|
12
|
-
userLogout: () => Promise<any>;
|
|
13
|
-
mainAppPush: (params: any) => Promise<any>;
|
|
6
|
+
// 定义请求数据格式
|
|
7
|
+
interface ApiRequestData {
|
|
8
|
+
type: 'API_REQUEST';
|
|
9
|
+
id: number;
|
|
10
|
+
method: string;
|
|
11
|
+
params?: any;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
//
|
|
17
|
-
|
|
14
|
+
// 定义响应数据格式
|
|
15
|
+
interface ApiResponseData {
|
|
16
|
+
type: 'API_RESPONSE';
|
|
17
|
+
id: number;
|
|
18
|
+
success: boolean;
|
|
19
|
+
result?: any;
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
18
22
|
|
|
19
|
-
/**
|
|
20
|
-
* MicroAppSDK类 - 管理与主应用的通信
|
|
21
|
-
*/
|
|
22
23
|
class MicroAppSDK {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
24
|
+
private static messageId = 0;
|
|
25
|
+
private static callbacks = new Map<number, { resolve: Function; reject: Function }>();
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 检查是否在微前端环境中运行
|
|
29
|
+
* @returns boolean
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
throw new Error('MicroAppSDK can only be used in browser environment');
|
|
33
|
-
}
|
|
31
|
+
static isInMicroApp(): boolean {
|
|
32
|
+
return typeof window !== 'undefined' && !!(window as any).microApp;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
36
|
+
* 调用主应用方法的通用方法
|
|
37
|
+
* @param method 方法名
|
|
38
|
+
* @param params 参数
|
|
39
|
+
* @returns Promise
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
private static async callMainAppMethod(method: string, params?: any): Promise<any> {
|
|
42
|
+
// 检查是否在微前端环境中
|
|
43
|
+
if (!this.isInMicroApp()) {
|
|
44
|
+
throw new Error(`未配置${method}接口!`);
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
|
|
47
|
+
// 生成唯一消息ID
|
|
48
|
+
const id = ++this.messageId;
|
|
49
|
+
|
|
50
|
+
// 创建Promise并保存回调
|
|
51
|
+
const promise = new Promise((resolve, reject) => {
|
|
52
|
+
this.callbacks.set(id, { resolve, reject });
|
|
53
|
+
|
|
54
|
+
// 设置超时
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
if (this.callbacks.has(id)) {
|
|
57
|
+
this.callbacks.delete(id);
|
|
58
|
+
reject(new Error(`API调用超时: ${method}`));
|
|
59
|
+
}
|
|
60
|
+
}, 10000); // 10秒超时
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// 构造请求数据
|
|
64
|
+
const requestData: ApiRequestData = {
|
|
65
|
+
type: 'API_REQUEST',
|
|
66
|
+
id,
|
|
67
|
+
method,
|
|
68
|
+
params,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// 发送数据到主应用(使用micro-app的dispatch方法)
|
|
72
|
+
(window as any).microApp.dispatch(requestData);
|
|
73
|
+
|
|
74
|
+
// 等待结果
|
|
75
|
+
return promise;
|
|
45
76
|
}
|
|
46
77
|
|
|
47
78
|
/**
|
|
48
|
-
*
|
|
79
|
+
* 处理来自主应用的响应数据
|
|
80
|
+
* @param data 响应数据
|
|
49
81
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
static handleResponseData(data: any) {
|
|
83
|
+
// 检查是否为API响应
|
|
84
|
+
if (data && data.type === 'API_RESPONSE' && typeof data.id === 'number') {
|
|
85
|
+
const { id, success, result, error } = data as ApiResponseData;
|
|
86
|
+
const callback = this.callbacks.get(id);
|
|
87
|
+
|
|
88
|
+
if (callback) {
|
|
89
|
+
this.callbacks.delete(id);
|
|
90
|
+
if (success) {
|
|
91
|
+
callback.resolve(result);
|
|
92
|
+
} else {
|
|
93
|
+
callback.reject(new Error(error || '未知错误'));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
52
97
|
}
|
|
53
98
|
|
|
54
99
|
/**
|
|
55
|
-
*
|
|
100
|
+
* 初始化通信监听器
|
|
56
101
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
throw new Error(`Main API method '${methodName}' is not available`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
if (params !== undefined) {
|
|
69
|
-
return await method(params);
|
|
70
|
-
} else {
|
|
71
|
-
return await method();
|
|
72
|
-
}
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.error(`Failed to call main API '${methodName}':`, error);
|
|
75
|
-
throw error;
|
|
102
|
+
static init() {
|
|
103
|
+
if (this.isInMicroApp()) {
|
|
104
|
+
// 添加监听器
|
|
105
|
+
(window as any).microApp.addDataListener((data: any) => {
|
|
106
|
+
console.log('收到来自主应用的数据:', data);
|
|
107
|
+
this.handleResponseData(data);
|
|
108
|
+
});
|
|
76
109
|
}
|
|
77
110
|
}
|
|
78
111
|
|
|
79
112
|
/**
|
|
80
113
|
* 获取应用信息
|
|
81
114
|
*/
|
|
82
|
-
async getAppInfo(): Promise<any> {
|
|
83
|
-
return this.
|
|
115
|
+
static async getAppInfo(): Promise<any> {
|
|
116
|
+
return this.callMainAppMethod('getAppInfo');
|
|
84
117
|
}
|
|
85
118
|
|
|
86
119
|
/**
|
|
87
120
|
* 获取主机信息
|
|
88
121
|
*/
|
|
89
|
-
async getHostInfo(): Promise<any> {
|
|
90
|
-
return this.
|
|
122
|
+
static async getHostInfo(): Promise<any> {
|
|
123
|
+
return this.callMainAppMethod('getHostInfo');
|
|
91
124
|
}
|
|
92
125
|
|
|
93
126
|
/**
|
|
94
127
|
* 获取用户信息
|
|
95
128
|
*/
|
|
96
|
-
async getUserInfo(): Promise<any> {
|
|
97
|
-
return this.
|
|
129
|
+
static async getUserInfo(): Promise<any> {
|
|
130
|
+
return this.callMainAppMethod('getUserInfo');
|
|
98
131
|
}
|
|
99
132
|
|
|
100
133
|
/**
|
|
101
134
|
* 获取授权令牌
|
|
102
135
|
*/
|
|
103
|
-
async getToken(): Promise<any> {
|
|
104
|
-
return this.
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* 用户登录
|
|
109
|
-
*/
|
|
110
|
-
async userLogin(params: any): Promise<any> {
|
|
111
|
-
return this.callMainApi('userLogin', params);
|
|
136
|
+
static async getToken(): Promise<any> {
|
|
137
|
+
return this.callMainAppMethod('getToken');
|
|
112
138
|
}
|
|
113
139
|
|
|
114
140
|
/**
|
|
115
141
|
* 用户登出
|
|
116
142
|
*/
|
|
117
|
-
async userLogout(): Promise<any> {
|
|
118
|
-
return this.
|
|
143
|
+
static async userLogout(): Promise<any> {
|
|
144
|
+
return this.callMainAppMethod('userLogout');
|
|
119
145
|
}
|
|
120
146
|
|
|
121
147
|
/**
|
|
122
148
|
* 主应用推送
|
|
123
149
|
*/
|
|
124
|
-
async mainAppPush(params: any): Promise<any> {
|
|
125
|
-
return this.
|
|
150
|
+
static async mainAppPush(params: any): Promise<any> {
|
|
151
|
+
return this.callMainAppMethod('mainAppPush', params);
|
|
126
152
|
}
|
|
127
153
|
}
|
|
128
154
|
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// 统一导出对象
|
|
133
|
-
const MicroOpenApis = {
|
|
134
|
-
getAppInfo: microAppSDKInstance.getAppInfo.bind(microAppSDKInstance),
|
|
135
|
-
getHostInfo: microAppSDKInstance.getHostInfo.bind(microAppSDKInstance),
|
|
136
|
-
getUserInfo: microAppSDKInstance.getUserInfo.bind(microAppSDKInstance),
|
|
137
|
-
getToken: microAppSDKInstance.getToken.bind(microAppSDKInstance),
|
|
138
|
-
userLogin: microAppSDKInstance.userLogin.bind(microAppSDKInstance),
|
|
139
|
-
userLogout: microAppSDKInstance.userLogout.bind(microAppSDKInstance),
|
|
140
|
-
mainAppPush: microAppSDKInstance.mainAppPush.bind(microAppSDKInstance),
|
|
141
|
-
isInMicroApp: microAppSDKInstance.isInMicroApp.bind(microAppSDKInstance),
|
|
142
|
-
};
|
|
155
|
+
// 初始化通信监听器
|
|
156
|
+
MicroAppSDK.init();
|
|
143
157
|
|
|
144
158
|
// 导出统一对象
|
|
145
|
-
export
|
|
159
|
+
export const MicroOpenApis = {
|
|
160
|
+
getAppInfo: MicroAppSDK.getAppInfo.bind(MicroAppSDK),
|
|
161
|
+
getHostInfo: MicroAppSDK.getHostInfo.bind(MicroAppSDK),
|
|
162
|
+
getUserInfo: MicroAppSDK.getUserInfo.bind(MicroAppSDK),
|
|
163
|
+
getToken: MicroAppSDK.getToken.bind(MicroAppSDK),
|
|
164
|
+
userLogout: MicroAppSDK.userLogout.bind(MicroAppSDK),
|
|
165
|
+
mainAppPush: MicroAppSDK.mainAppPush.bind(MicroAppSDK),
|
|
166
|
+
isInMicroApp: MicroAppSDK.isInMicroApp.bind(MicroAppSDK),
|
|
167
|
+
};
|