@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,24 @@
1
+ import { onMounted, onBeforeUnmount } from 'vue';
2
+
3
+ let registeredHandlers = [];
4
+ const cacchedHandler = (event) => {
5
+ for (let registeredHandler of registeredHandlers) {
6
+ registeredHandler(event);
7
+ }
8
+ };
9
+ const useKeydown = (handler) => {
10
+ onMounted(() => {
11
+ if (!registeredHandlers.length) {
12
+ document.addEventListener("keydown", cacchedHandler);
13
+ }
14
+ registeredHandlers.push(handler);
15
+ });
16
+ onBeforeUnmount(() => {
17
+ registeredHandlers = registeredHandlers.filter((registeredHandler) => registeredHandler !== handler);
18
+ if (!registeredHandlers.length) {
19
+ document.removeEventListener("keydown", cacchedHandler);
20
+ }
21
+ });
22
+ };
23
+
24
+ export { useKeydown };
@@ -0,0 +1,12 @@
1
+ import { useKeydown } from './use-keydown.mjs';
2
+
3
+ const useSaveKeydown = (handler) => {
4
+ useKeydown((event) => {
5
+ if (event.key.toLocaleLowerCase() === "s" && (event.ctrlKey || event.metaKey)) {
6
+ event.preventDefault();
7
+ handler(event);
8
+ }
9
+ });
10
+ };
11
+
12
+ export { useSaveKeydown };
@@ -0,0 +1,68 @@
1
+ import { useGlobalConfig } from '../use-global-config/index.mjs';
2
+
3
+ const defaultNamespace = "web";
4
+ const statePrefix = "is-";
5
+ const _bem = (namespace, block, blockSuffix, element, modifier) => {
6
+ let cls = `${namespace}-${block}`;
7
+ if (blockSuffix) {
8
+ cls += `-${blockSuffix}`;
9
+ }
10
+ if (element) {
11
+ cls += `__${element}`;
12
+ }
13
+ if (modifier) {
14
+ cls += `--${modifier}`;
15
+ }
16
+ return cls;
17
+ };
18
+ const useNamespace = (block) => {
19
+ const namespace = useGlobalConfig("namespace", defaultNamespace);
20
+ const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
21
+ const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
22
+ const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
23
+ const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
24
+ const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
25
+ const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
26
+ const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
27
+ const is = (name, ...args) => {
28
+ const state = args.length >= 1 ? args[0] : true;
29
+ return name && state ? `${statePrefix}${name}` : "";
30
+ };
31
+ const cssVar = (object) => {
32
+ const styles = {};
33
+ for (const key in object) {
34
+ if (object[key]) {
35
+ styles[`--${namespace.value}-${key}`] = object[key];
36
+ }
37
+ }
38
+ return styles;
39
+ };
40
+ const cssVarBlock = (object) => {
41
+ const styles = {};
42
+ for (const key in object) {
43
+ if (object[key]) {
44
+ styles[`--${namespace.value}-${block}-${key}`] = object[key];
45
+ }
46
+ }
47
+ return styles;
48
+ };
49
+ const cssVarName = (name) => `--${namespace.value}-${name}`;
50
+ const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
51
+ return {
52
+ namespace,
53
+ b,
54
+ e,
55
+ m,
56
+ be,
57
+ em,
58
+ bm,
59
+ bem,
60
+ is,
61
+ cssVar,
62
+ cssVarName,
63
+ cssVarBlock,
64
+ cssVarBlockName
65
+ };
66
+ };
67
+
68
+ export { defaultNamespace, useNamespace };
@@ -0,0 +1,9 @@
1
+ import { computed } from 'vue';
2
+ import { applicationKey } from '@ctzy-web-client/tokens';
3
+ import { useGlobalConfig } from '../use-global-config/index.mjs';
4
+
5
+ const useService = function(key) {
6
+ return computed(() => useGlobalConfig(applicationKey).value.getIocContainer().getService(key));
7
+ };
8
+
9
+ export { useService };
@@ -0,0 +1,9 @@
1
+ import { computed } from 'vue';
2
+ import { applicationKey } from '@ctzy-web-client/tokens';
3
+ import { useGlobalConfig } from '../use-global-config/index.mjs';
4
+
5
+ const useValue = function(key) {
6
+ return computed(() => useGlobalConfig(applicationKey).value.getIocContainer().getValue(key));
7
+ };
8
+
9
+ export { useValue };
package/es/index.mjs ADDED
@@ -0,0 +1,20 @@
1
+ import './interceptors/index.mjs';
2
+ export { BwaApplication, BwaMicroApplication } from './application/index.mjs';
3
+ import './hooks/index.mjs';
4
+ export * from '@ctzy-web-client/data-model';
5
+ export * from '@ctzy-web-client/ioc';
6
+ export * from '@ctzy-web-client/support';
7
+ export * from '@ctzy-web-client/tokens';
8
+ export { RequestInterceptors } from './interceptors/RequestInterceptors.mjs';
9
+ export { RouterInterceptors } from './interceptors/RouterInterceptors.mjs';
10
+ export { Application } from './application/Application.mjs';
11
+ export { provideGlobalConfig, useGlobalConfig } from './hooks/use-global-config/index.mjs';
12
+ export { defaultNamespace, useNamespace } from './hooks/use-namespace/index.mjs';
13
+ export { useDataForm } from './hooks/use-data-form/index.mjs';
14
+ export { useDataTable } from './hooks/use-data-table/index.mjs';
15
+ export { useService } from './hooks/use-service/index.mjs';
16
+ export { useValue } from './hooks/use-value/index.mjs';
17
+ export { useKeydown } from './hooks/use-keydown/use-keydown.mjs';
18
+ export { useSaveKeydown } from './hooks/use-keydown/use-save-keydown.mjs';
19
+ export { useEventDispatcher } from './hooks/use-event-dispatcher/index.mjs';
20
+ export { useDataTablePage } from './hooks/use-data-table-page/index.mjs';
@@ -0,0 +1,25 @@
1
+ class RequestInterceptors {
2
+ request(config) {
3
+ return config;
4
+ }
5
+ requestError(e) {
6
+ return Promise.reject(new Error("\u8BF7\u6C42\u9519\u8BEF"));
7
+ }
8
+ response(response) {
9
+ let {
10
+ data,
11
+ status,
12
+ statusText
13
+ } = response;
14
+ if (status === 200) {
15
+ return data;
16
+ } else {
17
+ throw new Error(`\u8BF7\u6C42\u5F02\u5E38:[${status}] ${statusText}`);
18
+ }
19
+ }
20
+ responseError(e) {
21
+ return Promise.reject(new Error("\u8BF7\u6C42\u9519\u8BEF"));
22
+ }
23
+ }
24
+
25
+ export { RequestInterceptors };
@@ -0,0 +1,36 @@
1
+ import { initializerDefineProperty as _initializerDefineProperty, applyDecoratedDescriptor as _applyDecoratedDescriptor } from '../_virtual/_rollupPluginBabelHelpers.mjs';
2
+ import { inject } from '@ctzy-web-client/ioc-annotations';
3
+
4
+ var _dec, _class, _descriptor;
5
+ let RouterInterceptors = (_dec = inject("Application"), _class = class RouterInterceptors2 {
6
+ constructor() {
7
+ _initializerDefineProperty(this, "application", _descriptor, this);
8
+ }
9
+ async needWaitRouteLoad(to) {
10
+ if (!to.matched.length && this.application._resolveRoutesPromise) {
11
+ await this.application._resolveRoutesPromise;
12
+ return true;
13
+ }
14
+ return false;
15
+ }
16
+ afterEach(to, from, failure) {
17
+ }
18
+ async beforeEach(to, from, next) {
19
+ if (await this.needWaitRouteLoad(to)) {
20
+ return next(to);
21
+ }
22
+ return next();
23
+ }
24
+ beforeResolve(to, from, next) {
25
+ return next();
26
+ }
27
+ }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "application", [_dec], {
28
+ configurable: true,
29
+ enumerable: true,
30
+ writable: true,
31
+ initializer: function() {
32
+ return null;
33
+ }
34
+ }), _class);
35
+
36
+ export { RouterInterceptors };
@@ -0,0 +1,2 @@
1
+ export { RequestInterceptors } from './RequestInterceptors.mjs';
2
+ export { RouterInterceptors } from './RouterInterceptors.mjs';
@@ -0,0 +1,14 @@
1
+ import { reactive } from 'vue';
2
+ import { InstantiationService } from '@ctzy-web-client/ioc';
3
+
4
+ class ReactiveInstantiationService extends InstantiationService {
5
+ createInstance(Clazz, option) {
6
+ let instance = super.createInstance(Clazz, option);
7
+ if (option == null ? void 0 : option.reactive) {
8
+ instance = reactive(instance);
9
+ }
10
+ return instance;
11
+ }
12
+ }
13
+
14
+ export { ReactiveInstantiationService };
@@ -0,0 +1 @@
1
+ export { ReactiveInstantiationService } from './ReactiveInstantiationService.mjs';
@@ -0,0 +1 @@
1
+ export { pageDataParser } from './pageDataParser.mjs';
@@ -0,0 +1,21 @@
1
+ const pageDataParser = async function(pages) {
2
+ if (typeof pages == "object") {
3
+ const pageModules = await Promise.all(Object.keys(pages).map((path) => pages[path]()));
4
+ return pageModules.map((module) => {
5
+ module.default.inheritAttrs = false;
6
+ return {
7
+ parent: module.parent,
8
+ meta: module.meta,
9
+ route: module.route,
10
+ name: module.name || module.default.name,
11
+ component: module.default,
12
+ redirect: module.redirect,
13
+ props: module.props
14
+ };
15
+ });
16
+ } else {
17
+ pageDeifnes.push(...pages);
18
+ }
19
+ };
20
+
21
+ export { pageDataParser };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _export_sfc = (sfc, props) => {
6
+ const target = sfc.__vccOpts || sfc;
7
+ for (const [key, val] of props) {
8
+ target[key] = val;
9
+ }
10
+ return target;
11
+ };
12
+
13
+ exports["default"] = _export_sfc;