@ibiz-template/mob-vue3-components 0.0.12 → 0.0.14

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 (89) hide show
  1. package/dist/index.min.css +1 -1
  2. package/dist/index.system.min.js +5 -5
  3. package/dist/index.system.min.js.map +1 -1
  4. package/es/control/app-menu/app-menu.d.ts +1 -1
  5. package/es/control/app-menu/app-menu.mjs +5 -3
  6. package/es/control/app-menu/index.d.ts +1 -1
  7. package/es/control/form/form-detail/form-item/form-item-container/form-item-container.mjs +1 -1
  8. package/es/editor/data-picker/ibiz-picker-select-view/ibiz-picker-select-view.d.ts +1 -0
  9. package/es/editor/date-picker/date-picker-editor.controller.d.ts +0 -8
  10. package/es/editor/date-picker/date-picker-editor.controller.mjs +0 -11
  11. package/es/editor/date-range/date-range-editor.controller.d.ts +0 -8
  12. package/es/editor/date-range/date-range-editor.controller.mjs +0 -20
  13. package/es/editor/span/span/span.d.ts +3 -0
  14. package/es/ibiz-vue3.d.ts +6 -0
  15. package/es/ibiz-vue3.mjs +75 -0
  16. package/es/index.d.ts +6 -10
  17. package/es/index.mjs +89 -135
  18. package/es/mob-app/App.css +1 -0
  19. package/es/mob-app/App.d.ts +11 -0
  20. package/es/mob-app/App.mjs +64 -0
  21. package/es/mob-app/attach-environment-config.d.ts +1 -0
  22. package/es/mob-app/attach-environment-config.mjs +22 -0
  23. package/es/mob-app/components/home-view/home-view.css +1 -0
  24. package/es/mob-app/components/home-view/home-view.d.ts +17 -0
  25. package/es/mob-app/components/home-view/home-view.mjs +38 -0
  26. package/es/mob-app/components/index.d.ts +3 -0
  27. package/es/mob-app/components/index.mjs +4 -0
  28. package/es/mob-app/components/router-shell/router-shell.d.ts +33 -0
  29. package/es/mob-app/components/router-shell/router-shell.mjs +82 -0
  30. package/es/mob-app/create-vue-app.d.ts +12 -0
  31. package/es/mob-app/create-vue-app.mjs +38 -0
  32. package/es/mob-app/guard/auth-guard/auth-guard.d.ts +9 -0
  33. package/es/mob-app/guard/auth-guard/auth-guard.mjs +141 -0
  34. package/es/mob-app/guard/index.d.ts +1 -0
  35. package/es/mob-app/guard/index.mjs +3 -0
  36. package/es/mob-app/index.d.ts +1 -0
  37. package/es/mob-app/index.mjs +3 -0
  38. package/es/mob-app/main.d.ts +2 -0
  39. package/es/mob-app/main.mjs +60 -0
  40. package/es/mob-app/router/index.d.ts +21 -0
  41. package/es/mob-app/router/index.mjs +178 -0
  42. package/es/mob-app/util/index.d.ts +1 -0
  43. package/es/mob-app/util/index.mjs +3 -0
  44. package/es/mob-app/util/unauthorized-handler/unauthorized-handler.d.ts +46 -0
  45. package/es/mob-app/util/unauthorized-handler/unauthorized-handler.mjs +100 -0
  46. package/es/panel-component/index.mjs +2 -1
  47. package/es/panel-component/panel-button/index.d.ts +1 -1
  48. package/es/panel-component/panel-button/panel-button.d.ts +1 -1
  49. package/es/util/app-modal/app-modal-component.d.ts +1 -0
  50. package/es/util/notification-util/notification-util.d.ts +1 -0
  51. package/es/util/notification-util/notification-util.mjs +3 -0
  52. package/es/util/open-view-util/open-view-util.d.ts +2 -1
  53. package/es/util/open-view-util/open-view-util.mjs +5 -2
  54. package/es/util/store/view-stack/view-stack.mjs +5 -1
  55. package/es/view-engine/mob-edit-view.engine.mjs +5 -1
  56. package/lib/control/app-menu/app-menu.cjs +5 -3
  57. package/lib/control/form/form-detail/form-item/form-item-container/form-item-container.cjs +1 -1
  58. package/lib/editor/date-picker/date-picker-editor.controller.cjs +0 -11
  59. package/lib/editor/date-range/date-range-editor.controller.cjs +0 -20
  60. package/lib/editor/upload/ibiz-image-select/ibiz-image-select.cjs +2 -2
  61. package/lib/editor/upload/ibiz-image-upload/ibiz-image-upload.cjs +2 -2
  62. package/lib/ibiz-vue3.cjs +79 -0
  63. package/lib/index.cjs +177 -221
  64. package/lib/mob-app/App.cjs +68 -0
  65. package/lib/mob-app/App.css +1 -0
  66. package/lib/mob-app/attach-environment-config.cjs +24 -0
  67. package/lib/mob-app/components/home-view/home-view.cjs +40 -0
  68. package/lib/mob-app/components/home-view/home-view.css +1 -0
  69. package/lib/mob-app/components/index.cjs +9 -0
  70. package/lib/mob-app/components/router-shell/router-shell.cjs +84 -0
  71. package/lib/mob-app/create-vue-app.cjs +40 -0
  72. package/lib/mob-app/guard/auth-guard/auth-guard.cjs +143 -0
  73. package/lib/mob-app/guard/index.cjs +7 -0
  74. package/lib/mob-app/index.cjs +7 -0
  75. package/lib/mob-app/main.cjs +62 -0
  76. package/lib/mob-app/router/index.cjs +180 -0
  77. package/lib/mob-app/util/index.cjs +7 -0
  78. package/lib/mob-app/util/unauthorized-handler/unauthorized-handler.cjs +102 -0
  79. package/lib/panel-component/index.cjs +1 -0
  80. package/lib/util/confirm-util/confirm-util.cjs +5 -5
  81. package/lib/util/directive/loading.cjs +2 -2
  82. package/lib/util/loading-util/loading-util.cjs +2 -2
  83. package/lib/util/message-util/message-util.cjs +5 -5
  84. package/lib/util/modal-util/modal-util.cjs +6 -6
  85. package/lib/util/notification-util/notification-util.cjs +8 -5
  86. package/lib/util/open-view-util/open-view-util.cjs +5 -2
  87. package/lib/util/store/view-stack/view-stack.cjs +5 -1
  88. package/lib/view-engine/mob-edit-view.engine.cjs +5 -1
  89. package/package.json +8 -7
@@ -0,0 +1,17 @@
1
+ import { PropType } from 'vue';
2
+ import { IModal, Modal } from '@ibiz-template/runtime';
3
+ import './home-view.scss';
4
+ export declare const HomeView: import("vue").DefineComponent<{
5
+ modal: {
6
+ type: PropType<IModal>;
7
+ required: true;
8
+ };
9
+ }, {
10
+ viewModal: Modal;
11
+ ns: import("@ibiz-template/core").Namespace;
12
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
13
+ modal: {
14
+ type: PropType<IModal>;
15
+ required: true;
16
+ };
17
+ }>>, {}, {}>;
@@ -0,0 +1,38 @@
1
+ import { resolveComponent, createVNode, defineComponent } from 'vue';
2
+ import { ViewMode, Modal } from '@ibiz-template/runtime';
3
+ import './home-view.css';
4
+ import { useNamespace } from '@ibiz-template/vue3-util';
5
+
6
+ "use strict";
7
+ const HomeView = /* @__PURE__ */ defineComponent({
8
+ name: "HomeView",
9
+ props: {
10
+ modal: {
11
+ type: Object,
12
+ required: true
13
+ }
14
+ },
15
+ setup(props) {
16
+ const ns = useNamespace("home-view");
17
+ const viewModal = new Modal({
18
+ mode: ViewMode.ROUTE,
19
+ viewUsage: 1,
20
+ routeDepth: props.modal.routeDepth + 1,
21
+ dismiss: () => {
22
+ props.modal.dismiss();
23
+ }
24
+ });
25
+ return {
26
+ viewModal,
27
+ ns
28
+ };
29
+ },
30
+ render() {
31
+ return createVNode(resolveComponent("iBizRouterView"), {
32
+ "class": this.ns.b(),
33
+ "modal": this.viewModal
34
+ }, null);
35
+ }
36
+ });
37
+
38
+ export { HomeView };
@@ -0,0 +1,3 @@
1
+ import { HomeView } from './home-view/home-view';
2
+ import { RouterShell } from './router-shell/router-shell';
3
+ export { RouterShell, HomeView };
@@ -0,0 +1,4 @@
1
+ export { HomeView } from './home-view/home-view.mjs';
2
+ export { RouterShell } from './router-shell/router-shell.mjs';
3
+
4
+ "use strict";
@@ -0,0 +1,33 @@
1
+ import { PropType } from 'vue';
2
+ import { IModal } from '@ibiz-template/runtime';
3
+ export declare const RouterShell: import("vue").DefineComponent<{
4
+ modal: {
5
+ type: PropType<IModal>;
6
+ required: true;
7
+ };
8
+ }, {
9
+ route: import("vue-router").RouteLocationNormalizedLoaded;
10
+ viewData: import("vue").Ref<{
11
+ viewConfig?: {
12
+ id: string;
13
+ appId: string;
14
+ codeName: string;
15
+ openMode: string;
16
+ viewType: string;
17
+ width?: number | undefined;
18
+ height?: number | undefined;
19
+ appDataEntityId?: string | undefined;
20
+ redirectView?: boolean | undefined;
21
+ modalOption?: IData | undefined;
22
+ } | undefined;
23
+ context?: IParams | undefined;
24
+ params?: IParams | undefined;
25
+ srfnav?: string | undefined;
26
+ }>;
27
+ isLoaded: import("vue").Ref<boolean>;
28
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
29
+ modal: {
30
+ type: PropType<IModal>;
31
+ required: true;
32
+ };
33
+ }>>, {}, {}>;
@@ -0,0 +1,82 @@
1
+ import { ref, toRaw, onUnmounted, resolveComponent, h, defineComponent } from 'vue';
2
+ import { parseRouteViewData } from '@ibiz-template/vue3-util';
3
+ import { useRoute, useRouter } from 'vue-router';
4
+ import { IBizContext } from '@ibiz-template/core';
5
+ import { mergeDeepLeft } from 'ramda';
6
+
7
+ "use strict";
8
+ const RouterShell = /* @__PURE__ */ defineComponent({
9
+ name: "RouterShell",
10
+ props: {
11
+ modal: {
12
+ type: Object,
13
+ required: true
14
+ }
15
+ },
16
+ setup(props) {
17
+ const route = useRoute();
18
+ const router = useRouter();
19
+ const viewData = ref({});
20
+ const isLoaded = ref(false);
21
+ const destroyContext = () => {
22
+ if (viewData.value.context) {
23
+ const {
24
+ context
25
+ } = toRaw(viewData.value);
26
+ if (context)
27
+ context.destroy();
28
+ }
29
+ };
30
+ const routeDepth = props.modal.routeDepth || 1;
31
+ onUnmounted(() => {
32
+ destroyContext();
33
+ });
34
+ const calcViewData = async () => {
35
+ try {
36
+ const _viewData = await parseRouteViewData(route, routeDepth);
37
+ const _context = IBizContext.create(_viewData.context);
38
+ viewData.value = {
39
+ ..._viewData,
40
+ context: _context
41
+ };
42
+ isLoaded.value = true;
43
+ } catch (error) {
44
+ router.push({
45
+ name: `404View${routeDepth}`
46
+ });
47
+ }
48
+ };
49
+ calcViewData();
50
+ return {
51
+ route,
52
+ viewData,
53
+ isLoaded
54
+ };
55
+ },
56
+ render() {
57
+ if (!this.isLoaded) {
58
+ return null;
59
+ }
60
+ const {
61
+ context,
62
+ params,
63
+ srfnav,
64
+ viewConfig
65
+ } = this.viewData;
66
+ const props = mergeDeepLeft({
67
+ ...this.$props,
68
+ ...this.$attrs,
69
+ context,
70
+ params,
71
+ viewId: viewConfig.id,
72
+ key: viewConfig.codeName
73
+ }, {
74
+ state: {
75
+ srfnav
76
+ }
77
+ });
78
+ return h(resolveComponent("IBizViewShell"), props, this.$slots);
79
+ }
80
+ });
81
+
82
+ export { RouterShell };
@@ -0,0 +1,12 @@
1
+ import { App, Component } from 'vue';
2
+ /**
3
+ * 创建 vue3 实例,避免多实例情况下全局方法未成功挂载
4
+ *
5
+ * @author chitanda
6
+ * @date 2022-12-29 11:12:25
7
+ * @export
8
+ * @param {Component} rootComponent
9
+ * @param {IData} [rootProps]
10
+ * @return {*} {Promise<App<Element>>}
11
+ */
12
+ export declare function createVueApp(rootComponent: Component, rootProps?: IData): App<Element>;
@@ -0,0 +1,38 @@
1
+ import { createApp, KeepAlive } from 'vue';
2
+ import Vant, { allowMultipleToast } from 'vant';
3
+ import { AppHooks, piniaInstance } from '@ibiz-template/vue3-util';
4
+ import { i18n } from '../locale/index.mjs';
5
+ import IBizVue3 from '../ibiz-vue3.mjs';
6
+ import '../util/index.mjs';
7
+ import { loadingDirective } from '../util/directive/loading.mjs';
8
+
9
+ "use strict";
10
+ allowMultipleToast();
11
+ function createVueApp(rootComponent, rootProps) {
12
+ const app = createApp(rootComponent, rootProps);
13
+ app.component("KeepAlive", KeepAlive);
14
+ app.config.errorHandler = function(err) {
15
+ ibiz.util.error.handle(err);
16
+ };
17
+ const installPlugin = (_, plugin) => {
18
+ app.use(plugin);
19
+ };
20
+ AppHooks.useComponent.tap(installPlugin);
21
+ if (rootProps) {
22
+ const oldUnMounted = rootProps.unmounted;
23
+ rootProps.unmounted = () => {
24
+ oldUnMounted();
25
+ AppHooks.useComponent.removeTap(installPlugin);
26
+ };
27
+ }
28
+ app.use(i18n);
29
+ app.use(Vant);
30
+ app.use(piniaInstance);
31
+ app.use(IBizVue3);
32
+ AppHooks.createApp.callSync(null, app);
33
+ app.directive("loading", loadingDirective);
34
+ ibiz.plugin.register(app);
35
+ return app;
36
+ }
37
+
38
+ export { createVueApp };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 应用权限守卫
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-10-28 10:10:29
6
+ * @export
7
+ * @return {*} {Promise<boolean>}
8
+ */
9
+ export declare function AuthGuard(permission?: boolean): Promise<boolean>;
@@ -0,0 +1,141 @@
1
+ import { CoreConst } from '@ibiz-template/core';
2
+ import { getCookie, setCookie } from 'qx-util';
3
+ import { ModelHelper } from '@ibiz-template/model-helper';
4
+ import { mergeDeepRight } from 'ramda';
5
+ import { AppHooks } from '@ibiz-template/vue3-util';
6
+ import { i18n } from '../../../locale/index.mjs';
7
+
8
+ "use strict";
9
+ async function loadAppData() {
10
+ const res = await ibiz.net.get("/appdata");
11
+ if (res.ok) {
12
+ ibiz.appData = res.data;
13
+ }
14
+ }
15
+ async function loadOrgData() {
16
+ const res = await ibiz.net.get(`/uaa/getbydcsystem/${ibiz.env.dcSystem}`);
17
+ if (res.ok) {
18
+ const orgDataItems = res.data;
19
+ if (orgDataItems) {
20
+ const [data] = orgDataItems;
21
+ ibiz.orgData = data;
22
+ }
23
+ }
24
+ }
25
+ function setRefreshToken() {
26
+ const token = getCookie(CoreConst.TOKEN);
27
+ const expirein = getCookie(CoreConst.TOKEN_EXPIRES);
28
+ if (token && expirein) {
29
+ let wait = Number(expirein) - (/* @__PURE__ */ new Date()).getTime();
30
+ const early = 5 * 60 * 1e3;
31
+ wait = wait > early ? wait - early : 0;
32
+ setTimeout(async () => {
33
+ const res = await ibiz.net.get(`/uaa/refreshtoken2`);
34
+ if (res.ok) {
35
+ setCookie(CoreConst.TOKEN, res.data.token, 0, true);
36
+ const expiredDate = (/* @__PURE__ */ new Date()).getTime() + (res.data.expirein || 7199) * 1e3;
37
+ setCookie(CoreConst.TOKEN_EXPIRES, `${expiredDate}`, 0, true);
38
+ }
39
+ setRefreshToken();
40
+ }, wait);
41
+ }
42
+ }
43
+ async function loadTheme() {
44
+ const app = ibiz.hub.getApp();
45
+ const uiThemes = app.model.appUIThemes || [];
46
+ if (uiThemes.length > 0) {
47
+ const theme = uiThemes[0];
48
+ await ibiz.util.theme.loadTheme(theme);
49
+ }
50
+ }
51
+ let helper;
52
+ async function initModel(permission = true) {
53
+ if (!helper) {
54
+ helper = new ModelHelper(
55
+ async (url) => {
56
+ if (ibiz.env.isLocalModel) {
57
+ const res2 = await ibiz.net.getModel(`./model${url}`);
58
+ return res2.data;
59
+ }
60
+ const res = await ibiz.net.get(
61
+ `${ibiz.env.remoteModelUrl}${url}`,
62
+ void 0,
63
+ permission ? {} : { srfdcsystem: ibiz.env.dcSystem }
64
+ );
65
+ return res.data;
66
+ },
67
+ ibiz.env.appId,
68
+ permission
69
+ );
70
+ const app = await ibiz.hub.getAppAsync(ibiz.env.appId);
71
+ const appModel = app.model;
72
+ ibiz.env.isMob = appModel.mobileApp === true;
73
+ if (ibiz.env.isEnableMultiLan) {
74
+ const lang = ibiz.i18n.getLang();
75
+ const m = await helper.getPSAppLang(lang.replace("-", "_").toUpperCase());
76
+ const items = m.languageItems || [];
77
+ const data = {};
78
+ items.forEach((item) => {
79
+ data[item.lanResTag] = item.content;
80
+ });
81
+ i18n.global.mergeLocaleMessage(lang, data);
82
+ }
83
+ if (!appModel.appUIThemes) {
84
+ const module = await import('@ibiz-template/mob-theme');
85
+ const theme = module.default || module;
86
+ AppHooks.useComponent.callSync(null, theme);
87
+ } else {
88
+ await loadTheme();
89
+ }
90
+ }
91
+ }
92
+ async function initEnvironment() {
93
+ if (helper) {
94
+ const app = await helper.getAppModel();
95
+ const userParam = app.userParam;
96
+ if (userParam) {
97
+ Object.keys(userParam).forEach((key) => {
98
+ const value = ibiz.util.rawValue.format(userParam[key]);
99
+ const keys = key.split(".");
100
+ let currentObj = ibiz.env;
101
+ for (let i = 0; i < keys.length; i++) {
102
+ const k = keys[i];
103
+ if (i === keys.length - 1) {
104
+ currentObj[k] = value;
105
+ } else {
106
+ currentObj[k] = currentObj[k] || {};
107
+ currentObj = currentObj[k];
108
+ }
109
+ }
110
+ });
111
+ if (ibiz.env.globalConfig) {
112
+ ibiz.config = mergeDeepRight(ibiz.config, ibiz.env.globalConfig);
113
+ }
114
+ }
115
+ }
116
+ }
117
+ async function appInit() {
118
+ if (ibiz.env.isSaaSMode === true) {
119
+ await loadOrgData();
120
+ }
121
+ await loadAppData();
122
+ await initModel();
123
+ await initEnvironment();
124
+ setRefreshToken();
125
+ }
126
+ async function AuthGuard(permission = true) {
127
+ if (permission) {
128
+ let result = true;
129
+ try {
130
+ await appInit();
131
+ } catch (error) {
132
+ result = false;
133
+ ibiz.util.error.handle(error);
134
+ }
135
+ return result;
136
+ }
137
+ await initModel(false);
138
+ return true;
139
+ }
140
+
141
+ export { AuthGuard };
@@ -0,0 +1 @@
1
+ export { AuthGuard } from './auth-guard/auth-guard';
@@ -0,0 +1,3 @@
1
+ export { AuthGuard } from './auth-guard/auth-guard.mjs';
2
+
3
+ "use strict";
@@ -0,0 +1 @@
1
+ export { runApp } from './main';
@@ -0,0 +1,3 @@
1
+ export { runApp } from './main.mjs';
2
+
3
+ "use strict";
@@ -0,0 +1,2 @@
1
+ import { Plugin } from 'vue';
2
+ export declare function runApp(plugins?: Plugin[]): Promise<void>;
@@ -0,0 +1,60 @@
1
+ import { install } from '@ibiz-template/core';
2
+ import { install as install$1, getPlatformProvider } from '@ibiz-template/runtime';
3
+ import { AppHooks, PluginFactory, OverlayContainer } from '@ibiz-template/vue3-util';
4
+ import App from './App.mjs';
5
+ import { attachEnvironmentConfig } from './attach-environment-config.mjs';
6
+ import { createVueApp } from './create-vue-app.mjs';
7
+ import { AppRouter } from './router/index.mjs';
8
+ import './util/index.mjs';
9
+ import '../util/index.mjs';
10
+ import { UnauthorizedHandler } from './util/unauthorized-handler/unauthorized-handler.mjs';
11
+ import { OpenViewUtil } from '../util/open-view-util/open-view-util.mjs';
12
+ import { MessageUtil } from '../util/message-util/message-util.mjs';
13
+ import { ModalUtil } from '../util/modal-util/modal-util.mjs';
14
+ import { ConfirmUtil } from '../util/confirm-util/confirm-util.mjs';
15
+ import { NotificationUtil } from '../util/notification-util/notification-util.mjs';
16
+ import { LoadingUtil } from '../util/loading-util/loading-util.mjs';
17
+ import { OverlayController } from '../util/overlay-controller/overlay-controller.mjs';
18
+
19
+ "use strict";
20
+ async function runApp(plugins) {
21
+ AppHooks.createApp.tap((_, app2) => {
22
+ if (plugins) {
23
+ plugins.forEach((plugin) => {
24
+ app2.use(plugin);
25
+ });
26
+ }
27
+ });
28
+ install();
29
+ install$1();
30
+ ibiz.plugin = new PluginFactory();
31
+ ibiz.util.error.register(new UnauthorizedHandler());
32
+ const app = createVueApp(App);
33
+ OverlayContainer.createVueApp = createVueApp;
34
+ window.onerror = function(_event, _source, _lineno, _colno, error) {
35
+ if (error) {
36
+ ibiz.util.error.handle(error);
37
+ }
38
+ };
39
+ window.addEventListener("unhandledrejection", function(event) {
40
+ event.preventDefault();
41
+ event.promise.catch((err) => {
42
+ ibiz.util.error.handle(err);
43
+ });
44
+ });
45
+ await attachEnvironmentConfig();
46
+ const router = AppRouter.getRouter();
47
+ app.use(router);
48
+ ibiz.openView = new OpenViewUtil(router);
49
+ ibiz.message = new MessageUtil();
50
+ ibiz.modal = new ModalUtil();
51
+ ibiz.confirm = new ConfirmUtil();
52
+ ibiz.notification = new NotificationUtil();
53
+ ibiz.loading = new LoadingUtil();
54
+ ibiz.overlay = new OverlayController();
55
+ ibiz.platform = getPlatformProvider();
56
+ await ibiz.i18n.init();
57
+ app.mount("#app");
58
+ }
59
+
60
+ export { runApp };
@@ -0,0 +1,21 @@
1
+ import { Router } from 'vue-router';
2
+ export declare class AppRouter {
3
+ private static router?;
4
+ /**
5
+ * 创建vue路由对象
6
+ * @author lxm
7
+ * @date 2023-06-29 07:56:11
8
+ * @protected
9
+ * @static
10
+ * @return {*}
11
+ */
12
+ protected static createRouter(): Router;
13
+ /**
14
+ * 获取路由对象
15
+ * @author lxm
16
+ * @date 2023-06-29 07:56:05
17
+ * @static
18
+ * @return {*}
19
+ */
20
+ static getRouter(): Router;
21
+ }
@@ -0,0 +1,178 @@
1
+ import { createWebHashHistory, createRouter } from 'vue-router';
2
+ import { ViewMode, Modal } from '@ibiz-template/runtime';
3
+ import { isNilOrEmpty } from 'qx-util';
4
+ import { AppRedirectView } from '@ibiz-template/vue3-util';
5
+ import '../guard/index.mjs';
6
+ import '../components/index.mjs';
7
+ import '../../view/index.mjs';
8
+ import '../../util/index.mjs';
9
+ import { AuthGuard } from '../guard/auth-guard/auth-guard.mjs';
10
+ import { View404 } from '../../view/404-view/404-view.mjs';
11
+ import { RouterShell } from '../components/router-shell/router-shell.mjs';
12
+ import { LoginView } from '../../view/login-view/login-view.mjs';
13
+ import { HomeView } from '../components/home-view/home-view.mjs';
14
+ import { useViewStack } from '../../util/store/view-stack/view-stack.mjs';
15
+
16
+ "use strict";
17
+ var __defProp = Object.defineProperty;
18
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
19
+ var __publicField = (obj, key, value) => {
20
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+ return value;
22
+ };
23
+ const getPropsCallback = (depth) => {
24
+ if (depth === 1) {
25
+ return () => ({});
26
+ }
27
+ return () => ({
28
+ modal: new Modal({
29
+ mode: ViewMode.ROUTE,
30
+ viewUsage: 1,
31
+ routeDepth: depth
32
+ })
33
+ });
34
+ };
35
+ class AppRouter {
36
+ /**
37
+ * 创建vue路由对象
38
+ * @author lxm
39
+ * @date 2023-06-29 07:56:11
40
+ * @protected
41
+ * @static
42
+ * @return {*}
43
+ */
44
+ static createRouter() {
45
+ const beforeEnter = async (_to, _from, next) => {
46
+ if (!isNilOrEmpty(ibiz.appData)) {
47
+ next();
48
+ }
49
+ const authority = await AuthGuard();
50
+ if (authority) {
51
+ next();
52
+ } else {
53
+ next(false);
54
+ }
55
+ };
56
+ const placeholder = ibiz.env.routePlaceholder;
57
+ const paramReg = `[^/]+=[^/]+|${placeholder}`;
58
+ const viewReg = `[^=/]+`;
59
+ const children = [
60
+ {
61
+ path: "404",
62
+ name: "404View2",
63
+ meta: { preset: true },
64
+ component: View404
65
+ },
66
+ {
67
+ path: `:view2(${viewReg})/:params2(${paramReg})`,
68
+ component: RouterShell,
69
+ props: getPropsCallback(2),
70
+ children: [
71
+ {
72
+ path: "404",
73
+ name: "404View3",
74
+ meta: { preset: true },
75
+ component: View404
76
+ },
77
+ {
78
+ path: `:view3(${viewReg})/:params3(${paramReg})`,
79
+ component: RouterShell,
80
+ props: getPropsCallback(3),
81
+ children: [
82
+ {
83
+ path: "404",
84
+ name: "404View4",
85
+ meta: { preset: true },
86
+ component: View404
87
+ },
88
+ {
89
+ path: `:view4(${viewReg})/:params4(${paramReg})`,
90
+ component: RouterShell,
91
+ props: getPropsCallback(4)
92
+ },
93
+ {
94
+ path: ":pathMatch(.*)*",
95
+ redirect: { name: "404View4" }
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ path: ":pathMatch(.*)*",
101
+ redirect: { name: "404View3" }
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ path: ":pathMatch(.*)*",
107
+ redirect: { name: "404View2" }
108
+ }
109
+ ];
110
+ return createRouter({
111
+ // 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
112
+ history: createWebHashHistory(),
113
+ routes: [
114
+ {
115
+ path: "/",
116
+ redirect: {
117
+ replace: true,
118
+ path: `/${placeholder}/index/${placeholder}`
119
+ }
120
+ },
121
+ {
122
+ path: "/login",
123
+ name: "loginView",
124
+ meta: { preset: true },
125
+ component: LoginView
126
+ },
127
+ {
128
+ path: "/404",
129
+ name: "404View1",
130
+ meta: { preset: true },
131
+ component: View404
132
+ },
133
+ {
134
+ path: "/appredirectview",
135
+ name: "appRedirectView",
136
+ meta: { preset: true },
137
+ beforeEnter,
138
+ component: AppRedirectView
139
+ },
140
+ {
141
+ path: `/:appContext(${paramReg})/home/:params1(${paramReg})`,
142
+ meta: { home: true },
143
+ beforeEnter,
144
+ component: HomeView,
145
+ children
146
+ },
147
+ {
148
+ path: `/:appContext(${paramReg})/:view1(${viewReg})/:params1(${paramReg})`,
149
+ beforeEnter,
150
+ component: RouterShell,
151
+ children
152
+ },
153
+ {
154
+ path: "/:pathMatch(.*)*",
155
+ redirect: { name: "404View1" }
156
+ }
157
+ ]
158
+ });
159
+ }
160
+ /**
161
+ * 获取路由对象
162
+ * @author lxm
163
+ * @date 2023-06-29 07:56:05
164
+ * @static
165
+ * @return {*}
166
+ */
167
+ static getRouter() {
168
+ if (!this.router) {
169
+ this.router = this.createRouter();
170
+ const { init } = useViewStack();
171
+ init(this.router);
172
+ }
173
+ return this.router;
174
+ }
175
+ }
176
+ __publicField(AppRouter, "router");
177
+
178
+ export { AppRouter };
@@ -0,0 +1 @@
1
+ export { UnauthorizedHandler } from './unauthorized-handler/unauthorized-handler';
@@ -0,0 +1,3 @@
1
+ export { UnauthorizedHandler } from './unauthorized-handler/unauthorized-handler.mjs';
2
+
3
+ "use strict";