@morningfast/platform 1.0.0 → 1.0.2
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/dist/chunks/{sub-D7y3UaHp.js → sub-LssKnIb1.js} +59 -59
- package/dist/index.js +2 -2
- package/dist/request/index.d.ts +2 -0
- package/dist/request.js +13 -12
- package/dist/sub/composables/useRequestClient.d.ts +2 -1
- package/dist/sub/router/index.d.ts +5 -1
- package/dist/sub.js +2 -2
- package/package.json +7 -8
|
@@ -23,26 +23,54 @@ function m(e = {}) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
26
|
+
//#region src/sub/composables/useSubAppContext.ts
|
|
27
|
+
function h() {
|
|
28
|
+
return c(p, m());
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/sub/composables/useRequestClient.ts
|
|
32
|
+
var g = /* @__PURE__ */ new Map();
|
|
33
|
+
function _(r) {
|
|
34
|
+
let i = r ?? h(), a = i.runtime.apiBaseUrl, s = g.get(a);
|
|
35
|
+
if (s) return s;
|
|
36
|
+
let c = n({
|
|
37
|
+
baseURL: i.runtime.apiBaseUrl,
|
|
38
|
+
getToken: t,
|
|
39
|
+
onError(e) {
|
|
40
|
+
o.error(e);
|
|
41
|
+
},
|
|
42
|
+
onUnauthorized(t) {
|
|
43
|
+
e({
|
|
44
|
+
source: "sub-app",
|
|
45
|
+
reason: "unauthorized",
|
|
46
|
+
code: t.code,
|
|
47
|
+
message: t.message
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return g.set(a, c), c;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
26
54
|
//#region src/sub/qiankun/index.ts
|
|
27
|
-
var
|
|
28
|
-
function
|
|
55
|
+
var v = "morningfast-sub-app", y = "/", b = "morningfast:theme-change";
|
|
56
|
+
function x(e) {
|
|
29
57
|
let t = e?.basePath || "/";
|
|
30
58
|
return t.endsWith("/") ? t : `${t}/`;
|
|
31
59
|
}
|
|
32
60
|
//#endregion
|
|
33
61
|
//#region src/sub/router/index.ts
|
|
34
|
-
function
|
|
35
|
-
let
|
|
62
|
+
function S(e, t = "/", n = {}) {
|
|
63
|
+
let a = r({
|
|
36
64
|
history: i(t),
|
|
37
65
|
routes: e
|
|
38
66
|
});
|
|
39
|
-
return n.afterEach((e) => {
|
|
67
|
+
return a.beforeEach((e, t) => (e.path !== t.path && n.requestManager?.setCurrentPage(e.path), !0)), a.afterEach((e) => {
|
|
40
68
|
document.title = String(e.meta.title ?? "Morningfast Sub App");
|
|
41
|
-
}),
|
|
69
|
+
}), a;
|
|
42
70
|
}
|
|
43
71
|
//#endregion
|
|
44
72
|
//#region src/sub/theme/index.ts
|
|
45
|
-
var
|
|
73
|
+
var C = {
|
|
46
74
|
colorPrimary: "--el-color-primary",
|
|
47
75
|
colorPrimaryLight3: "--el-color-primary-light-3",
|
|
48
76
|
colorPrimaryLight5: "--el-color-primary-light-5",
|
|
@@ -51,90 +79,62 @@ var b = {
|
|
|
51
79
|
colorPrimaryLight9: "--el-color-primary-light-9",
|
|
52
80
|
colorPrimaryDark2: "--el-color-primary-dark-2"
|
|
53
81
|
};
|
|
54
|
-
function
|
|
82
|
+
function w(e) {
|
|
55
83
|
let t = document.documentElement;
|
|
56
|
-
e && (Object.entries(
|
|
84
|
+
e && (Object.entries(C).forEach(([n, r]) => {
|
|
57
85
|
let i = e[n];
|
|
58
86
|
i && t.style.setProperty(r, i);
|
|
59
87
|
}), t.classList.toggle("dark", e.mode === "dark"), t.style.colorScheme = e.mode === "dark" ? "dark" : "light");
|
|
60
88
|
}
|
|
61
89
|
//#endregion
|
|
62
90
|
//#region src/sub/app/mount.ts
|
|
63
|
-
var
|
|
64
|
-
function
|
|
91
|
+
var T = null, E = null;
|
|
92
|
+
function D(e) {
|
|
65
93
|
f({
|
|
66
94
|
bootstrap() {},
|
|
67
95
|
mount(t) {
|
|
68
|
-
|
|
96
|
+
O(e.rootComponent, e.routes, t);
|
|
69
97
|
},
|
|
70
98
|
unmount() {
|
|
71
|
-
|
|
99
|
+
E?.(), T?.unmount(), T = null;
|
|
72
100
|
},
|
|
73
101
|
update(e) {
|
|
74
|
-
|
|
102
|
+
w(k(e).theme);
|
|
75
103
|
}
|
|
76
|
-
}), d.__POWERED_BY_QIANKUN__ ||
|
|
104
|
+
}), d.__POWERED_BY_QIANKUN__ || O(e.rootComponent, e.routes);
|
|
77
105
|
}
|
|
78
|
-
function
|
|
79
|
-
let r =
|
|
80
|
-
|
|
106
|
+
function O(e, t, n = {}) {
|
|
107
|
+
let r = k(n);
|
|
108
|
+
w(r.theme), A(), l();
|
|
81
109
|
let i = n.container?.querySelector("#sub-app") || document.querySelector("#sub-app");
|
|
82
110
|
if (!i) return;
|
|
83
|
-
let o =
|
|
84
|
-
S = s(e, {
|
|
111
|
+
let o = m({
|
|
85
112
|
app: n.app,
|
|
86
|
-
basePath: n
|
|
113
|
+
basePath: x(n),
|
|
87
114
|
runtime: n.runtime,
|
|
88
115
|
theme: r.theme
|
|
89
|
-
}), S
|
|
116
|
+
}), c = _(o), d = S(t, x(n), { requestManager: c.requestManager });
|
|
117
|
+
T = s(e, {
|
|
90
118
|
app: n.app,
|
|
91
|
-
basePath:
|
|
119
|
+
basePath: n.basePath,
|
|
92
120
|
runtime: n.runtime,
|
|
93
121
|
theme: r.theme
|
|
94
|
-
})),
|
|
122
|
+
}), T.provide(p, o), T.use(a, { locale: u }), T.use(d), T.mount(i);
|
|
95
123
|
}
|
|
96
|
-
function
|
|
124
|
+
function k(e = {}) {
|
|
97
125
|
return {
|
|
98
126
|
theme: e.theme,
|
|
99
127
|
...e.getRuntimeProps?.()
|
|
100
128
|
};
|
|
101
129
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
130
|
+
function A() {
|
|
131
|
+
E?.();
|
|
104
132
|
let e = (e) => {
|
|
105
|
-
|
|
133
|
+
w(e.detail);
|
|
106
134
|
};
|
|
107
|
-
window.addEventListener(
|
|
108
|
-
window.removeEventListener(
|
|
135
|
+
window.addEventListener(b, e), E = () => {
|
|
136
|
+
window.removeEventListener(b, e), E = null;
|
|
109
137
|
};
|
|
110
138
|
}
|
|
111
139
|
//#endregion
|
|
112
|
-
|
|
113
|
-
function O() {
|
|
114
|
-
return c(p, m());
|
|
115
|
-
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/sub/composables/useRequestClient.ts
|
|
118
|
-
var k = /* @__PURE__ */ new Map();
|
|
119
|
-
function A() {
|
|
120
|
-
let r = O(), i = r.runtime.apiBaseUrl, a = k.get(i);
|
|
121
|
-
if (a) return a;
|
|
122
|
-
let s = n({
|
|
123
|
-
baseURL: r.runtime.apiBaseUrl,
|
|
124
|
-
getToken: t,
|
|
125
|
-
onError(e) {
|
|
126
|
-
o.error(e);
|
|
127
|
-
},
|
|
128
|
-
onUnauthorized(t) {
|
|
129
|
-
e({
|
|
130
|
-
source: "sub-app",
|
|
131
|
-
reason: "unauthorized",
|
|
132
|
-
code: t.code,
|
|
133
|
-
message: t.message
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
return k.set(i, s), s;
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
export { y as a, _ as c, p as d, x as i, v as l, O as n, g as o, w as r, h as s, A as t, m as u };
|
|
140
|
+
export { v as a, _ as c, p as d, y as i, h as l, w as n, b as o, S as r, x as s, D as t, m as u };
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,5 @@ import { ApiError as x, RequestManager as S, createRequestClient as C, formatErr
|
|
|
4
4
|
import { a as T, i as E, n as D, r as O, t as k } from "./chunks/auth-C3RvRgcW.js";
|
|
5
5
|
import { i as A, n as j, r as M, t as N } from "./chunks/system-DZaKDrG6.js";
|
|
6
6
|
import { o as P } from "./chunks/config-CJOAan9n.js";
|
|
7
|
-
import { a as F, c as I, d as L,
|
|
8
|
-
export { x as ApiError, d as HOME_TAB_PATH, e as MICRO_AUTH_EXPIRED_EVENT, i as MicroAppView, S as RequestManager,
|
|
7
|
+
import { a as F, c as I, d as L, l as R, n as z, o as B, r as V, s as H, t as U, u as W } from "./chunks/sub-LssKnIb1.js";
|
|
8
|
+
export { x as ApiError, d as HOME_TAB_PATH, e as MICRO_AUTH_EXPIRED_EVENT, i as MicroAppView, S as RequestManager, F as SUB_APP_NAME, B as SUB_APP_THEME_CHANGE_EVENT, z as applySubAppTheme, s as configureMorningfastRequestClient, t as createApi, D as createMockLoginResult, O as createMockUserProfile, v as createMorningfastBaseRoutes, u as createMorningfastRouter, C as createRequestClient, g as createRoutesFromItems, W as createSubAppContext, V as createSubAppRouter, w as formatErrorMessage, j as getPersistedValue, n as getStoredUpdateCheckEnabled, y as http, _ as mountMorningfastApp, U as mountSubApp, E as normalizeLoginResult, T as normalizeUserProfile, M as removePersistedValue, b as requestManager, H as resolveSubAppBasePath, f as restartAppUpdateChecker, P as setDefaultAppConfigs, A as setPersistedValue, p as setStoredUpdateCheckEnabled, h as setupAppUpdateChecker, r as setupAuthExpiredHandler, l as stopAppUpdateChecker, L as subAppContextKey, m as useAppStore, k as useAuthStore, I as useRequestClient, o as useShortcutStore, a as useSortable, R as useSubAppContext, N as useSystemStore, c as useTabsStore };
|
package/dist/request/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface PageResult<Row = unknown> {
|
|
|
17
17
|
total_page: number;
|
|
18
18
|
}
|
|
19
19
|
export interface RequestConfig {
|
|
20
|
+
cancelOnRouteChange?: boolean;
|
|
20
21
|
pageKey?: string;
|
|
21
22
|
rawResponse?: boolean;
|
|
22
23
|
}
|
|
@@ -25,6 +26,7 @@ export interface ManagedRequestConfig extends AxiosRequestConfig, RequestConfig
|
|
|
25
26
|
export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
26
27
|
export interface RequestClientOptions {
|
|
27
28
|
baseURL: string;
|
|
29
|
+
cancelOnRouteChange?: boolean;
|
|
28
30
|
timeout?: number;
|
|
29
31
|
getToken?: () => string | undefined | null;
|
|
30
32
|
getHeaders?: () => Record<string, string | undefined>;
|
package/dist/request.js
CHANGED
|
@@ -37,16 +37,16 @@ var t = class extends Error {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
function r(r) {
|
|
40
|
-
let i = new n(), c = r.isSuccessCode ?? ((e) => e === 0), l = e.create({
|
|
40
|
+
let i = new n(), c = r.isSuccessCode ?? ((e) => e === 0), l = r.cancelOnRouteChange ?? !0, u = e.create({
|
|
41
41
|
baseURL: r.baseURL,
|
|
42
42
|
timeout: r.timeout ?? 15e3
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
u.interceptors.request.use((e) => {
|
|
45
45
|
let t = r.getToken?.(), n = r.getHeaders?.() ?? {};
|
|
46
46
|
return Object.entries(n).forEach(([t, n]) => {
|
|
47
47
|
n && e.headers.set(t, n);
|
|
48
48
|
}), t && e.headers.set("Authorization", `Bearer ${t}`), e;
|
|
49
|
-
}),
|
|
49
|
+
}), u.interceptors.response.use((e) => {
|
|
50
50
|
let n = e.data;
|
|
51
51
|
if (e.config.rawResponse) return e.data;
|
|
52
52
|
if (n?.code !== void 0 && !c(n.code)) {
|
|
@@ -72,22 +72,23 @@ function r(r) {
|
|
|
72
72
|
});
|
|
73
73
|
return o(c, r), Promise.reject(new t(c.message, c));
|
|
74
74
|
});
|
|
75
|
-
function
|
|
75
|
+
function d(t) {
|
|
76
76
|
let n = null, r = async (r) => {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
let a = !!t.signal, o = t.cancelOnRouteChange ?? l;
|
|
78
|
+
n = a ? null : new AbortController();
|
|
79
|
+
let s = n, c = s ? i.register(s, o ? t.pageKey : "global") : () => {};
|
|
79
80
|
try {
|
|
80
81
|
let e = (t.method || "GET").toUpperCase(), n = {
|
|
81
82
|
...t,
|
|
82
83
|
method: e,
|
|
83
|
-
signal: t.signal ||
|
|
84
|
+
signal: t.signal || s?.signal
|
|
84
85
|
};
|
|
85
|
-
return e === "GET" || e === "DELETE" ? n.params = r : n.data = r, await
|
|
86
|
+
return e === "GET" || e === "DELETE" ? n.params = r : n.data = r, await u.request(n);
|
|
86
87
|
} catch (t) {
|
|
87
|
-
if ((e.isCancel(t) || t instanceof Error && t.name === "CanceledError") &&
|
|
88
|
+
if ((e.isCancel(t) || t instanceof Error && t.name === "CanceledError") && s && !i.isManualCancel(s)) return null;
|
|
88
89
|
throw t;
|
|
89
90
|
} finally {
|
|
90
|
-
|
|
91
|
+
c();
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
94
|
return r.cancel = () => {
|
|
@@ -95,8 +96,8 @@ function r(r) {
|
|
|
95
96
|
}, r;
|
|
96
97
|
}
|
|
97
98
|
return {
|
|
98
|
-
http:
|
|
99
|
-
createApi:
|
|
99
|
+
http: u,
|
|
100
|
+
createApi: d,
|
|
100
101
|
requestManager: i
|
|
101
102
|
};
|
|
102
103
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { SubAppContext } from '../context/sub-app-context';
|
|
2
|
+
export declare function useRequestClient(providedContext?: SubAppContext): {
|
|
2
3
|
http: import('axios').AxiosInstance;
|
|
3
4
|
createApi: <Params = void, Result = void>(option: import('../../request').ManagedRequestConfig) => import('../../request').ManagedApi<Params, Result>;
|
|
4
5
|
requestManager: import('../../request').RequestManager;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { RouteRecordRaw } from 'vue-router';
|
|
2
|
-
|
|
2
|
+
import { RequestManager } from '../../request';
|
|
3
|
+
export interface CreateSubAppRouterOptions {
|
|
4
|
+
requestManager?: RequestManager;
|
|
5
|
+
}
|
|
6
|
+
export declare function createSubAppRouter(routes: RouteRecordRaw[], base?: string, options?: CreateSubAppRouterOptions): import('vue-router').Router;
|
package/dist/sub.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as e } from "./chunks/route-items-DXwaEe0Y.js";
|
|
2
|
-
import { a as t, c as n, d as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./chunks/sub-
|
|
3
|
-
export {
|
|
2
|
+
import { a as t, c as n, d as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./chunks/sub-LssKnIb1.js";
|
|
3
|
+
export { i as DEFAULT_SUB_APP_BASE, t as SUB_APP_NAME, s as SUB_APP_THEME_CHANGE_EVENT, o as applySubAppTheme, e as createRoutesFromItems, d as createSubAppContext, c as createSubAppRouter, u as mountSubApp, l as resolveSubAppBasePath, r as subAppContextKey, n as useRequestClient, a as useSubAppContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morningfast/platform",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Morningfast platform runtime for main and sub applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -48,12 +48,6 @@
|
|
|
48
48
|
"default": "./dist/assets/main/style.css"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
"scripts": {
|
|
52
|
-
"build": "vite build && node scripts/merge-main-style.mjs",
|
|
53
|
-
"check": "vue-tsc --build",
|
|
54
|
-
"prepack": "pnpm build",
|
|
55
|
-
"publish:dry-run": "pnpm build && npm publish --dry-run"
|
|
56
|
-
},
|
|
57
51
|
"dependencies": {
|
|
58
52
|
"morningfast-plus": "^1.1.0",
|
|
59
53
|
"localforage": "^1.10.0",
|
|
@@ -82,5 +76,10 @@
|
|
|
82
76
|
},
|
|
83
77
|
"engines": {
|
|
84
78
|
"node": ">=22.12.0"
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "vite build && node scripts/merge-main-style.mjs",
|
|
82
|
+
"check": "vue-tsc --build",
|
|
83
|
+
"publish:dry-run": "pnpm build && npm publish --dry-run"
|
|
85
84
|
}
|
|
86
|
-
}
|
|
85
|
+
}
|