@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.
Files changed (87) hide show
  1. package/dist/assets/main/style.css +13 -0
  2. package/dist/assets/main.css +1 -0
  3. package/dist/assets/sub/style.css +1 -0
  4. package/dist/auth/index.d.ts +32 -0
  5. package/dist/auth.js +49 -0
  6. package/dist/chunks/Forbidden-gf6y5Zsh.js +30 -0
  7. package/dist/chunks/Login-rBkUOl6l.js +209 -0
  8. package/dist/chunks/MicroAppView-DqTrIZZa.js +249 -0
  9. package/dist/chunks/NotFound-D0ybyfbK.js +30 -0
  10. package/dist/chunks/SystemConfig-DxkDxCnC.js +194 -0
  11. package/dist/chunks/_plugin-vue_export-helper-DvRHjpsZ.js +8 -0
  12. package/dist/chunks/app-Cn5iHmfI.js +221 -0
  13. package/dist/chunks/application-config-0d6f-odq.js +287 -0
  14. package/dist/chunks/auth-C3RvRgcW.js +248 -0
  15. package/dist/chunks/config-DkMAgPn_.js +44 -0
  16. package/dist/chunks/main-CfTD1njJ.js +1798 -0
  17. package/dist/chunks/storage-DNllLr_D.js +18 -0
  18. package/dist/chunks/sub-DlD5e1ys.js +140 -0
  19. package/dist/chunks/system-BbMsTIBR.js +160 -0
  20. package/dist/index.d.ts +4 -0
  21. package/dist/index.js +8 -0
  22. package/dist/main/api/adapter.d.ts +25 -0
  23. package/dist/main/api/auth.d.ts +12 -0
  24. package/dist/main/api/client.d.ts +3 -0
  25. package/dist/main/api/types.d.ts +1 -0
  26. package/dist/main/app/create-app.d.ts +29 -0
  27. package/dist/main/app/runtime-config.d.ts +5 -0
  28. package/dist/main/auth/expired.d.ts +2 -0
  29. package/dist/main/composables/useSortable.d.ts +197 -0
  30. package/dist/main/directives/index.d.ts +2 -0
  31. package/dist/main/index.d.ts +11 -0
  32. package/dist/main/layouts/AppLayout.vue.d.ts +3 -0
  33. package/dist/main/layouts/components/AppContentView.vue.d.ts +6 -0
  34. package/dist/main/layouts/components/AppHeader.vue.d.ts +7 -0
  35. package/dist/main/layouts/components/AppHeaderMenuNode.vue.d.ts +7 -0
  36. package/dist/main/layouts/components/AppMenuSearch.vue.d.ts +10 -0
  37. package/dist/main/layouts/components/AppMenuSearchItem.vue.d.ts +17 -0
  38. package/dist/main/layouts/components/AppMenuSearchTrigger.vue.d.ts +11 -0
  39. package/dist/main/layouts/components/AppSidebar.vue.d.ts +3 -0
  40. package/dist/main/layouts/components/AppSidebarNode.vue.d.ts +8 -0
  41. package/dist/main/layouts/components/AppSidebarSearch.vue.d.ts +11 -0
  42. package/dist/main/layouts/components/AppTabs.vue.d.ts +7 -0
  43. package/dist/main/layouts/components/AppTabsContextMenu.vue.d.ts +38 -0
  44. package/dist/main/layouts/composables/useAppMenus.d.ts +23 -0
  45. package/dist/main/layouts/composables/useShortcutLabel.d.ts +4 -0
  46. package/dist/main/layouts/utils/menuIcons.d.ts +1 -0
  47. package/dist/main/layouts/utils/menuSearch.d.ts +3 -0
  48. package/dist/main/micro-apps/config.d.ts +25 -0
  49. package/dist/main/micro-apps/register.d.ts +1 -0
  50. package/dist/main/micro-apps/status.d.ts +39 -0
  51. package/dist/main/micro-apps/types.d.ts +39 -0
  52. package/dist/main/pages/auth/Login.vue.d.ts +3 -0
  53. package/dist/main/pages/error/Forbidden.vue.d.ts +3 -0
  54. package/dist/main/pages/error/NotFound.vue.d.ts +3 -0
  55. package/dist/main/pages/micro/MicroAppView.vue.d.ts +3 -0
  56. package/dist/main/pages/system/SystemConfig.vue.d.ts +3 -0
  57. package/dist/main/pages/system/application-config/index.vue.d.ts +3 -0
  58. package/dist/main/router/base-routes.d.ts +2 -0
  59. package/dist/main/router/guard.d.ts +2 -0
  60. package/dist/main/router/index.d.ts +8 -0
  61. package/dist/main/settings/components/SystemSettingsDrawer.vue.d.ts +3 -0
  62. package/dist/main/settings/components/ThemeToggleButton.vue.d.ts +3 -0
  63. package/dist/main/settings/components/ThemedSvgImage.vue.d.ts +10 -0
  64. package/dist/main/stores/app.d.ts +85 -0
  65. package/dist/main/stores/auth.d.ts +110 -0
  66. package/dist/main/stores/index.d.ts +4 -0
  67. package/dist/main/stores/system.d.ts +111 -0
  68. package/dist/main/stores/tabs.d.ts +83 -0
  69. package/dist/main/utils/auth.d.ts +1 -0
  70. package/dist/main/utils/persistence.d.ts +3 -0
  71. package/dist/main/utils/storage.d.ts +3 -0
  72. package/dist/main/utils/theme.d.ts +20 -0
  73. package/dist/main.js +5 -0
  74. package/dist/micro-contract/index.d.ts +13 -0
  75. package/dist/micro-contract.js +4 -0
  76. package/dist/request/index.d.ts +72 -0
  77. package/dist/request.js +153 -0
  78. package/dist/sub/app/mount.d.ts +7 -0
  79. package/dist/sub/composables/useRequestClient.d.ts +5 -0
  80. package/dist/sub/composables/useSubAppContext.d.ts +1 -0
  81. package/dist/sub/context/sub-app-context.d.ts +10 -0
  82. package/dist/sub/index.d.ts +8 -0
  83. package/dist/sub/qiankun/index.d.ts +38 -0
  84. package/dist/sub/router/index.d.ts +2 -0
  85. package/dist/sub/theme/index.d.ts +2 -0
  86. package/dist/sub.js +2 -0
  87. package/package.json +86 -0
@@ -0,0 +1,248 @@
1
+ import { clearAccessToken as e, clearAuthProfile as t, getAccessToken as n, setAccessToken as r, setAuthProfile as i } from "../auth.js";
2
+ import { n as a, r as o, t as s } from "./storage-DNllLr_D.js";
3
+ import { computed as c, ref as l } from "vue";
4
+ import { defineStore as u } from "pinia";
5
+ //#region src/main/api/adapter.ts
6
+ var d = {
7
+ id: "mock-admin",
8
+ name: "admin",
9
+ role: "admin",
10
+ roleLabel: "系统管理员"
11
+ }, f = [{
12
+ id: "admin",
13
+ code: "admin",
14
+ name: "系统管理员"
15
+ }], p = [
16
+ "system:user:view",
17
+ "system:user:create",
18
+ "system:user:edit"
19
+ ];
20
+ function m(e) {
21
+ return { token: `mock-token-${e || d.name}` };
22
+ }
23
+ function h() {
24
+ return {
25
+ user: d,
26
+ roles: f,
27
+ permissions: p,
28
+ menus: []
29
+ };
30
+ }
31
+ function g(e, t = "") {
32
+ if (!e || typeof e != "object") return m(t);
33
+ let n = e;
34
+ return { token: T(w(n.data) ?? n, [
35
+ "token",
36
+ "accessToken",
37
+ "access_token"
38
+ ]) || m(t).token };
39
+ }
40
+ function _(e) {
41
+ if (!e || typeof e != "object") return h();
42
+ let t = e, n = w(t.data) ?? t, r = v(n.user ?? n.userInfo ?? n.user_info), i = b(n.roles ?? n.roleList ?? n.role_list ?? n.userRoles), a = C(n.menus ?? n.menu ?? n.routes ?? n.router);
43
+ return {
44
+ user: r,
45
+ roles: i,
46
+ permissions: y(n.permissions ?? n.permission),
47
+ menus: a
48
+ };
49
+ }
50
+ function v(e, t = "") {
51
+ let n = w(e);
52
+ return n ? {
53
+ id: T(n, [
54
+ "id",
55
+ "userId",
56
+ "user_id"
57
+ ]) || E(n, [
58
+ "id",
59
+ "userId",
60
+ "user_id"
61
+ ]),
62
+ name: T(n, [
63
+ "name",
64
+ "username",
65
+ "nickname",
66
+ "realName"
67
+ ]) || t || d.name,
68
+ role: T(n, [
69
+ "role",
70
+ "roleCode",
71
+ "role_code"
72
+ ]) || d.role,
73
+ roleLabel: T(n, [
74
+ "roleLabel",
75
+ "roleName",
76
+ "role_name"
77
+ ]) || d.roleLabel
78
+ } : {
79
+ ...d,
80
+ name: t || d.name
81
+ };
82
+ }
83
+ function y(e) {
84
+ let t = /* @__PURE__ */ new Set();
85
+ return S(e, t), t.size ? Array.from(t) : p;
86
+ }
87
+ function b(e) {
88
+ if (!e) return f;
89
+ if (typeof e == "string") return [{
90
+ code: e,
91
+ name: e
92
+ }];
93
+ if (!Array.isArray(e)) {
94
+ let t = x(e);
95
+ return t ? [t] : f;
96
+ }
97
+ let t = e.map((e) => x(e)).filter((e) => !!e);
98
+ return t.length ? t : f;
99
+ }
100
+ function x(e) {
101
+ if (typeof e == "string") return {
102
+ code: e,
103
+ name: e
104
+ };
105
+ let t = w(e);
106
+ if (!t) return null;
107
+ let n = T(t, [
108
+ "code",
109
+ "roleCode",
110
+ "role_code",
111
+ "key",
112
+ "value"
113
+ ]), r = T(t, [
114
+ "name",
115
+ "roleName",
116
+ "role_name",
117
+ "label",
118
+ "title"
119
+ ]) || n;
120
+ return !n && !r ? null : {
121
+ id: T(t, [
122
+ "id",
123
+ "roleId",
124
+ "role_id"
125
+ ]) || E(t, [
126
+ "id",
127
+ "roleId",
128
+ "role_id"
129
+ ]),
130
+ code: n || r,
131
+ name: r
132
+ };
133
+ }
134
+ function S(e, t) {
135
+ if (!e) return;
136
+ if (typeof e == "string") {
137
+ t.add(e);
138
+ return;
139
+ }
140
+ if (Array.isArray(e)) {
141
+ e.forEach((e) => S(e, t));
142
+ return;
143
+ }
144
+ let n = w(e);
145
+ n && (S(n.path, t), S(n.code, t), S(n.permission, t), S(n.permissions, t));
146
+ }
147
+ function C(e) {
148
+ return Array.isArray(e) ? e.filter((e) => !!(e && typeof e == "object")) : [];
149
+ }
150
+ function w(e) {
151
+ return e && typeof e == "object" && !Array.isArray(e) ? e : null;
152
+ }
153
+ function T(e, t) {
154
+ for (let n of t) {
155
+ let t = e[n];
156
+ if (typeof t == "string" && t) return t;
157
+ }
158
+ return "";
159
+ }
160
+ function E(e, t) {
161
+ for (let n of t) {
162
+ let t = e[n];
163
+ if (typeof t == "number") return t;
164
+ }
165
+ }
166
+ //#endregion
167
+ //#region src/main/api/auth.ts
168
+ async function D(e) {
169
+ return await Promise.resolve(m(e.username));
170
+ }
171
+ async function O() {
172
+ await Promise.resolve();
173
+ }
174
+ async function k() {
175
+ return await Promise.resolve(h());
176
+ }
177
+ //#endregion
178
+ //#region src/main/stores/auth.ts
179
+ var A = "auth-user", j = "auth-roles", M = "auth-permissions", N = {
180
+ id: "mock-admin",
181
+ name: "admin",
182
+ role: "admin",
183
+ roleLabel: "系统管理员"
184
+ }, P = u("auth", () => {
185
+ let u = l(n()), d = l(s(A, N)), f = l(s(j, h().roles)), p = l(s(M, h().permissions)), m = l(!1), g = c(() => !!u.value), _ = c(() => d.value.name || N.name), v = c(() => d.value.role || N.role), y = c(() => v.value === "admin" || f.value.some((e) => e.code === "admin") || p.value.includes("*")), b = c(() => d.value.roleLabel || (v.value === "admin" ? "系统管理员" : "业务用户"));
186
+ async function x() {
187
+ if (m.value) {
188
+ m.value = !0;
189
+ return;
190
+ }
191
+ if (!u.value) {
192
+ m.value = !0;
193
+ return;
194
+ }
195
+ let e = await k();
196
+ C({
197
+ token: u.value,
198
+ user: e.user,
199
+ roles: e.roles,
200
+ permissions: e.permissions
201
+ }), m.value = !0;
202
+ }
203
+ async function S(e) {
204
+ let t = await D({
205
+ username: e.username,
206
+ password: e.password ?? ""
207
+ });
208
+ C(t);
209
+ let n = await k();
210
+ return C({
211
+ token: t.token,
212
+ user: n.user,
213
+ roles: n.roles,
214
+ permissions: n.permissions
215
+ }), t;
216
+ }
217
+ function C(e) {
218
+ u.value = e.token, d.value = e.user || N, f.value = e.roles?.length ? e.roles : h().roles, p.value = e.permissions?.length ? e.permissions : h().permissions, r(u.value), i({
219
+ user: d.value,
220
+ roles: f.value,
221
+ permissions: p.value
222
+ }), o(A, d.value), o(j, f.value), o(M, p.value);
223
+ }
224
+ async function w() {
225
+ await O(), u.value = "", d.value = N, f.value = h().roles, p.value = h().permissions, m.value = !1, e(), t(), a(A), a(j), a(M);
226
+ }
227
+ function T(e) {
228
+ return !e || y.value ? !0 : p.value.includes(e);
229
+ }
230
+ return {
231
+ initAuth: x,
232
+ isAuthenticated: g,
233
+ login: S,
234
+ logout: w,
235
+ hasPermission: T,
236
+ initialized: m,
237
+ isSuperAdmin: y,
238
+ permissions: p,
239
+ roles: f,
240
+ token: u,
241
+ user: d,
242
+ userName: _,
243
+ userRole: v,
244
+ userRoleLabel: b
245
+ };
246
+ });
247
+ //#endregion
248
+ export { _ as a, g as i, m as n, h as r, P as t };
@@ -0,0 +1,44 @@
1
+ import { r as e, t } from "./storage-DNllLr_D.js";
2
+ //#region src/main/micro-apps/config.ts
3
+ var n = "system:apps", r = [{
4
+ id: "sub-orders",
5
+ name: "订单子应用",
6
+ type: "sub",
7
+ description: "独立业务子应用,先在本地配置里测试子应用结构和菜单入口。",
8
+ basePath: "/micro/sub-app",
9
+ entry: "http://localhost:5174"
10
+ }], i = "micro-app-container";
11
+ function a() {
12
+ return t(n, r).filter((e) => e.type === "sub");
13
+ }
14
+ async function o(t) {
15
+ await e(n, t);
16
+ }
17
+ function s(e) {
18
+ return e.map((e) => ({
19
+ id: e.id,
20
+ name: l(e),
21
+ title: e.name,
22
+ entry: e.entry || "http://localhost:5174",
23
+ activeRule: u(e.basePath),
24
+ container: "#micro-app-container"
25
+ }));
26
+ }
27
+ function c(e) {
28
+ return {
29
+ id: "id" in e ? String(e.id) : e.name,
30
+ name: e.name,
31
+ title: e.title,
32
+ entry: e.entry,
33
+ activeRule: e.activeRule
34
+ };
35
+ }
36
+ function l(e) {
37
+ return `morningfast-${e.id}`;
38
+ }
39
+ function u(e) {
40
+ let t = e.trim() || "/micro";
41
+ return t.startsWith("/") ? t : `/${t}`;
42
+ }
43
+ //#endregion
44
+ export { o as a, u as i, a as n, c as o, s as r, i as t };