@morningfast/platform 0.0.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/dist/assets/main/style.css +13 -0
- package/dist/assets/main.css +1 -0
- package/dist/assets/sub/style.css +1 -0
- package/dist/auth/index.d.ts +32 -0
- package/dist/auth.js +49 -0
- package/dist/chunks/Forbidden-gf6y5Zsh.js +30 -0
- package/dist/chunks/Login-rBkUOl6l.js +209 -0
- package/dist/chunks/MicroAppView-DqTrIZZa.js +249 -0
- package/dist/chunks/NotFound-D0ybyfbK.js +30 -0
- package/dist/chunks/SystemConfig-DxkDxCnC.js +194 -0
- package/dist/chunks/_plugin-vue_export-helper-DvRHjpsZ.js +8 -0
- package/dist/chunks/app-Cn5iHmfI.js +221 -0
- package/dist/chunks/application-config-0d6f-odq.js +287 -0
- package/dist/chunks/auth-C3RvRgcW.js +248 -0
- package/dist/chunks/config-DkMAgPn_.js +44 -0
- package/dist/chunks/main-CfTD1njJ.js +1798 -0
- package/dist/chunks/storage-DNllLr_D.js +18 -0
- package/dist/chunks/sub-DlD5e1ys.js +140 -0
- package/dist/chunks/system-BbMsTIBR.js +160 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/main/api/adapter.d.ts +25 -0
- package/dist/main/api/auth.d.ts +12 -0
- package/dist/main/api/client.d.ts +3 -0
- package/dist/main/api/types.d.ts +1 -0
- package/dist/main/app/create-app.d.ts +29 -0
- package/dist/main/app/runtime-config.d.ts +5 -0
- package/dist/main/auth/expired.d.ts +2 -0
- package/dist/main/composables/useSortable.d.ts +197 -0
- package/dist/main/directives/index.d.ts +2 -0
- package/dist/main/index.d.ts +11 -0
- package/dist/main/layouts/AppLayout.vue.d.ts +3 -0
- package/dist/main/layouts/components/AppContentView.vue.d.ts +6 -0
- package/dist/main/layouts/components/AppHeader.vue.d.ts +7 -0
- package/dist/main/layouts/components/AppHeaderMenuNode.vue.d.ts +7 -0
- package/dist/main/layouts/components/AppMenuSearch.vue.d.ts +10 -0
- package/dist/main/layouts/components/AppMenuSearchItem.vue.d.ts +17 -0
- package/dist/main/layouts/components/AppMenuSearchTrigger.vue.d.ts +11 -0
- package/dist/main/layouts/components/AppSidebar.vue.d.ts +3 -0
- package/dist/main/layouts/components/AppSidebarNode.vue.d.ts +8 -0
- package/dist/main/layouts/components/AppSidebarSearch.vue.d.ts +11 -0
- package/dist/main/layouts/components/AppTabs.vue.d.ts +7 -0
- package/dist/main/layouts/components/AppTabsContextMenu.vue.d.ts +38 -0
- package/dist/main/layouts/composables/useAppMenus.d.ts +23 -0
- package/dist/main/layouts/composables/useShortcutLabel.d.ts +4 -0
- package/dist/main/layouts/utils/menuIcons.d.ts +1 -0
- package/dist/main/layouts/utils/menuSearch.d.ts +3 -0
- package/dist/main/micro-apps/config.d.ts +25 -0
- package/dist/main/micro-apps/register.d.ts +1 -0
- package/dist/main/micro-apps/status.d.ts +39 -0
- package/dist/main/micro-apps/types.d.ts +39 -0
- package/dist/main/pages/auth/Login.vue.d.ts +3 -0
- package/dist/main/pages/error/Forbidden.vue.d.ts +3 -0
- package/dist/main/pages/error/NotFound.vue.d.ts +3 -0
- package/dist/main/pages/micro/MicroAppView.vue.d.ts +3 -0
- package/dist/main/pages/system/SystemConfig.vue.d.ts +3 -0
- package/dist/main/pages/system/application-config/index.vue.d.ts +3 -0
- package/dist/main/router/base-routes.d.ts +2 -0
- package/dist/main/router/guard.d.ts +2 -0
- package/dist/main/router/index.d.ts +8 -0
- package/dist/main/settings/components/SystemSettingsDrawer.vue.d.ts +3 -0
- package/dist/main/settings/components/ThemeToggleButton.vue.d.ts +3 -0
- package/dist/main/settings/components/ThemedSvgImage.vue.d.ts +10 -0
- package/dist/main/stores/app.d.ts +85 -0
- package/dist/main/stores/auth.d.ts +110 -0
- package/dist/main/stores/index.d.ts +4 -0
- package/dist/main/stores/system.d.ts +111 -0
- package/dist/main/stores/tabs.d.ts +83 -0
- package/dist/main/utils/auth.d.ts +1 -0
- package/dist/main/utils/persistence.d.ts +3 -0
- package/dist/main/utils/storage.d.ts +3 -0
- package/dist/main/utils/theme.d.ts +20 -0
- package/dist/main.js +5 -0
- package/dist/micro-contract/index.d.ts +13 -0
- package/dist/micro-contract.js +4 -0
- package/dist/request/index.d.ts +72 -0
- package/dist/request.js +153 -0
- package/dist/sub/app/mount.d.ts +7 -0
- package/dist/sub/composables/useRequestClient.d.ts +5 -0
- package/dist/sub/composables/useSubAppContext.d.ts +1 -0
- package/dist/sub/context/sub-app-context.d.ts +10 -0
- package/dist/sub/index.d.ts +8 -0
- package/dist/sub/qiankun/index.d.ts +38 -0
- package/dist/sub/router/index.d.ts +2 -0
- package/dist/sub/theme/index.d.ts +2 -0
- package/dist/sub.js +2 -0
- package/package.json +86 -0
package/dist/request.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import e from "axios";
|
|
2
|
+
//#region src/request/index.ts
|
|
3
|
+
var t = class extends Error {
|
|
4
|
+
code;
|
|
5
|
+
rawMessage;
|
|
6
|
+
traceId;
|
|
7
|
+
status;
|
|
8
|
+
response;
|
|
9
|
+
error;
|
|
10
|
+
constructor(e, t = {}) {
|
|
11
|
+
super(e), this.name = "ApiError", this.code = t.code, this.rawMessage = t.rawMessage, this.traceId = t.traceId, this.status = t.status, this.response = t.response, this.error = t.error;
|
|
12
|
+
}
|
|
13
|
+
}, n = class {
|
|
14
|
+
requestsByPage = /* @__PURE__ */ new Map();
|
|
15
|
+
manualCancels = /* @__PURE__ */ new WeakSet();
|
|
16
|
+
currentPage = "";
|
|
17
|
+
setCurrentPage(e) {
|
|
18
|
+
this.currentPage && this.currentPage !== e && this.cancelPageRequests(this.currentPage), this.currentPage = e;
|
|
19
|
+
}
|
|
20
|
+
register(e, t) {
|
|
21
|
+
let n = t || this.currentPage || "global";
|
|
22
|
+
return this.requestsByPage.has(n) || this.requestsByPage.set(n, /* @__PURE__ */ new Set()), this.requestsByPage.get(n)?.add(e), () => {
|
|
23
|
+
this.requestsByPage.get(n)?.delete(e);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
cancelPageRequests(e) {
|
|
27
|
+
let t = this.requestsByPage.get(e);
|
|
28
|
+
t && (t.forEach((e) => {
|
|
29
|
+
e.signal.aborted || e.abort();
|
|
30
|
+
}), this.requestsByPage.delete(e));
|
|
31
|
+
}
|
|
32
|
+
markAsManualCancel(e) {
|
|
33
|
+
this.manualCancels.add(e);
|
|
34
|
+
}
|
|
35
|
+
isManualCancel(e) {
|
|
36
|
+
return this.manualCancels.has(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
function r(r) {
|
|
40
|
+
let i = new n(), c = r.isSuccessCode ?? ((e) => e === 0), l = e.create({
|
|
41
|
+
baseURL: r.baseURL,
|
|
42
|
+
timeout: r.timeout ?? 15e3
|
|
43
|
+
});
|
|
44
|
+
l.interceptors.request.use((e) => {
|
|
45
|
+
let t = r.getToken?.(), n = r.getHeaders?.() ?? {};
|
|
46
|
+
return Object.entries(n).forEach(([t, n]) => {
|
|
47
|
+
n && e.headers.set(t, n);
|
|
48
|
+
}), t && e.headers.set("Authorization", `Bearer ${t}`), e;
|
|
49
|
+
}), l.interceptors.response.use((e) => {
|
|
50
|
+
let n = e.data;
|
|
51
|
+
if (e.config.rawResponse) return e.data;
|
|
52
|
+
if (n?.code !== void 0 && !c(n.code)) {
|
|
53
|
+
let i = a({
|
|
54
|
+
code: n.code,
|
|
55
|
+
message: n.message || "请求失败,请稍后重试",
|
|
56
|
+
traceId: n.trace_id || s(e.headers),
|
|
57
|
+
status: e.status,
|
|
58
|
+
response: n
|
|
59
|
+
});
|
|
60
|
+
return o(i, r), Promise.reject(new t(i.message, i));
|
|
61
|
+
}
|
|
62
|
+
return n?.data;
|
|
63
|
+
}, (n) => {
|
|
64
|
+
if (e.isCancel(n)) return Promise.reject(n);
|
|
65
|
+
let i = n.response?.data, c = a({
|
|
66
|
+
code: i?.code,
|
|
67
|
+
message: i?.message || n.message || "请求失败,请稍后重试",
|
|
68
|
+
traceId: i?.trace_id || s(n.response?.headers),
|
|
69
|
+
status: n.response?.status,
|
|
70
|
+
response: i ?? null,
|
|
71
|
+
error: n
|
|
72
|
+
});
|
|
73
|
+
return o(c, r), Promise.reject(new t(c.message, c));
|
|
74
|
+
});
|
|
75
|
+
function u(t) {
|
|
76
|
+
let n = null, r = async (r) => {
|
|
77
|
+
n = t.signal ? null : new AbortController();
|
|
78
|
+
let a = n, o = a ? i.register(a, t.pageKey) : () => {};
|
|
79
|
+
try {
|
|
80
|
+
let e = (t.method || "GET").toUpperCase(), n = {
|
|
81
|
+
...t,
|
|
82
|
+
method: e,
|
|
83
|
+
signal: t.signal || a?.signal
|
|
84
|
+
};
|
|
85
|
+
return e === "GET" || e === "DELETE" ? n.params = r : n.data = r, await l.request(n);
|
|
86
|
+
} catch (t) {
|
|
87
|
+
if ((e.isCancel(t) || t instanceof Error && t.name === "CanceledError") && a && !i.isManualCancel(a)) return null;
|
|
88
|
+
throw t;
|
|
89
|
+
} finally {
|
|
90
|
+
o();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return r.cancel = () => {
|
|
94
|
+
n &&= (i.markAsManualCancel(n), n.abort(), null);
|
|
95
|
+
}, r;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
http: l,
|
|
99
|
+
createApi: u,
|
|
100
|
+
requestManager: i
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function i(e, t) {
|
|
104
|
+
let n = e.trim() || "请求失败,请稍后重试", r = t?.trim();
|
|
105
|
+
return !r || n.includes(r) ? n : `${n}(错误ID:${r})`;
|
|
106
|
+
}
|
|
107
|
+
function a(e) {
|
|
108
|
+
let t = e.rawMessage ?? e.message, n = e.traceId?.trim();
|
|
109
|
+
return {
|
|
110
|
+
...e,
|
|
111
|
+
rawMessage: t,
|
|
112
|
+
traceId: n,
|
|
113
|
+
message: i(t, n)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function o(e, t) {
|
|
117
|
+
if (l(e)) {
|
|
118
|
+
t.onUnauthorized?.(e);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
t.onError?.(e.message, e);
|
|
122
|
+
}
|
|
123
|
+
function s(e) {
|
|
124
|
+
let t = [
|
|
125
|
+
"trace_id",
|
|
126
|
+
"trace-id",
|
|
127
|
+
"x-trace-id",
|
|
128
|
+
"x-request-id"
|
|
129
|
+
];
|
|
130
|
+
if (!e) return;
|
|
131
|
+
if (typeof e.get == "function") {
|
|
132
|
+
let n = e.get;
|
|
133
|
+
for (let r of t) {
|
|
134
|
+
let t = c(n.call(e, r));
|
|
135
|
+
if (t) return t;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let n = e;
|
|
139
|
+
for (let e of t) {
|
|
140
|
+
let t = c(n[e] ?? n[e.toLowerCase()]);
|
|
141
|
+
if (t) return t;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function c(e) {
|
|
145
|
+
if (Array.isArray(e)) return c(e[0]);
|
|
146
|
+
if (typeof e == "string") return e.trim() || void 0;
|
|
147
|
+
if (typeof e == "number") return String(e);
|
|
148
|
+
}
|
|
149
|
+
function l(e) {
|
|
150
|
+
return e.status === 401 || e.code !== void 0 && e.code >= 2e3 && e.code < 3e3;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { t as ApiError, n as RequestManager, r as createRequestClient, i as formatErrorMessage };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function useRequestClient(): {
|
|
2
|
+
http: import('axios').AxiosInstance;
|
|
3
|
+
createApi: <Params = void, Result = void>(option: import('../../request').ManagedRequestConfig) => import('../../request').ManagedApi<Params, Result>;
|
|
4
|
+
requestManager: import('../../request').RequestManager;
|
|
5
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSubAppContext(): import('..').SubAppContext;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
import { SubAppInfo, SubAppRuntimeContext, SubAppThemeContext } from '../qiankun';
|
|
3
|
+
export interface SubAppContext {
|
|
4
|
+
basePath: string;
|
|
5
|
+
app?: SubAppInfo;
|
|
6
|
+
runtime: SubAppRuntimeContext;
|
|
7
|
+
theme?: SubAppThemeContext;
|
|
8
|
+
}
|
|
9
|
+
export declare const subAppContextKey: InjectionKey<SubAppContext>;
|
|
10
|
+
export declare function createSubAppContext(context?: Partial<SubAppContext>): SubAppContext;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { mountSubApp } from './app/mount';
|
|
2
|
+
export type { MountSubAppOptions } from './app/mount';
|
|
3
|
+
export { createSubAppRouter } from './router';
|
|
4
|
+
export { useRequestClient } from './composables/useRequestClient';
|
|
5
|
+
export { useSubAppContext } from './composables/useSubAppContext';
|
|
6
|
+
export * from './context/sub-app-context';
|
|
7
|
+
export * from './qiankun';
|
|
8
|
+
export * from './theme';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const SUB_APP_NAME = "morningfast-sub-app";
|
|
2
|
+
export declare const DEFAULT_SUB_APP_BASE = "/";
|
|
3
|
+
export declare const SUB_APP_THEME_CHANGE_EVENT = "morningfast:theme-change";
|
|
4
|
+
export interface SubAppInfo {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
title: string;
|
|
8
|
+
entry: string;
|
|
9
|
+
activeRule: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SubAppRuntimeContext {
|
|
12
|
+
env: string;
|
|
13
|
+
apiBaseUrl: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SubAppThemeContext {
|
|
16
|
+
colorPrimary?: string;
|
|
17
|
+
colorPrimaryLight3?: string;
|
|
18
|
+
colorPrimaryLight5?: string;
|
|
19
|
+
colorPrimaryLight7?: string;
|
|
20
|
+
colorPrimaryLight8?: string;
|
|
21
|
+
colorPrimaryLight9?: string;
|
|
22
|
+
colorPrimaryDark2?: string;
|
|
23
|
+
mode?: 'light' | 'dark';
|
|
24
|
+
}
|
|
25
|
+
export interface SubAppRuntimeProps {
|
|
26
|
+
theme?: SubAppThemeContext;
|
|
27
|
+
}
|
|
28
|
+
export interface SubAppProps {
|
|
29
|
+
basePath?: string;
|
|
30
|
+
app?: SubAppInfo;
|
|
31
|
+
runtime?: SubAppRuntimeContext;
|
|
32
|
+
theme?: SubAppThemeContext;
|
|
33
|
+
getRuntimeProps?: () => Partial<SubAppRuntimeProps>;
|
|
34
|
+
container?: {
|
|
35
|
+
querySelector: (selectors: string) => unknown;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare function resolveSubAppBasePath(props?: SubAppProps): string;
|
package/dist/sub.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./chunks/sub-DlD5e1ys.js";
|
|
2
|
+
export { o as DEFAULT_SUB_APP_BASE, c as SUB_APP_NAME, t as SUB_APP_THEME_CHANGE_EVENT, r as applySubAppTheme, u as createSubAppContext, e as createSubAppRouter, s as mountSubApp, i as resolveSubAppBasePath, n as subAppContextKey, l as useRequestClient, a as useSubAppContext };
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@morningfast/platform",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "Morningfast platform runtime for main and sub applications.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.css"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org/",
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./main": {
|
|
22
|
+
"types": "./dist/main/index.d.ts",
|
|
23
|
+
"import": "./dist/main.js"
|
|
24
|
+
},
|
|
25
|
+
"./main/style.css": {
|
|
26
|
+
"default": "./dist/assets/main/style.css"
|
|
27
|
+
},
|
|
28
|
+
"./sub": {
|
|
29
|
+
"types": "./dist/sub/index.d.ts",
|
|
30
|
+
"import": "./dist/sub.js"
|
|
31
|
+
},
|
|
32
|
+
"./sub/style.css": {
|
|
33
|
+
"default": "./dist/assets/sub/style.css"
|
|
34
|
+
},
|
|
35
|
+
"./request": {
|
|
36
|
+
"types": "./dist/request/index.d.ts",
|
|
37
|
+
"import": "./dist/request.js"
|
|
38
|
+
},
|
|
39
|
+
"./auth": {
|
|
40
|
+
"types": "./dist/auth/index.d.ts",
|
|
41
|
+
"import": "./dist/auth.js"
|
|
42
|
+
},
|
|
43
|
+
"./micro-contract": {
|
|
44
|
+
"types": "./dist/micro-contract/index.d.ts",
|
|
45
|
+
"import": "./dist/micro-contract.js"
|
|
46
|
+
},
|
|
47
|
+
"./style.css": {
|
|
48
|
+
"default": "./dist/assets/main/style.css"
|
|
49
|
+
}
|
|
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
|
+
"dependencies": {
|
|
58
|
+
"morningfast-plus": "^1.1.0",
|
|
59
|
+
"localforage": "^1.10.0",
|
|
60
|
+
"nprogress": "^0.2.0",
|
|
61
|
+
"vite-plugin-qiankun": "^1.0.15"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@element-plus/icons-vue": "^2.3.2",
|
|
65
|
+
"axios": "^1.16.0",
|
|
66
|
+
"element-plus": "^2.14.0",
|
|
67
|
+
"pinia": "^3.0.4",
|
|
68
|
+
"qiankun": "^2.10.16",
|
|
69
|
+
"sortablejs": "^1.15.7",
|
|
70
|
+
"vue": "^3.5.32",
|
|
71
|
+
"vue-router": "^5.0.4"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@types/nprogress": "^0.2.3",
|
|
75
|
+
"@types/sortablejs": "^1.15.9",
|
|
76
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
77
|
+
"@vue/tsconfig": "^0.9.1",
|
|
78
|
+
"typescript": "~6.0.0",
|
|
79
|
+
"vite": "^8.0.8",
|
|
80
|
+
"vite-plugin-dts": "^5.0.1",
|
|
81
|
+
"vue-tsc": "^3.2.6"
|
|
82
|
+
},
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
85
|
+
}
|
|
86
|
+
}
|