@ibiz-template/mob-vue3-components 0.0.12 → 0.0.13
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/index.min.css +1 -1
- package/dist/index.system.min.js +5 -5
- package/dist/index.system.min.js.map +1 -1
- package/es/control/app-menu/app-menu.d.ts +1 -1
- package/es/control/app-menu/app-menu.mjs +5 -3
- package/es/control/app-menu/index.d.ts +1 -1
- package/es/control/form/form-detail/form-item/form-item-container/form-item-container.mjs +1 -1
- package/es/editor/date-picker/date-picker-editor.controller.d.ts +0 -8
- package/es/editor/date-picker/date-picker-editor.controller.mjs +0 -11
- package/es/editor/date-range/date-range-editor.controller.d.ts +0 -8
- package/es/editor/date-range/date-range-editor.controller.mjs +0 -20
- package/es/editor/span/span/span.d.ts +3 -0
- package/es/ibiz-vue3.d.ts +6 -0
- package/es/ibiz-vue3.mjs +75 -0
- package/es/index.d.ts +6 -10
- package/es/index.mjs +89 -135
- package/es/mob-app/App.css +1 -0
- package/es/mob-app/App.d.ts +11 -0
- package/es/mob-app/App.mjs +64 -0
- package/es/mob-app/attach-environment-config.d.ts +1 -0
- package/es/mob-app/attach-environment-config.mjs +22 -0
- package/es/mob-app/components/home-view/home-view.css +1 -0
- package/es/mob-app/components/home-view/home-view.d.ts +17 -0
- package/es/mob-app/components/home-view/home-view.mjs +38 -0
- package/es/mob-app/components/index.d.ts +3 -0
- package/es/mob-app/components/index.mjs +4 -0
- package/es/mob-app/components/router-shell/router-shell.d.ts +3867 -0
- package/es/mob-app/components/router-shell/router-shell.mjs +82 -0
- package/es/mob-app/create-vue-app.d.ts +12 -0
- package/es/mob-app/create-vue-app.mjs +38 -0
- package/es/mob-app/guard/auth-guard/auth-guard.d.ts +9 -0
- package/es/mob-app/guard/auth-guard/auth-guard.mjs +141 -0
- package/es/mob-app/guard/index.d.ts +1 -0
- package/es/mob-app/guard/index.mjs +3 -0
- package/es/mob-app/index.d.ts +1 -0
- package/es/mob-app/index.mjs +3 -0
- package/es/mob-app/main.d.ts +2 -0
- package/es/mob-app/main.mjs +60 -0
- package/es/mob-app/router/index.d.ts +21 -0
- package/es/mob-app/router/index.mjs +174 -0
- package/es/mob-app/util/index.d.ts +1 -0
- package/es/mob-app/util/index.mjs +3 -0
- package/es/mob-app/util/unauthorized-handler/unauthorized-handler.d.ts +46 -0
- package/es/mob-app/util/unauthorized-handler/unauthorized-handler.mjs +100 -0
- package/es/panel-component/index.mjs +2 -1
- package/es/util/open-view-util/open-view-util.d.ts +2 -1
- package/es/util/open-view-util/open-view-util.mjs +5 -2
- package/es/view-engine/mob-edit-view.engine.mjs +5 -1
- package/lib/control/app-menu/app-menu.cjs +5 -3
- package/lib/control/form/form-detail/form-item/form-item-container/form-item-container.cjs +1 -1
- package/lib/editor/date-picker/date-picker-editor.controller.cjs +0 -11
- package/lib/editor/date-range/date-range-editor.controller.cjs +0 -20
- package/lib/editor/upload/ibiz-image-select/ibiz-image-select.cjs +2 -2
- package/lib/editor/upload/ibiz-image-upload/ibiz-image-upload.cjs +2 -2
- package/lib/ibiz-vue3.cjs +79 -0
- package/lib/index.cjs +177 -221
- package/lib/mob-app/App.cjs +68 -0
- package/lib/mob-app/App.css +1 -0
- package/lib/mob-app/attach-environment-config.cjs +24 -0
- package/lib/mob-app/components/home-view/home-view.cjs +40 -0
- package/lib/mob-app/components/home-view/home-view.css +1 -0
- package/lib/mob-app/components/index.cjs +9 -0
- package/lib/mob-app/components/router-shell/router-shell.cjs +84 -0
- package/lib/mob-app/create-vue-app.cjs +40 -0
- package/lib/mob-app/guard/auth-guard/auth-guard.cjs +143 -0
- package/lib/mob-app/guard/index.cjs +7 -0
- package/lib/mob-app/index.cjs +7 -0
- package/lib/mob-app/main.cjs +62 -0
- package/lib/mob-app/router/index.cjs +176 -0
- package/lib/mob-app/util/index.cjs +7 -0
- package/lib/mob-app/util/unauthorized-handler/unauthorized-handler.cjs +102 -0
- package/lib/panel-component/index.cjs +1 -0
- package/lib/util/confirm-util/confirm-util.cjs +5 -5
- package/lib/util/directive/loading.cjs +2 -2
- package/lib/util/loading-util/loading-util.cjs +2 -2
- package/lib/util/message-util/message-util.cjs +5 -5
- package/lib/util/modal-util/modal-util.cjs +6 -6
- package/lib/util/notification-util/notification-util.cjs +5 -5
- package/lib/util/open-view-util/open-view-util.cjs +5 -2
- package/lib/view-engine/mob-edit-view.engine.cjs +5 -1
- package/package.json +8 -7
|
@@ -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
|
+
viewModel
|
|
65
|
+
} = this.viewData;
|
|
66
|
+
const props = mergeDeepLeft({
|
|
67
|
+
...this.$props,
|
|
68
|
+
...this.$attrs,
|
|
69
|
+
context,
|
|
70
|
+
params,
|
|
71
|
+
modelData: viewModel,
|
|
72
|
+
key: viewModel.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,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 @@
|
|
|
1
|
+
export { runApp } from './main';
|
|
@@ -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 { OpenViewUtil } from '../util/open-view-util/open-view-util.mjs';
|
|
11
|
+
import { MessageUtil } from '../util/message-util/message-util.mjs';
|
|
12
|
+
import { ModalUtil } from '../util/modal-util/modal-util.mjs';
|
|
13
|
+
import { ConfirmUtil } from '../util/confirm-util/confirm-util.mjs';
|
|
14
|
+
import { NotificationUtil } from '../util/notification-util/notification-util.mjs';
|
|
15
|
+
import { LoadingUtil } from '../util/loading-util/loading-util.mjs';
|
|
16
|
+
import { OverlayController } from '../util/overlay-controller/overlay-controller.mjs';
|
|
17
|
+
import { UnauthorizedHandler } from './util/unauthorized-handler/unauthorized-handler.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
|
+
const app = createVueApp(App);
|
|
32
|
+
OverlayContainer.createVueApp = createVueApp;
|
|
33
|
+
window.onerror = function(_event, _source, _lineno, _colno, error) {
|
|
34
|
+
if (error) {
|
|
35
|
+
ibiz.util.error.handle(error);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
window.addEventListener("unhandledrejection", function(event) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
event.promise.catch((err) => {
|
|
41
|
+
ibiz.util.error.handle(err);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
await attachEnvironmentConfig();
|
|
45
|
+
const router = AppRouter.getRouter();
|
|
46
|
+
app.use(router);
|
|
47
|
+
ibiz.openView = new OpenViewUtil(router);
|
|
48
|
+
ibiz.message = new MessageUtil();
|
|
49
|
+
ibiz.modal = new ModalUtil();
|
|
50
|
+
ibiz.confirm = new ConfirmUtil();
|
|
51
|
+
ibiz.notification = new NotificationUtil();
|
|
52
|
+
ibiz.loading = new LoadingUtil();
|
|
53
|
+
ibiz.overlay = new OverlayController();
|
|
54
|
+
ibiz.util.error.register(new UnauthorizedHandler());
|
|
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,174 @@
|
|
|
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 () => {
|
|
46
|
+
if (!isNilOrEmpty(ibiz.appData)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
const authority = await AuthGuard();
|
|
50
|
+
return authority;
|
|
51
|
+
};
|
|
52
|
+
const placeholder = ibiz.env.routePlaceholder;
|
|
53
|
+
const paramReg = `[^/]+=[^/]+|${placeholder}`;
|
|
54
|
+
const viewReg = `[^=/]+`;
|
|
55
|
+
const children = [
|
|
56
|
+
{
|
|
57
|
+
path: "404",
|
|
58
|
+
name: "404View2",
|
|
59
|
+
meta: { preset: true },
|
|
60
|
+
component: View404
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
path: `:view2(${viewReg})/:params2(${paramReg})`,
|
|
64
|
+
component: RouterShell,
|
|
65
|
+
props: getPropsCallback(2),
|
|
66
|
+
children: [
|
|
67
|
+
{
|
|
68
|
+
path: "404",
|
|
69
|
+
name: "404View3",
|
|
70
|
+
meta: { preset: true },
|
|
71
|
+
component: View404
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
path: `:view3(${viewReg})/:params3(${paramReg})`,
|
|
75
|
+
component: RouterShell,
|
|
76
|
+
props: getPropsCallback(3),
|
|
77
|
+
children: [
|
|
78
|
+
{
|
|
79
|
+
path: "404",
|
|
80
|
+
name: "404View4",
|
|
81
|
+
meta: { preset: true },
|
|
82
|
+
component: View404
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
path: `:view4(${viewReg})/:params4(${paramReg})`,
|
|
86
|
+
component: RouterShell,
|
|
87
|
+
props: getPropsCallback(4)
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
path: ":pathMatch(.*)*",
|
|
91
|
+
redirect: { name: "404View4" }
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
path: ":pathMatch(.*)*",
|
|
97
|
+
redirect: { name: "404View3" }
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
path: ":pathMatch(.*)*",
|
|
103
|
+
redirect: { name: "404View2" }
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
return createRouter({
|
|
107
|
+
// 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
|
|
108
|
+
history: createWebHashHistory(),
|
|
109
|
+
routes: [
|
|
110
|
+
{
|
|
111
|
+
path: "/",
|
|
112
|
+
redirect: {
|
|
113
|
+
replace: true,
|
|
114
|
+
path: `/${placeholder}/index/${placeholder}`
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
path: "/login",
|
|
119
|
+
name: "loginView",
|
|
120
|
+
meta: { preset: true },
|
|
121
|
+
component: LoginView
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
path: "/404",
|
|
125
|
+
name: "404View1",
|
|
126
|
+
meta: { preset: true },
|
|
127
|
+
component: View404
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
path: "/appredirectview",
|
|
131
|
+
name: "appRedirectView",
|
|
132
|
+
meta: { preset: true },
|
|
133
|
+
beforeEnter,
|
|
134
|
+
component: AppRedirectView
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
path: `/:appContext(${paramReg})/home/:params1(${paramReg})`,
|
|
138
|
+
meta: { home: true },
|
|
139
|
+
beforeEnter,
|
|
140
|
+
component: HomeView,
|
|
141
|
+
children
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
path: `/:appContext(${paramReg})/:view1(${viewReg})/:params1(${paramReg})`,
|
|
145
|
+
beforeEnter,
|
|
146
|
+
component: RouterShell,
|
|
147
|
+
children
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
path: "/:pathMatch(.*)*",
|
|
151
|
+
redirect: { name: "404View1" }
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* 获取路由对象
|
|
158
|
+
* @author lxm
|
|
159
|
+
* @date 2023-06-29 07:56:05
|
|
160
|
+
* @static
|
|
161
|
+
* @return {*}
|
|
162
|
+
*/
|
|
163
|
+
static getRouter() {
|
|
164
|
+
if (!this.router) {
|
|
165
|
+
this.router = this.createRouter();
|
|
166
|
+
const { init } = useViewStack();
|
|
167
|
+
init(this.router);
|
|
168
|
+
}
|
|
169
|
+
return this.router;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
__publicField(AppRouter, "router");
|
|
173
|
+
|
|
174
|
+
export { AppRouter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UnauthorizedHandler } from './unauthorized-handler/unauthorized-handler';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { IErrorHandler } from '@ibiz-template/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* 没有权限的错误处理器
|
|
4
|
+
*
|
|
5
|
+
* @author lxm
|
|
6
|
+
* @date 2022-10-11 14:10:10
|
|
7
|
+
* @export
|
|
8
|
+
* @class UnauthorizedHandler
|
|
9
|
+
*/
|
|
10
|
+
export declare class UnauthorizedHandler implements IErrorHandler {
|
|
11
|
+
match(error: unknown): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* cas登录处理
|
|
14
|
+
*
|
|
15
|
+
* @author lxm
|
|
16
|
+
* @date 2022-10-11 14:10:35
|
|
17
|
+
* @protected
|
|
18
|
+
* @returns {*} {Promise<void>}
|
|
19
|
+
*/
|
|
20
|
+
protected casLogin(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* 普通登录处理
|
|
23
|
+
*
|
|
24
|
+
* @author lxm
|
|
25
|
+
* @date 2022-10-11 14:10:24
|
|
26
|
+
* @protected
|
|
27
|
+
* @returns {*} {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
protected normalLogin(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* 处理403
|
|
32
|
+
* @author lxm
|
|
33
|
+
* @date 2023-12-06 10:19:12
|
|
34
|
+
* @protected
|
|
35
|
+
* @return {*} {Promise<void>}
|
|
36
|
+
*/
|
|
37
|
+
protected handle403(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* 没有权限处理
|
|
40
|
+
*
|
|
41
|
+
* @author lxm
|
|
42
|
+
* @date 2022-10-11 14:10:50
|
|
43
|
+
* @returns {*} {Promise<void>}
|
|
44
|
+
*/
|
|
45
|
+
handle(error: unknown): boolean | undefined;
|
|
46
|
+
}
|