@skyfox2000/webui 1.4.2 → 1.4.4
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-CYzXPj7i.js} +3 -3
- package/lib/assets/modules/{file-upload-DiUcAspb.js → file-upload-Dmi2Kiqo.js} +27 -28
- package/lib/assets/modules/{index-YIIA7qm8.js → index-1Qt9-aFa.js} +2 -2
- package/lib/assets/modules/{index-DbgSOuIs.js → index-QDkmhaJS.js} +1 -1
- package/lib/assets/modules/{index-C5X-1A4m.js → index-RrFsG5IK.js} +2 -2
- package/lib/assets/modules/{menuTabs-hVwE4xrx.js → menuTabs-sfALzkA5.js} +56 -56
- package/lib/assets/modules/{toolIcon-BHWHHyOp.js → toolIcon-C6QsaAZ8.js} +1 -1
- package/lib/assets/modules/{uploadList-1qFfdb6_.js → uploadList-Bh1TJ-XO.js} +4 -4
- package/lib/assets/modules/{uploadList-EbG8acej.js → uploadList-C4BvnORD.js} +281 -279
- 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/stores/hostInfo.d.ts +2 -2
- package/lib/utils/micro-openapis.d.ts +24 -10
- package/lib/webui.es.js +12 -12
- package/package.json +2 -2
- package/src/components/layout/header/headerExits.vue +4 -4
- package/src/stores/appInfo.ts +5 -5
- package/src/stores/hostInfo.ts +6 -5
- package/src/utils/file-upload.ts +4 -3
- package/src/utils/micro-openapis.ts +110 -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-C6QsaAZ8.js";
|
|
4
4
|
import "@skyfox2000/fapi";
|
|
5
|
-
import "../../assets/modules/uploadList-
|
|
5
|
+
import "../../assets/modules/uploadList-C4BvnORD.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-RrFsG5IK.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-CYzXPj7i.js";
|
|
3
|
+
import { af as A, a as S } from "../../assets/modules/uploadList-C4BvnORD.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-C4BvnORD.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-C4BvnORD.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-QDkmhaJS.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-C4BvnORD.js";
|
|
6
|
+
import { A as Re, p as De, U as ce } from "../../assets/modules/file-upload-Dmi2Kiqo.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-1Qt9-aFa.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-1Qt9-aFa.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-CYzXPj7i.js";
|
|
3
|
+
import { af as A, a as S } from "../../assets/modules/uploadList-C4BvnORD.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-QDkmhaJS.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-C4BvnORD.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-Dmi2Kiqo.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-Bh1TJ-XO.js";
|
|
13
13
|
const K = /* @__PURE__ */ y({
|
|
14
14
|
__name: "uploadForm",
|
|
15
15
|
props: {
|
package/lib/stores/hostInfo.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { HostInfo
|
|
1
|
+
import { HostInfo } from '../../../502424_MicroBase';
|
|
2
2
|
import { StoreDefinition } from 'pinia';
|
|
3
3
|
export declare const useHostInfo: StoreDefinition<"hostInfo", {
|
|
4
4
|
hostInfo: HostInfo;
|
|
5
5
|
}, {}, {
|
|
6
6
|
getSiteHostApi(): string;
|
|
7
|
-
loadHostInfo(hostApi: string, hostKey?: string
|
|
7
|
+
loadHostInfo(hostApi: string, hostKey?: string): Promise<void>;
|
|
8
8
|
clear(): void;
|
|
9
9
|
_setHostInfo(hostInfo: HostInfo | null): void;
|
|
10
10
|
getHostInfo(): HostInfo;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { AppInfo, HostInfo, UserInfo } from '../../../502424_MicroBase';
|
|
2
|
+
declare class MicroAppSDK {
|
|
3
|
+
private static messageId;
|
|
4
|
+
private static callbacks;
|
|
5
|
+
static isInMicroApp(): boolean;
|
|
6
|
+
private static callMainAppMethod;
|
|
7
|
+
static handleResponseData(data: any): void;
|
|
8
|
+
static init(): void;
|
|
9
|
+
static getAppInfo(): Promise<AppInfo>;
|
|
10
|
+
static getHostInfo(): Promise<HostInfo>;
|
|
11
|
+
static getUserInfo(): Promise<UserInfo>;
|
|
12
|
+
static getToken(): Promise<string>;
|
|
13
|
+
static userLogout(): Promise<void>;
|
|
14
|
+
static mainAppPush(path: string): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare const MicroOpenApis: {
|
|
17
|
+
getAppInfo: typeof MicroAppSDK.getAppInfo;
|
|
18
|
+
getHostInfo: typeof MicroAppSDK.getHostInfo;
|
|
19
|
+
getUserInfo: typeof MicroAppSDK.getUserInfo;
|
|
20
|
+
getToken: typeof MicroAppSDK.getToken;
|
|
21
|
+
userLogout: typeof MicroAppSDK.userLogout;
|
|
22
|
+
mainAppPush: typeof MicroAppSDK.mainAppPush;
|
|
23
|
+
isInMicroApp: typeof MicroAppSDK.isInMicroApp;
|
|
10
24
|
};
|
|
11
|
-
export {
|
|
25
|
+
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-C4BvnORD.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-C4BvnORD.js";
|
|
3
|
+
import { A as ds, U as ps, p as fs } from "./assets/modules/file-upload-Dmi2Kiqo.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-Bh1TJ-XO.js";
|
|
13
|
+
import { C as ms, U as hs, a as gs, p as bs } from "./assets/modules/uploadList-Bh1TJ-XO.js";
|
|
14
|
+
import { c as He } from "./assets/modules/index-1Qt9-aFa.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-1Qt9-aFa.js";
|
|
16
|
+
import { _ as A } from "./assets/modules/index-QDkmhaJS.js";
|
|
17
|
+
import { _ as U } from "./assets/modules/toolIcon-C6QsaAZ8.js";
|
|
18
|
+
import { a as Ns } from "./assets/modules/toolIcon-C6QsaAZ8.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-sfALzkA5.js";
|
|
20
|
+
import { _ as Ws } from "./assets/modules/index-RrFsG5IK.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,16 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref } from 'vue';
|
|
3
3
|
import { Modal, Flex } from 'ant-design-vue';
|
|
4
|
-
import { mainAppApis } from '@skyfox2000/microbase';
|
|
5
4
|
import { ToolIcon, Tooltip } from '../../common';
|
|
6
|
-
import { useUserInfo } from '@/index';
|
|
5
|
+
import { MicroOpenApis, useUserInfo } from '@/index';
|
|
6
|
+
import { isMicroApp } from '@skyfox2000/microbase';
|
|
7
7
|
|
|
8
8
|
const userInfoStore = useUserInfo();
|
|
9
9
|
const open = ref(false);
|
|
10
10
|
const confirmExit = () => {
|
|
11
11
|
open.value = false;
|
|
12
|
-
if (
|
|
13
|
-
|
|
12
|
+
if (isMicroApp()) {
|
|
13
|
+
MicroOpenApis.userLogout!();
|
|
14
14
|
} else {
|
|
15
15
|
userInfoStore.logout(true);
|
|
16
16
|
}
|
package/src/stores/appInfo.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
AppSource,
|
|
7
7
|
isBaseMicroApp,
|
|
8
8
|
isMicroApp,
|
|
9
|
-
mainAppApis,
|
|
10
9
|
RouteRecord,
|
|
11
10
|
EnvConfig,
|
|
12
11
|
} from '@skyfox2000/microbase';
|
|
@@ -18,6 +17,7 @@ import { Component, h, nextTick } from 'vue';
|
|
|
18
17
|
import { LoginExpiredError, useUserInfo } from './userInfo';
|
|
19
18
|
import { ApiResponse, httpPost, IUrlInfo, ResStatus } from '@skyfox2000/fapi';
|
|
20
19
|
import message from 'vue-m-message';
|
|
20
|
+
import { MicroOpenApis } from '@/utils/micro-openapis';
|
|
21
21
|
|
|
22
22
|
// const APPINFO_STORE_KEY = 'appInfoStore';
|
|
23
23
|
|
|
@@ -353,9 +353,9 @@ export const useAppInfo = defineStore('appInfo', {
|
|
|
353
353
|
this.appInfo.defaultPage = findFirstPage(filteredRoutes) || '';
|
|
354
354
|
if (this.appInfo.defaultPage) {
|
|
355
355
|
this.menuLoaded = true;
|
|
356
|
-
if (
|
|
356
|
+
if (isMicroApp()) {
|
|
357
357
|
const fullPath = this.formatRoute(this.appInfo.defaultPage);
|
|
358
|
-
|
|
358
|
+
MicroOpenApis.mainAppPush(fullPath);
|
|
359
359
|
}
|
|
360
360
|
continueNavigation(this.appInfo.defaultPage);
|
|
361
361
|
}
|
|
@@ -393,9 +393,9 @@ export const useAppInfo = defineStore('appInfo', {
|
|
|
393
393
|
nextTick(() => {
|
|
394
394
|
// 直接使用当前应用路由AppRouter
|
|
395
395
|
AppRouter.push({ path });
|
|
396
|
-
if (
|
|
396
|
+
if (isMicroApp()) {
|
|
397
397
|
const fullPath = this.formatRoute(path);
|
|
398
|
-
|
|
398
|
+
MicroOpenApis.mainAppPush(fullPath);
|
|
399
399
|
}
|
|
400
400
|
});
|
|
401
401
|
},
|
package/src/stores/hostInfo.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { MicroOpenApis } from '@/utils/micro-openapis';
|
|
1
2
|
import { API_HOST, ApiResponse, httpPost, IUrlInfo, ResStatus, SERVER_HOST } from '@skyfox2000/fapi';
|
|
2
3
|
|
|
3
|
-
import { HostInfo,
|
|
4
|
+
import { HostInfo, isMicroApp } from '@skyfox2000/microbase';
|
|
4
5
|
|
|
5
6
|
import { defineStore } from 'pinia';
|
|
6
7
|
|
|
@@ -57,11 +58,11 @@ export const useHostInfo = defineStore('hostInfo', {
|
|
|
57
58
|
* 加载站点信息
|
|
58
59
|
* @param hostApi 启动配置主机地址
|
|
59
60
|
* @param hostKey 站点信息,默认为当前主域名
|
|
60
|
-
* @param mainOpenApis 宿主机开放接口
|
|
61
61
|
*/
|
|
62
|
-
async loadHostInfo(hostApi: string, hostKey?: string
|
|
63
|
-
if (
|
|
64
|
-
|
|
62
|
+
async loadHostInfo(hostApi: string, hostKey?: string): Promise<void> {
|
|
63
|
+
if (isMicroApp()) {
|
|
64
|
+
const hostInfo = await MicroOpenApis.getHostInfo();
|
|
65
|
+
this._setHostInfo(hostInfo);
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
|
package/src/utils/file-upload.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { hostUrl, IUrlInfo } from '@skyfox2000/fapi';
|
|
2
2
|
|
|
3
|
-
import { getToken } from '@/utils/main-openapis';
|
|
4
3
|
import { UploadFile, UploadStatus } from '@/typings/upload.d';
|
|
5
4
|
import dayjs from 'dayjs';
|
|
6
5
|
import message from 'vue-m-message';
|
|
7
6
|
import { Ref } from 'vue';
|
|
7
|
+
import { MicroOpenApis } from './micro-openapis';
|
|
8
|
+
import { isMicroApp } from '@skyfox2000/microbase';
|
|
9
|
+
import { useUserInfo } from '@/stores/userInfo';
|
|
8
10
|
|
|
9
11
|
export class path {
|
|
10
12
|
/**
|
|
@@ -233,7 +235,7 @@ export class AsyncUploader {
|
|
|
233
235
|
|
|
234
236
|
// 添加授权 Token(如果需要)
|
|
235
237
|
if (this.urlInfo.authorize) {
|
|
236
|
-
const token = getToken(); // 假设 getToken 是获取 Token 的方法
|
|
238
|
+
const token = isMicroApp() ? MicroOpenApis.getToken() : useUserInfo().getToken(); // 假设 getToken 是获取 Token 的方法
|
|
237
239
|
if (!token) {
|
|
238
240
|
reject(new Error('未授权或授权过期'));
|
|
239
241
|
return;
|
|
@@ -360,4 +362,3 @@ export class AsyncUploader {
|
|
|
360
362
|
// console.error('上传错误:', error);
|
|
361
363
|
// }
|
|
362
364
|
// })();
|
|
363
|
-
|
|
@@ -1,145 +1,169 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 微前端通信工具
|
|
3
|
+
* 提供与主应用的通信接口,基于micro-app框架
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
mainAppPush: (params: any) => Promise<any>;
|
|
6
|
+
import { AppInfo, HostInfo, UserInfo } from '@skyfox2000/microbase';
|
|
7
|
+
|
|
8
|
+
// 定义请求数据格式
|
|
9
|
+
interface ApiRequestData {
|
|
10
|
+
type: 'API_REQUEST';
|
|
11
|
+
id: number;
|
|
12
|
+
method: string;
|
|
13
|
+
params?: any;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
|
|
16
|
+
// 定义响应数据格式
|
|
17
|
+
interface ApiResponseData {
|
|
18
|
+
type: 'API_RESPONSE';
|
|
19
|
+
id: number;
|
|
20
|
+
success: boolean;
|
|
21
|
+
result?: any;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
18
24
|
|
|
19
|
-
/**
|
|
20
|
-
* MicroAppSDK类 - 管理与主应用的通信
|
|
21
|
-
*/
|
|
22
25
|
class MicroAppSDK {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
+
private static messageId = 0;
|
|
27
|
+
private static callbacks = new Map<number, { resolve: Function; reject: Function }>();
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* 检查是否在微前端环境中运行
|
|
31
|
+
* @returns boolean
|
|
29
32
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
throw new Error('MicroAppSDK can only be used in browser environment');
|
|
33
|
-
}
|
|
33
|
+
static isInMicroApp(): boolean {
|
|
34
|
+
return typeof window !== 'undefined' && !!(window as any).microApp;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
+
* 调用主应用方法的通用方法
|
|
39
|
+
* @param method 方法名
|
|
40
|
+
* @param params 参数
|
|
41
|
+
* @returns Promise
|
|
38
42
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
private static async callMainAppMethod(method: string, params?: any): Promise<any> {
|
|
44
|
+
// 检查是否在微前端环境中
|
|
45
|
+
if (!this.isInMicroApp()) {
|
|
46
|
+
throw new Error(`未配置${method}接口!`);
|
|
43
47
|
}
|
|
44
|
-
|
|
48
|
+
|
|
49
|
+
// 生成唯一消息ID
|
|
50
|
+
const id = ++this.messageId;
|
|
51
|
+
|
|
52
|
+
// 创建Promise并保存回调
|
|
53
|
+
const promise = new Promise((resolve, reject) => {
|
|
54
|
+
this.callbacks.set(id, { resolve, reject });
|
|
55
|
+
|
|
56
|
+
// 设置超时
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
if (this.callbacks.has(id)) {
|
|
59
|
+
this.callbacks.delete(id);
|
|
60
|
+
reject(new Error(`API调用超时: ${method}`));
|
|
61
|
+
}
|
|
62
|
+
}, 10000); // 10秒超时
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// 构造请求数据
|
|
66
|
+
const requestData: ApiRequestData = {
|
|
67
|
+
type: 'API_REQUEST',
|
|
68
|
+
id,
|
|
69
|
+
method,
|
|
70
|
+
params,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// 发送数据到主应用(使用micro-app的dispatch方法)
|
|
74
|
+
(window as any).microApp.dispatch(requestData);
|
|
75
|
+
|
|
76
|
+
// 等待结果
|
|
77
|
+
return promise;
|
|
45
78
|
}
|
|
46
79
|
|
|
47
80
|
/**
|
|
48
|
-
*
|
|
81
|
+
* 处理来自主应用的响应数据
|
|
82
|
+
* @param data 响应数据
|
|
49
83
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
84
|
+
static handleResponseData(data: any) {
|
|
85
|
+
// 检查是否为API响应
|
|
86
|
+
if (data && data.type === 'API_RESPONSE' && typeof data.id === 'number') {
|
|
87
|
+
const { id, success, result, error } = data as ApiResponseData;
|
|
88
|
+
const callback = this.callbacks.get(id);
|
|
89
|
+
|
|
90
|
+
if (callback) {
|
|
91
|
+
this.callbacks.delete(id);
|
|
92
|
+
if (success) {
|
|
93
|
+
callback.resolve(result);
|
|
94
|
+
} else {
|
|
95
|
+
callback.reject(new Error(error || '未知错误'));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
52
99
|
}
|
|
53
100
|
|
|
54
101
|
/**
|
|
55
|
-
*
|
|
102
|
+
* 初始化通信监听器
|
|
56
103
|
*/
|
|
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;
|
|
104
|
+
static init() {
|
|
105
|
+
if (this.isInMicroApp()) {
|
|
106
|
+
// 添加监听器
|
|
107
|
+
(window as any).microApp.addDataListener((data: any) => {
|
|
108
|
+
console.log('收到来自主应用的数据:', data);
|
|
109
|
+
this.handleResponseData(data);
|
|
110
|
+
});
|
|
76
111
|
}
|
|
77
112
|
}
|
|
78
113
|
|
|
79
114
|
/**
|
|
80
115
|
* 获取应用信息
|
|
81
116
|
*/
|
|
82
|
-
async getAppInfo(): Promise<
|
|
83
|
-
return this.
|
|
117
|
+
static async getAppInfo(): Promise<AppInfo> {
|
|
118
|
+
return this.callMainAppMethod('getAppInfo');
|
|
84
119
|
}
|
|
85
120
|
|
|
86
121
|
/**
|
|
87
122
|
* 获取主机信息
|
|
88
123
|
*/
|
|
89
|
-
async getHostInfo(): Promise<
|
|
90
|
-
return this.
|
|
124
|
+
static async getHostInfo(): Promise<HostInfo> {
|
|
125
|
+
return this.callMainAppMethod('getHostInfo');
|
|
91
126
|
}
|
|
92
127
|
|
|
93
128
|
/**
|
|
94
129
|
* 获取用户信息
|
|
95
130
|
*/
|
|
96
|
-
async getUserInfo(): Promise<
|
|
97
|
-
return this.
|
|
131
|
+
static async getUserInfo(): Promise<UserInfo> {
|
|
132
|
+
return this.callMainAppMethod('getUserInfo');
|
|
98
133
|
}
|
|
99
134
|
|
|
100
135
|
/**
|
|
101
136
|
* 获取授权令牌
|
|
102
137
|
*/
|
|
103
|
-
async getToken(): Promise<
|
|
104
|
-
return this.
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* 用户登录
|
|
109
|
-
*/
|
|
110
|
-
async userLogin(params: any): Promise<any> {
|
|
111
|
-
return this.callMainApi('userLogin', params);
|
|
138
|
+
static async getToken(): Promise<string> {
|
|
139
|
+
return this.callMainAppMethod('getToken');
|
|
112
140
|
}
|
|
113
141
|
|
|
114
142
|
/**
|
|
115
143
|
* 用户登出
|
|
116
144
|
*/
|
|
117
|
-
async userLogout(): Promise<
|
|
118
|
-
return this.
|
|
145
|
+
static async userLogout(): Promise<void> {
|
|
146
|
+
return this.callMainAppMethod('userLogout');
|
|
119
147
|
}
|
|
120
148
|
|
|
121
149
|
/**
|
|
122
150
|
* 主应用推送
|
|
123
151
|
*/
|
|
124
|
-
async mainAppPush(
|
|
125
|
-
return this.
|
|
152
|
+
static async mainAppPush(path: string): Promise<void> {
|
|
153
|
+
return this.callMainAppMethod('mainAppPush', path);
|
|
126
154
|
}
|
|
127
155
|
}
|
|
128
156
|
|
|
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
|
-
};
|
|
157
|
+
// 初始化通信监听器
|
|
158
|
+
MicroAppSDK.init();
|
|
143
159
|
|
|
144
160
|
// 导出统一对象
|
|
145
|
-
export
|
|
161
|
+
export const MicroOpenApis = {
|
|
162
|
+
getAppInfo: MicroAppSDK.getAppInfo.bind(MicroAppSDK),
|
|
163
|
+
getHostInfo: MicroAppSDK.getHostInfo.bind(MicroAppSDK),
|
|
164
|
+
getUserInfo: MicroAppSDK.getUserInfo.bind(MicroAppSDK),
|
|
165
|
+
getToken: MicroAppSDK.getToken.bind(MicroAppSDK),
|
|
166
|
+
userLogout: MicroAppSDK.userLogout.bind(MicroAppSDK),
|
|
167
|
+
mainAppPush: MicroAppSDK.mainAppPush.bind(MicroAppSDK),
|
|
168
|
+
isInMicroApp: MicroAppSDK.isInMicroApp.bind(MicroAppSDK),
|
|
169
|
+
};
|