@ctzy-web-client/web-base-client-vue 1.0.1

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 (86) hide show
  1. package/es/_virtual/_plugin-vue_export-helper.mjs +9 -0
  2. package/es/_virtual/_rollupPluginBabelHelpers.mjs +2830 -0
  3. package/es/application/Application2.mjs +42 -0
  4. package/es/application/MicroApplication.mjs +49 -0
  5. package/es/application/app.mjs +34 -0
  6. package/es/application/application.mjs +312 -0
  7. package/es/application/index.mjs +11 -0
  8. package/es/application/micro-application.mjs +59 -0
  9. package/es/constants/index.mjs +1 -0
  10. package/es/hooks/index.mjs +11 -0
  11. package/es/hooks/use-data-form/index.mjs +18 -0
  12. package/es/hooks/use-data-table/index.mjs +18 -0
  13. package/es/hooks/use-data-table-page/index.mjs +47 -0
  14. package/es/hooks/use-event-dispatcher/index.mjs +14 -0
  15. package/es/hooks/use-global-config/index.mjs +47 -0
  16. package/es/hooks/use-keydown/index.mjs +2 -0
  17. package/es/hooks/use-keydown/use-keydown.mjs +24 -0
  18. package/es/hooks/use-keydown/use-save-keydown.mjs +12 -0
  19. package/es/hooks/use-namespace/index.mjs +68 -0
  20. package/es/hooks/use-service/index.mjs +9 -0
  21. package/es/hooks/use-value/index.mjs +9 -0
  22. package/es/index.mjs +20 -0
  23. package/es/interceptors/RequestInterceptors.mjs +25 -0
  24. package/es/interceptors/RouterInterceptors.mjs +36 -0
  25. package/es/interceptors/index.mjs +2 -0
  26. package/es/ioc/ReactiveInstantiationService.mjs +14 -0
  27. package/es/ioc/index.mjs +1 -0
  28. package/es/utils/index.mjs +1 -0
  29. package/es/utils/pageDataParser.mjs +21 -0
  30. package/lib/_virtual/_plugin-vue_export-helper.js +13 -0
  31. package/lib/_virtual/_rollupPluginBabelHelpers.js +2948 -0
  32. package/lib/application/Application2.js +46 -0
  33. package/lib/application/MicroApplication.js +53 -0
  34. package/lib/application/app.js +38 -0
  35. package/lib/application/application.js +316 -0
  36. package/lib/application/index.js +18 -0
  37. package/lib/application/micro-application.js +63 -0
  38. package/lib/constants/index.js +2 -0
  39. package/lib/hooks/index.js +30 -0
  40. package/lib/hooks/use-data-form/index.js +22 -0
  41. package/lib/hooks/use-data-table/index.js +22 -0
  42. package/lib/hooks/use-data-table-page/index.js +51 -0
  43. package/lib/hooks/use-event-dispatcher/index.js +18 -0
  44. package/lib/hooks/use-global-config/index.js +52 -0
  45. package/lib/hooks/use-keydown/index.js +11 -0
  46. package/lib/hooks/use-keydown/use-keydown.js +28 -0
  47. package/lib/hooks/use-keydown/use-save-keydown.js +16 -0
  48. package/lib/hooks/use-namespace/index.js +73 -0
  49. package/lib/hooks/use-service/index.js +13 -0
  50. package/lib/hooks/use-value/index.js +13 -0
  51. package/lib/index.js +68 -0
  52. package/lib/interceptors/RequestInterceptors.js +29 -0
  53. package/lib/interceptors/RouterInterceptors.js +40 -0
  54. package/lib/interceptors/index.js +11 -0
  55. package/lib/ioc/ReactiveInstantiationService.js +18 -0
  56. package/lib/ioc/index.js +9 -0
  57. package/lib/utils/index.js +9 -0
  58. package/lib/utils/pageDataParser.js +25 -0
  59. package/package.json +37 -0
  60. package/src/application/Application.js +538 -0
  61. package/src/application/MicroApplication.js +67 -0
  62. package/src/application/app.vue +22 -0
  63. package/src/application/application.vue +36 -0
  64. package/src/application/index.js +11 -0
  65. package/src/application/micro-application.vue +56 -0
  66. package/src/constants/index.js +0 -0
  67. package/src/hooks/index.js +9 -0
  68. package/src/hooks/use-data-form/index.js +24 -0
  69. package/src/hooks/use-data-table/index.js +22 -0
  70. package/src/hooks/use-data-table-page/index.js +48 -0
  71. package/src/hooks/use-event-dispatcher/index.js +15 -0
  72. package/src/hooks/use-global-config/index.js +49 -0
  73. package/src/hooks/use-keydown/index.js +2 -0
  74. package/src/hooks/use-keydown/use-keydown.js +35 -0
  75. package/src/hooks/use-keydown/use-save-keydown.js +13 -0
  76. package/src/hooks/use-namespace/index.js +90 -0
  77. package/src/hooks/use-service/index.js +15 -0
  78. package/src/hooks/use-value/index.js +15 -0
  79. package/src/index.js +8 -0
  80. package/src/interceptors/RequestInterceptors.js +46 -0
  81. package/src/interceptors/RouterInterceptors.js +47 -0
  82. package/src/interceptors/index.js +2 -0
  83. package/src/ioc/ReactiveInstantiationService.js +29 -0
  84. package/src/ioc/index.js +1 -0
  85. package/src/utils/index.js +1 -0
  86. package/src/utils/pageDataParser.js +27 -0
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var tokens = require('@ctzy-web-client/tokens');
7
+ var vueRouter = require('vue-router');
8
+ require('../hooks/index.js');
9
+ var _pluginVue_exportHelper = require('../_virtual/_plugin-vue_export-helper.js');
10
+ var index = require('../hooks/use-namespace/index.js');
11
+ var index$1 = require('../hooks/use-global-config/index.js');
12
+
13
+ const __default__ = vue.defineComponent({
14
+ name: "BwaApplication"
15
+ });
16
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
17
+ props: {
18
+ application: {
19
+ type: Object,
20
+ required: true
21
+ }
22
+ },
23
+ setup(__props) {
24
+ const props = __props;
25
+ const ns = index.useNamespace("application");
26
+ vue.watch(
27
+ vueRouter.useRoute(),
28
+ (currentRoute) => {
29
+ props.application.emitParentApplication("route-change", currentRoute);
30
+ },
31
+ { immediate: true }
32
+ );
33
+ vue.provide(tokens.applicationKey, vue.ref(props.application));
34
+ index$1.provideGlobalConfig({ [tokens.applicationKey]: props.application }, null, true);
35
+ return (_ctx, _cache) => {
36
+ return vue.openBlock(), vue.createElementBlock("div", {
37
+ class: vue.normalizeClass(vue.unref(ns).b())
38
+ }, [
39
+ vue.renderSlot(_ctx.$slots, "default")
40
+ ], 2);
41
+ };
42
+ }
43
+ });
44
+ var Application = /* @__PURE__ */ _pluginVue_exportHelper["default"](_sfc_main, [["__file", "application.vue"]]);
45
+
46
+ exports["default"] = Application;
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var qiankun = require('qiankun');
6
+
7
+ class MicroApplication {
8
+ constructor(options, application) {
9
+ options = options || {};
10
+ this.name = options.name;
11
+ this.entry = options.entry;
12
+ this.extendOptions = (options == null ? void 0 : options.extendOptions) || {};
13
+ this.ownerApplication = application;
14
+ this._microApp = null;
15
+ this.container = null;
16
+ }
17
+ _loadMicroApp() {
18
+ return qiankun.loadMicroApp({
19
+ name: this.name,
20
+ entry: this.entry,
21
+ container: this.container,
22
+ props: {
23
+ extendOptions: this.extendOptions,
24
+ ownerApplication: this.ownerApplication
25
+ }
26
+ });
27
+ }
28
+ async mountApplication() {
29
+ var _a;
30
+ if (((_a = this._microApp) == null ? void 0 : _a.getStatus()) === "UNMOUNTING") {
31
+ await this._microApp.unmountPromise();
32
+ }
33
+ if (!this._microApp) {
34
+ this.container = document.createElement("div");
35
+ this._microApp = this._loadMicroApp();
36
+ }
37
+ await this._microApp.mountPromise;
38
+ if (this._microApp.getStatus() === "NOT_MOUNTED") {
39
+ await this._microApp.mount();
40
+ }
41
+ }
42
+ async unmountApplication() {
43
+ if (!this._microApp) {
44
+ return;
45
+ }
46
+ if (this._microApp.getStatus() !== "MOUNTED") {
47
+ await this._microApp.mountPromise;
48
+ }
49
+ await this._microApp.unmount();
50
+ }
51
+ }
52
+
53
+ exports.MicroApplication = MicroApplication;
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var application = require('./application2.js');
7
+ var vueRouter = require('vue-router');
8
+ var _pluginVue_exportHelper = require('../_virtual/_plugin-vue_export-helper.js');
9
+
10
+ const _sfc_main = {
11
+ __name: "app",
12
+ props: {
13
+ applicaiton: {
14
+ Object,
15
+ required: true
16
+ }
17
+ },
18
+ setup(__props) {
19
+ const props = __props;
20
+ const { applicaiton } = vue.toRefs(props);
21
+ return (_ctx, _cache) => {
22
+ return vue.openBlock(), vue.createBlock(application["default"], { application: vue.unref(applicaiton) }, {
23
+ default: vue.withCtx(() => [
24
+ (vue.openBlock(), vue.createBlock(vue.Suspense, null, {
25
+ default: vue.withCtx(() => [
26
+ vue.createVNode(vue.unref(vueRouter.RouterView))
27
+ ]),
28
+ _: 1
29
+ }))
30
+ ]),
31
+ _: 1
32
+ }, 8, ["application"]);
33
+ };
34
+ }
35
+ };
36
+ var App = /* @__PURE__ */ _pluginVue_exportHelper["default"](_sfc_main, [["__file", "app.vue"]]);
37
+
38
+ exports["default"] = App;
@@ -0,0 +1,316 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var vueRouter = require('vue-router');
7
+ var support = require('@ctzy-web-client/support');
8
+ var ioc = require('@ctzy-web-client/ioc');
9
+ var dataModel = require('@ctzy-web-client/data-model');
10
+ var MicroApplication = require('./MicroApplication.js');
11
+ require('../utils/index.js');
12
+ var app = require('./app.js');
13
+ require('../interceptors/index.js');
14
+ require('../ioc/index.js');
15
+ var ReactiveInstantiationService = require('../ioc/ReactiveInstantiationService.js');
16
+ var RequestInterceptors = require('../interceptors/RequestInterceptors.js');
17
+ var RouterInterceptors = require('../interceptors/RouterInterceptors.js');
18
+ var pageDataParser = require('../utils/pageDataParser.js');
19
+
20
+ class Application extends support.EventDispatcher {
21
+ constructor(appName, options) {
22
+ super();
23
+ this.appName = appName;
24
+ this.options = options || {};
25
+ this._app = null;
26
+ this._router = null;
27
+ this._history = null;
28
+ this._iocContainer = new ioc.IocContainer();
29
+ this.parent = null;
30
+ this.microApplications = [];
31
+ this.subApplications = [];
32
+ this._targetSelector = "";
33
+ this._extendOptions = null;
34
+ this._plugins = [];
35
+ this.global = options.global;
36
+ this.applicationSlots = /* @__PURE__ */ new Map();
37
+ if (!this.global) {
38
+ throw new Error("options.global \u4E0D\u5B58\u5728");
39
+ }
40
+ this._viewportMountPromise = null;
41
+ this.global.__INNER_APPLICATION__ = this;
42
+ this._initEvent();
43
+ this._initIocContainer();
44
+ this._setRequestInterceptors();
45
+ this._exportLifecycle();
46
+ this._resolveRoutesPromise = null;
47
+ this._mountResolve = null;
48
+ }
49
+ addApplicationSlot(type, id, slot) {
50
+ let withTypeSlots = this.applicationSlots.get(type);
51
+ if (!withTypeSlots) {
52
+ withTypeSlots = /* @__PURE__ */ new Map();
53
+ this.applicationSlots.set(type, withTypeSlots);
54
+ }
55
+ withTypeSlots.set(id, slot);
56
+ this.emit("slot-change", type);
57
+ this.emitParentApplication("slot-change", type);
58
+ }
59
+ removeApplicationSlot(type, id) {
60
+ const withTypeSlots = this.applicationSlots.get(type);
61
+ if (!withTypeSlots) {
62
+ return;
63
+ }
64
+ withTypeSlots.delete(id);
65
+ this.emit("slot-change", type);
66
+ this.emitParentApplication("slot-change", type);
67
+ }
68
+ getApplicationSlots(type) {
69
+ let withTypeSlots = this.applicationSlots.get(type);
70
+ if (!withTypeSlots) {
71
+ return [];
72
+ }
73
+ return Array.from(withTypeSlots.values());
74
+ }
75
+ getIocContainer() {
76
+ return this._iocContainer;
77
+ }
78
+ getInstantiationService() {
79
+ return this.getIocContainer().getService(ioc.InstantiationService);
80
+ }
81
+ createInstance(Clazz, options) {
82
+ return this.getInstantiationService().createInstance(Clazz, options);
83
+ }
84
+ _initIocContainer() {
85
+ this._iocContainer.setInstantiationService(ReactiveInstantiationService.ReactiveInstantiationService);
86
+ this._iocContainer.registerService(RequestInterceptors.RequestInterceptors, RequestInterceptors.RequestInterceptors, {
87
+ overwrite: true
88
+ });
89
+ this._iocContainer.registerService(RouterInterceptors.RouterInterceptors, RouterInterceptors.RouterInterceptors, {
90
+ overwrite: true
91
+ });
92
+ this._iocContainer.registerService(support.HttpRequest, support.HttpRequest, {
93
+ overwrite: true,
94
+ args: [this.options.request || {}]
95
+ });
96
+ this._iocContainer.registerService(dataModel.SimpleOrm, dataModel.SimpleOrm, {
97
+ overwrite: false
98
+ });
99
+ this._iocContainer.registerService(dataModel.DataModelAdapter, dataModel.DataModelAdapter, {
100
+ overwrite: false
101
+ });
102
+ this._iocContainer.registerService("Application", Application, {
103
+ overwrite: false
104
+ });
105
+ this._iocContainer._serviceCollection.setInstance("Application", this);
106
+ this._iocContainer.registerValue("AppName", this.appName || "");
107
+ const delayRegisterServices = this.global.__DELAY_REGISTER_SERVICES__ || [];
108
+ for (const Service of delayRegisterServices) {
109
+ const serviceOptions = Service[ioc.SERVICE_INFO];
110
+ this._iocContainer.registerService(serviceOptions.value, Service, serviceOptions);
111
+ }
112
+ Reflect.deleteProperty(this.global, "__DELAY_REGISTER_SERVICES__");
113
+ }
114
+ _setRequestInterceptors() {
115
+ const httpRequest = this._iocContainer.getService(support.HttpRequest);
116
+ const requestInterceptors = this._iocContainer.getService(RequestInterceptors.RequestInterceptors);
117
+ httpRequest.setOptions(this.options.request);
118
+ httpRequest.addRequestInterceptors(requestInterceptors.request.bind(requestInterceptors), requestInterceptors.requestError.bind(requestInterceptors));
119
+ httpRequest.addResponseInterceptors(requestInterceptors.response.bind(requestInterceptors), requestInterceptors.requestError.bind(requestInterceptors));
120
+ }
121
+ _setRouteInterceptors() {
122
+ const routerInterceptors = this._iocContainer.getService(RouterInterceptors.RouterInterceptors);
123
+ this._router.beforeEach(routerInterceptors.beforeEach.bind(routerInterceptors));
124
+ this._router.beforeResolve(routerInterceptors.beforeResolve.bind(routerInterceptors));
125
+ this._router.afterEach(routerInterceptors.afterEach.bind(routerInterceptors));
126
+ }
127
+ _initVue() {
128
+ this._app = vue.createApp({
129
+ setup: () => {
130
+ const applicaiton = vue.reactive(this);
131
+ return () => vue.h(this.options.app || app["default"], {
132
+ applicaiton
133
+ });
134
+ }
135
+ });
136
+ this._plugins.forEach((plugin) => {
137
+ this._app.use(plugin);
138
+ });
139
+ }
140
+ _initRouter() {
141
+ var _a;
142
+ if (!this._app) {
143
+ throw new Error("Vue\u5B9E\u4F8B\u4E0D\u5B58\u5728");
144
+ }
145
+ let history = null;
146
+ let base = this.options.routeBaseUrl || "/";
147
+ if (this.global.__POWERED_BY_QIANKUN__ && base === "/") {
148
+ base = `/${this.appName}`;
149
+ }
150
+ if ((_a = this._extendOptions) == null ? void 0 : _a.base) {
151
+ base = this._extendOptions.base + base;
152
+ }
153
+ switch (this.options.routeMode) {
154
+ case "hash":
155
+ history = vueRouter.createWebHashHistory(base);
156
+ break;
157
+ case "memory":
158
+ history = vueRouter.createMemoryHistory(base);
159
+ break;
160
+ default:
161
+ history = vueRouter.createWebHistory(base);
162
+ }
163
+ this._history = history;
164
+ this._router = vueRouter.createRouter({
165
+ history,
166
+ routes: []
167
+ });
168
+ this._setRouteInterceptors();
169
+ this._app.use(this._router);
170
+ }
171
+ async _resolveRoutes() {
172
+ let pageDefines = await pageDataParser.pageDataParser(this.options.pages);
173
+ if (!this._router) {
174
+ return;
175
+ }
176
+ pageDefines = pageDefines.filter((pageDefine) => typeof pageDefine.name === "string" && typeof pageDefine.route === "string");
177
+ const routes = pageDefines.map((define) => ({
178
+ name: define.name,
179
+ redirect: define.redirect,
180
+ path: define.route,
181
+ props: define.props || ((route) => Object.assign(route.params, route.query)),
182
+ meta: define.meta,
183
+ component: define.component,
184
+ children: []
185
+ }));
186
+ const rootRoutes = [];
187
+ for (let i = 0, length = routes.length; i < length; i++) {
188
+ const pageDefine = pageDefines[i];
189
+ const route = routes[i];
190
+ for (let j = 0; j < length; j++) {
191
+ if (i === j) {
192
+ continue;
193
+ }
194
+ const innerPageDefine = pageDefines[j];
195
+ const innerRoute = routes[j];
196
+ if (pageDefine.name == null || innerPageDefine.name == null) {
197
+ continue;
198
+ }
199
+ if (pageDefine.name === innerPageDefine.parent) {
200
+ route.children.push(innerRoute);
201
+ }
202
+ }
203
+ if (!pageDefine.parent) {
204
+ rootRoutes.push(route);
205
+ }
206
+ }
207
+ for (const rootRoute of rootRoutes) {
208
+ this._router.addRoute(rootRoute);
209
+ }
210
+ }
211
+ _initEvent() {
212
+ this.on("subApplicationCreate", (application) => {
213
+ this.subApplications.push(application);
214
+ });
215
+ this.on("subApplicationDestroy", (application) => {
216
+ this.subApplications = this.subApplications.filter((app) => app !== application);
217
+ });
218
+ }
219
+ _exportLifecycle() {
220
+ if (!this.global.__POWERED_BY_QIANKUN__ || !this.appName) {
221
+ this._viewportMountPromise = Promise.resolve();
222
+ return;
223
+ }
224
+ if (!this.global.moudleQiankunAppLifeCycles) {
225
+ this.global.moudleQiankunAppLifeCycles = {};
226
+ }
227
+ this.global.moudleQiankunAppLifeCycles[this.appName] = {
228
+ bootstrap: async (props) => {
229
+ },
230
+ mount: async ({
231
+ ownerApplication,
232
+ container,
233
+ extendOptions = {}
234
+ }) => {
235
+ var _a;
236
+ this.parent = ownerApplication || null;
237
+ this._extendOptions = extendOptions;
238
+ this._initVue();
239
+ this._initRouter();
240
+ if (ownerApplication) {
241
+ this._iocContainer.setParent(ownerApplication.getIocContainer());
242
+ }
243
+ if (this._targetSelector) {
244
+ this._app.mount(container.querySelector(this._targetSelector));
245
+ }
246
+ this._resolveRoutesPromise = this._resolveRoutes();
247
+ this._resolveRoutesPromise.then(() => {
248
+ this._resolveRoutesPromise = null;
249
+ });
250
+ if (typeof this._mountResolve === "function") {
251
+ this._mountResolve();
252
+ }
253
+ (_a = this.parent) == null ? void 0 : _a.emit("subApplicationCreate", this);
254
+ },
255
+ unmount: async () => {
256
+ var _a;
257
+ (_a = this.parent) == null ? void 0 : _a.emit("subApplicationDestroy", this);
258
+ this.parent = null;
259
+ this._history.destroy();
260
+ this._app.unmount();
261
+ this._app = null;
262
+ this._router = null;
263
+ this._extendOptions = null;
264
+ this._iocContainer.setParent(null);
265
+ if (this._targetSelector) {
266
+ this.unmount();
267
+ }
268
+ }
269
+ };
270
+ }
271
+ getMicroApplication(name) {
272
+ var _a;
273
+ return (_a = this.microApplications.find((microApplication) => microApplication.name === name)) != null ? _a : null;
274
+ }
275
+ createMicroApplication(options) {
276
+ const microApplication = new MicroApplication.MicroApplication(options, this);
277
+ this.microApplications.push(microApplication);
278
+ return microApplication;
279
+ }
280
+ emitParentApplication(eventName, ...args) {
281
+ if (!this.parent) {
282
+ return;
283
+ }
284
+ this.parent.emit("fromSubApplication", this.appName, eventName, ...args);
285
+ }
286
+ use(plugin) {
287
+ this._plugins.push(plugin);
288
+ return this;
289
+ }
290
+ async mount(target) {
291
+ if (typeof target !== "string") {
292
+ throw new Error("mount: \u6307\u63A5\u53D7\u5B57\u7B26\u4E32\u53C2\u6570\u3002");
293
+ }
294
+ if (this.global.__POWERED_BY_QIANKUN__) {
295
+ const mountPromise = new Promise((resolve) => {
296
+ this._mountResolve = resolve;
297
+ });
298
+ this._targetSelector = target;
299
+ await mountPromise;
300
+ return;
301
+ }
302
+ this._initVue();
303
+ this._initRouter();
304
+ this._app.mount(target);
305
+ this._resolveRoutesPromise = this._resolveRoutes();
306
+ this._resolveRoutesPromise.then(() => {
307
+ this._resolveRoutesPromise = null;
308
+ });
309
+ }
310
+ unmount() {
311
+ var _a;
312
+ (_a = this._app) == null ? void 0 : _a.unmount();
313
+ }
314
+ }
315
+
316
+ exports.Application = Application;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var install = require('element-plus/es/utils/vue/install');
6
+ var application = require('./application2.js');
7
+ var microApplication = require('./micro-application.js');
8
+ var Application = require('./Application.js');
9
+
10
+ const BwaApplication = install.withInstall(application["default"], {
11
+ MicroApplication: microApplication["default"]
12
+ });
13
+ const BwaMicroApplication = install.withInstall(microApplication["default"]);
14
+
15
+ exports.Application = Application.Application;
16
+ exports.BwaApplication = BwaApplication;
17
+ exports.BwaMicroApplication = BwaMicroApplication;
18
+ exports["default"] = BwaApplication;
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var tokens = require('@ctzy-web-client/tokens');
7
+ require('../hooks/index.js');
8
+ var _pluginVue_exportHelper = require('../_virtual/_plugin-vue_export-helper.js');
9
+ var index = require('../hooks/use-namespace/index.js');
10
+ var index$1 = require('../hooks/use-global-config/index.js');
11
+
12
+ const __default__ = vue.defineComponent({
13
+ name: "BwaMcrioApplication"
14
+ });
15
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
16
+ props: {
17
+ name: {
18
+ type: String,
19
+ required: true
20
+ },
21
+ entry: {
22
+ type: String,
23
+ required: true
24
+ },
25
+ extendOptions: {
26
+ type: Object
27
+ }
28
+ },
29
+ async setup(__props) {
30
+ let __temp, __restore;
31
+ const props = __props;
32
+ const ns = index.useNamespace("application");
33
+ const application = index$1.useGlobalConfig(tokens.applicationKey);
34
+ const el = vue.ref(null);
35
+ const microApplication = vue.computed(
36
+ () => application.value.getMicroApplication(props.name) || application.value.createMicroApplication({
37
+ name: props.name,
38
+ entry: props.entry,
39
+ extendOptions: props.extendOptions
40
+ })
41
+ );
42
+ const mountApplicationPromise = microApplication.value.mountApplication();
43
+ vue.onMounted(() => {
44
+ el.value.appendChild(microApplication.value.container);
45
+ });
46
+ vue.onBeforeUnmount(() => {
47
+ el.value.removeChild(microApplication.value.container);
48
+ microApplication.value.unmountApplication();
49
+ });
50
+ ;
51
+ [__temp, __restore] = vue.withAsyncContext(() => mountApplicationPromise), await __temp, __restore();
52
+ return (_ctx, _cache) => {
53
+ return _cache[0] || (vue.setBlockTracking(-1), _cache[0] = vue.createElementVNode("div", {
54
+ ref_key: "el",
55
+ ref: el,
56
+ class: vue.normalizeClass(vue.unref(ns).b("mcrio"))
57
+ }, null, 2), vue.setBlockTracking(1), _cache[0]);
58
+ };
59
+ }
60
+ });
61
+ var MicroApplication = /* @__PURE__ */ _pluginVue_exportHelper["default"](_sfc_main, [["__file", "micro-application.vue"]]);
62
+
63
+ exports["default"] = MicroApplication;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var index = require('./use-global-config/index.js');
6
+ var index$1 = require('./use-namespace/index.js');
7
+ var index$2 = require('./use-data-form/index.js');
8
+ var index$3 = require('./use-data-table/index.js');
9
+ var index$4 = require('./use-service/index.js');
10
+ var index$5 = require('./use-value/index.js');
11
+ require('./use-keydown/index.js');
12
+ var index$6 = require('./use-event-dispatcher/index.js');
13
+ var index$7 = require('./use-data-table-page/index.js');
14
+ var useKeydown = require('./use-keydown/use-keydown.js');
15
+ var useSaveKeydown = require('./use-keydown/use-save-keydown.js');
16
+
17
+
18
+
19
+ exports.provideGlobalConfig = index.provideGlobalConfig;
20
+ exports.useGlobalConfig = index.useGlobalConfig;
21
+ exports.defaultNamespace = index$1.defaultNamespace;
22
+ exports.useNamespace = index$1.useNamespace;
23
+ exports.useDataForm = index$2.useDataForm;
24
+ exports.useDataTable = index$3.useDataTable;
25
+ exports.useService = index$4.useService;
26
+ exports.useValue = index$5.useValue;
27
+ exports.useEventDispatcher = index$6.useEventDispatcher;
28
+ exports.useDataTablePage = index$7.useDataTablePage;
29
+ exports.useKeydown = useKeydown.useKeydown;
30
+ exports.useSaveKeydown = useSaveKeydown.useSaveKeydown;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var dataModel = require('@ctzy-web-client/data-model');
7
+ var tokens = require('@ctzy-web-client/tokens');
8
+ var index = require('../use-global-config/index.js');
9
+
10
+ const useDataForm = (model, options = {}) => {
11
+ const application = index.useGlobalConfig(tokens.applicationKey);
12
+ const dataForm = vue.ref(application.value.createInstance(dataModel.DataForm, {
13
+ args: [{
14
+ model,
15
+ ...options
16
+ }]
17
+ }));
18
+ dataForm.value.init();
19
+ return dataForm;
20
+ };
21
+
22
+ exports.useDataForm = useDataForm;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var dataModel = require('@ctzy-web-client/data-model');
7
+ var tokens = require('@ctzy-web-client/tokens');
8
+ var index = require('../use-global-config/index.js');
9
+
10
+ const useDataTable = (model, options = {}) => {
11
+ const application = index.useGlobalConfig(tokens.applicationKey);
12
+ const dataTable = vue.ref(application.value.createInstance(dataModel.DataTable, {
13
+ args: [{
14
+ model,
15
+ ...options
16
+ }]
17
+ }));
18
+ dataTable.value.init();
19
+ return dataTable;
20
+ };
21
+
22
+ exports.useDataTable = useDataTable;
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var vueRouter = require('vue-router');
7
+ var index = require('../use-event-dispatcher/index.js');
8
+
9
+ const useDataTablePage = (dataTable, options = {}) => {
10
+ options = {
11
+ ...options
12
+ };
13
+ options.currentPage = options.currentPage || "currentPage";
14
+ options.pageSize = options.pageSize || "pageSize";
15
+ const router = vueRouter.useRouter();
16
+ const route = vueRouter.useRoute();
17
+ let {
18
+ currentPage = vue.unref(dataTable).pageNum,
19
+ pageSize = vue.unref(dataTable).pageSize
20
+ } = vue.unref(route).query;
21
+ currentPage = parseInt(currentPage);
22
+ pageSize = parseInt(pageSize);
23
+ if (isNaN(currentPage)) {
24
+ currentPage = vue.unref(dataTable).pageNum;
25
+ }
26
+ if (isNaN(pageSize)) {
27
+ pageSize = vue.unref(dataTable).pageSize;
28
+ }
29
+ vue.unref(dataTable).pageNum = currentPage;
30
+ vue.unref(dataTable).pageSize = pageSize;
31
+ index.useEventDispatcher(dataTable, "current-page-change", (currentPage2) => {
32
+ const query = vue.unref(router.currentRoute).query;
33
+ router.replace({
34
+ query: {
35
+ ...query,
36
+ currentPage: currentPage2
37
+ }
38
+ });
39
+ });
40
+ index.useEventDispatcher(dataTable, "page-size-change", (pageSize2) => {
41
+ const query = vue.unref(router.currentRoute).query;
42
+ router.replace({
43
+ query: {
44
+ ...query,
45
+ pageSize: pageSize2
46
+ }
47
+ });
48
+ });
49
+ };
50
+
51
+ exports.useDataTablePage = useDataTablePage;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+
7
+ const useEventDispatcher = (eventDispatcher, eventName, handler) => {
8
+ vue.onMounted(() => {
9
+ vue.unref(eventDispatcher).on(eventName, handler);
10
+ });
11
+ const off = () => {
12
+ vue.unref(eventDispatcher).off(eventName, handler);
13
+ };
14
+ vue.onUnmounted(off);
15
+ return off;
16
+ };
17
+
18
+ exports.useEventDispatcher = useEventDispatcher;