@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,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
5
|
+
var vueRouter = require('vue-router');
|
|
6
|
+
var core = require('@ibiz-template/core');
|
|
7
|
+
var ramda = require('ramda');
|
|
8
|
+
|
|
9
|
+
"use strict";
|
|
10
|
+
const RouterShell = /* @__PURE__ */ vue.defineComponent({
|
|
11
|
+
name: "RouterShell",
|
|
12
|
+
props: {
|
|
13
|
+
modal: {
|
|
14
|
+
type: Object,
|
|
15
|
+
required: true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
setup(props) {
|
|
19
|
+
const route = vueRouter.useRoute();
|
|
20
|
+
const router = vueRouter.useRouter();
|
|
21
|
+
const viewData = vue.ref({});
|
|
22
|
+
const isLoaded = vue.ref(false);
|
|
23
|
+
const destroyContext = () => {
|
|
24
|
+
if (viewData.value.context) {
|
|
25
|
+
const {
|
|
26
|
+
context
|
|
27
|
+
} = vue.toRaw(viewData.value);
|
|
28
|
+
if (context)
|
|
29
|
+
context.destroy();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const routeDepth = props.modal.routeDepth || 1;
|
|
33
|
+
vue.onUnmounted(() => {
|
|
34
|
+
destroyContext();
|
|
35
|
+
});
|
|
36
|
+
const calcViewData = async () => {
|
|
37
|
+
try {
|
|
38
|
+
const _viewData = await vue3Util.parseRouteViewData(route, routeDepth);
|
|
39
|
+
const _context = core.IBizContext.create(_viewData.context);
|
|
40
|
+
viewData.value = {
|
|
41
|
+
..._viewData,
|
|
42
|
+
context: _context
|
|
43
|
+
};
|
|
44
|
+
isLoaded.value = true;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
router.push({
|
|
47
|
+
name: `404View${routeDepth}`
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
calcViewData();
|
|
52
|
+
return {
|
|
53
|
+
route,
|
|
54
|
+
viewData,
|
|
55
|
+
isLoaded
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
render() {
|
|
59
|
+
if (!this.isLoaded) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const {
|
|
63
|
+
context,
|
|
64
|
+
params,
|
|
65
|
+
srfnav,
|
|
66
|
+
viewModel
|
|
67
|
+
} = this.viewData;
|
|
68
|
+
const props = ramda.mergeDeepLeft({
|
|
69
|
+
...this.$props,
|
|
70
|
+
...this.$attrs,
|
|
71
|
+
context,
|
|
72
|
+
params,
|
|
73
|
+
modelData: viewModel,
|
|
74
|
+
key: viewModel.codeName
|
|
75
|
+
}, {
|
|
76
|
+
state: {
|
|
77
|
+
srfnav
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return vue.h(vue.resolveComponent("IBizViewShell"), props, this.$slots);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
exports.RouterShell = RouterShell;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
var Vant = require('vant');
|
|
5
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
6
|
+
var index = require('../locale/index.cjs');
|
|
7
|
+
var ibizVue3 = require('../ibiz-vue3.cjs');
|
|
8
|
+
require('../util/index.cjs');
|
|
9
|
+
var loading = require('../util/directive/loading.cjs');
|
|
10
|
+
|
|
11
|
+
"use strict";
|
|
12
|
+
Vant.allowMultipleToast();
|
|
13
|
+
function createVueApp(rootComponent, rootProps) {
|
|
14
|
+
const app = vue.createApp(rootComponent, rootProps);
|
|
15
|
+
app.component("KeepAlive", vue.KeepAlive);
|
|
16
|
+
app.config.errorHandler = function(err) {
|
|
17
|
+
ibiz.util.error.handle(err);
|
|
18
|
+
};
|
|
19
|
+
const installPlugin = (_, plugin) => {
|
|
20
|
+
app.use(plugin);
|
|
21
|
+
};
|
|
22
|
+
vue3Util.AppHooks.useComponent.tap(installPlugin);
|
|
23
|
+
if (rootProps) {
|
|
24
|
+
const oldUnMounted = rootProps.unmounted;
|
|
25
|
+
rootProps.unmounted = () => {
|
|
26
|
+
oldUnMounted();
|
|
27
|
+
vue3Util.AppHooks.useComponent.removeTap(installPlugin);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
app.use(index.i18n);
|
|
31
|
+
app.use(Vant);
|
|
32
|
+
app.use(vue3Util.piniaInstance);
|
|
33
|
+
app.use(ibizVue3.default);
|
|
34
|
+
vue3Util.AppHooks.createApp.callSync(null, app);
|
|
35
|
+
app.directive("loading", loading.loadingDirective);
|
|
36
|
+
ibiz.plugin.register(app);
|
|
37
|
+
return app;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.createVueApp = createVueApp;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@ibiz-template/core');
|
|
4
|
+
var qxUtil = require('qx-util');
|
|
5
|
+
var modelHelper = require('@ibiz-template/model-helper');
|
|
6
|
+
var ramda = require('ramda');
|
|
7
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
8
|
+
var index = require('../../../locale/index.cjs');
|
|
9
|
+
|
|
10
|
+
"use strict";
|
|
11
|
+
async function loadAppData() {
|
|
12
|
+
const res = await ibiz.net.get("/appdata");
|
|
13
|
+
if (res.ok) {
|
|
14
|
+
ibiz.appData = res.data;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function loadOrgData() {
|
|
18
|
+
const res = await ibiz.net.get(`/uaa/getbydcsystem/${ibiz.env.dcSystem}`);
|
|
19
|
+
if (res.ok) {
|
|
20
|
+
const orgDataItems = res.data;
|
|
21
|
+
if (orgDataItems) {
|
|
22
|
+
const [data] = orgDataItems;
|
|
23
|
+
ibiz.orgData = data;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function setRefreshToken() {
|
|
28
|
+
const token = qxUtil.getCookie(core.CoreConst.TOKEN);
|
|
29
|
+
const expirein = qxUtil.getCookie(core.CoreConst.TOKEN_EXPIRES);
|
|
30
|
+
if (token && expirein) {
|
|
31
|
+
let wait = Number(expirein) - (/* @__PURE__ */ new Date()).getTime();
|
|
32
|
+
const early = 5 * 60 * 1e3;
|
|
33
|
+
wait = wait > early ? wait - early : 0;
|
|
34
|
+
setTimeout(async () => {
|
|
35
|
+
const res = await ibiz.net.get(`/uaa/refreshtoken2`);
|
|
36
|
+
if (res.ok) {
|
|
37
|
+
qxUtil.setCookie(core.CoreConst.TOKEN, res.data.token, 0, true);
|
|
38
|
+
const expiredDate = (/* @__PURE__ */ new Date()).getTime() + (res.data.expirein || 7199) * 1e3;
|
|
39
|
+
qxUtil.setCookie(core.CoreConst.TOKEN_EXPIRES, `${expiredDate}`, 0, true);
|
|
40
|
+
}
|
|
41
|
+
setRefreshToken();
|
|
42
|
+
}, wait);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function loadTheme() {
|
|
46
|
+
const app = ibiz.hub.getApp();
|
|
47
|
+
const uiThemes = app.model.appUIThemes || [];
|
|
48
|
+
if (uiThemes.length > 0) {
|
|
49
|
+
const theme = uiThemes[0];
|
|
50
|
+
await ibiz.util.theme.loadTheme(theme);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
let helper;
|
|
54
|
+
async function initModel(permission = true) {
|
|
55
|
+
if (!helper) {
|
|
56
|
+
helper = new modelHelper.ModelHelper(
|
|
57
|
+
async (url) => {
|
|
58
|
+
if (ibiz.env.isLocalModel) {
|
|
59
|
+
const res2 = await ibiz.net.getModel(`./model${url}`);
|
|
60
|
+
return res2.data;
|
|
61
|
+
}
|
|
62
|
+
const res = await ibiz.net.get(
|
|
63
|
+
`${ibiz.env.remoteModelUrl}${url}`,
|
|
64
|
+
void 0,
|
|
65
|
+
permission ? {} : { srfdcsystem: ibiz.env.dcSystem }
|
|
66
|
+
);
|
|
67
|
+
return res.data;
|
|
68
|
+
},
|
|
69
|
+
ibiz.env.appId,
|
|
70
|
+
permission
|
|
71
|
+
);
|
|
72
|
+
const app = await ibiz.hub.getAppAsync(ibiz.env.appId);
|
|
73
|
+
const appModel = app.model;
|
|
74
|
+
ibiz.env.isMob = appModel.mobileApp === true;
|
|
75
|
+
if (ibiz.env.isEnableMultiLan) {
|
|
76
|
+
const lang = ibiz.i18n.getLang();
|
|
77
|
+
const m = await helper.getPSAppLang(lang.replace("-", "_").toUpperCase());
|
|
78
|
+
const items = m.languageItems || [];
|
|
79
|
+
const data = {};
|
|
80
|
+
items.forEach((item) => {
|
|
81
|
+
data[item.lanResTag] = item.content;
|
|
82
|
+
});
|
|
83
|
+
index.i18n.global.mergeLocaleMessage(lang, data);
|
|
84
|
+
}
|
|
85
|
+
if (!appModel.appUIThemes) {
|
|
86
|
+
const module = await import('@ibiz-template/mob-theme');
|
|
87
|
+
const theme = module.default || module;
|
|
88
|
+
vue3Util.AppHooks.useComponent.callSync(null, theme);
|
|
89
|
+
} else {
|
|
90
|
+
await loadTheme();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function initEnvironment() {
|
|
95
|
+
if (helper) {
|
|
96
|
+
const app = await helper.getAppModel();
|
|
97
|
+
const userParam = app.userParam;
|
|
98
|
+
if (userParam) {
|
|
99
|
+
Object.keys(userParam).forEach((key) => {
|
|
100
|
+
const value = ibiz.util.rawValue.format(userParam[key]);
|
|
101
|
+
const keys = key.split(".");
|
|
102
|
+
let currentObj = ibiz.env;
|
|
103
|
+
for (let i = 0; i < keys.length; i++) {
|
|
104
|
+
const k = keys[i];
|
|
105
|
+
if (i === keys.length - 1) {
|
|
106
|
+
currentObj[k] = value;
|
|
107
|
+
} else {
|
|
108
|
+
currentObj[k] = currentObj[k] || {};
|
|
109
|
+
currentObj = currentObj[k];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
if (ibiz.env.globalConfig) {
|
|
114
|
+
ibiz.config = ramda.mergeDeepRight(ibiz.config, ibiz.env.globalConfig);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function appInit() {
|
|
120
|
+
if (ibiz.env.isSaaSMode === true) {
|
|
121
|
+
await loadOrgData();
|
|
122
|
+
}
|
|
123
|
+
await loadAppData();
|
|
124
|
+
await initModel();
|
|
125
|
+
await initEnvironment();
|
|
126
|
+
setRefreshToken();
|
|
127
|
+
}
|
|
128
|
+
async function AuthGuard(permission = true) {
|
|
129
|
+
if (permission) {
|
|
130
|
+
let result = true;
|
|
131
|
+
try {
|
|
132
|
+
await appInit();
|
|
133
|
+
} catch (error) {
|
|
134
|
+
result = false;
|
|
135
|
+
ibiz.util.error.handle(error);
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
await initModel(false);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
exports.AuthGuard = AuthGuard;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@ibiz-template/core');
|
|
4
|
+
var runtime = require('@ibiz-template/runtime');
|
|
5
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
6
|
+
var App = require('./App.cjs');
|
|
7
|
+
var attachEnvironmentConfig = require('./attach-environment-config.cjs');
|
|
8
|
+
var createVueApp = require('./create-vue-app.cjs');
|
|
9
|
+
var index = require('./router/index.cjs');
|
|
10
|
+
require('./util/index.cjs');
|
|
11
|
+
require('../util/index.cjs');
|
|
12
|
+
var openViewUtil = require('../util/open-view-util/open-view-util.cjs');
|
|
13
|
+
var messageUtil = require('../util/message-util/message-util.cjs');
|
|
14
|
+
var modalUtil = require('../util/modal-util/modal-util.cjs');
|
|
15
|
+
var confirmUtil = require('../util/confirm-util/confirm-util.cjs');
|
|
16
|
+
var notificationUtil = require('../util/notification-util/notification-util.cjs');
|
|
17
|
+
var loadingUtil = require('../util/loading-util/loading-util.cjs');
|
|
18
|
+
var overlayController = require('../util/overlay-controller/overlay-controller.cjs');
|
|
19
|
+
var unauthorizedHandler = require('./util/unauthorized-handler/unauthorized-handler.cjs');
|
|
20
|
+
|
|
21
|
+
"use strict";
|
|
22
|
+
async function runApp(plugins) {
|
|
23
|
+
vue3Util.AppHooks.createApp.tap((_, app2) => {
|
|
24
|
+
if (plugins) {
|
|
25
|
+
plugins.forEach((plugin) => {
|
|
26
|
+
app2.use(plugin);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
core.install();
|
|
31
|
+
runtime.install();
|
|
32
|
+
ibiz.plugin = new vue3Util.PluginFactory();
|
|
33
|
+
const app = createVueApp.createVueApp(App.default);
|
|
34
|
+
vue3Util.OverlayContainer.createVueApp = createVueApp.createVueApp;
|
|
35
|
+
window.onerror = function(_event, _source, _lineno, _colno, error) {
|
|
36
|
+
if (error) {
|
|
37
|
+
ibiz.util.error.handle(error);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
window.addEventListener("unhandledrejection", function(event) {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
event.promise.catch((err) => {
|
|
43
|
+
ibiz.util.error.handle(err);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
await attachEnvironmentConfig.attachEnvironmentConfig();
|
|
47
|
+
const router = index.AppRouter.getRouter();
|
|
48
|
+
app.use(router);
|
|
49
|
+
ibiz.openView = new openViewUtil.OpenViewUtil(router);
|
|
50
|
+
ibiz.message = new messageUtil.MessageUtil();
|
|
51
|
+
ibiz.modal = new modalUtil.ModalUtil();
|
|
52
|
+
ibiz.confirm = new confirmUtil.ConfirmUtil();
|
|
53
|
+
ibiz.notification = new notificationUtil.NotificationUtil();
|
|
54
|
+
ibiz.loading = new loadingUtil.LoadingUtil();
|
|
55
|
+
ibiz.overlay = new overlayController.OverlayController();
|
|
56
|
+
ibiz.util.error.register(new unauthorizedHandler.UnauthorizedHandler());
|
|
57
|
+
ibiz.platform = runtime.getPlatformProvider();
|
|
58
|
+
await ibiz.i18n.init();
|
|
59
|
+
app.mount("#app");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.runApp = runApp;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vueRouter = require('vue-router');
|
|
4
|
+
var runtime = require('@ibiz-template/runtime');
|
|
5
|
+
var qxUtil = require('qx-util');
|
|
6
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
7
|
+
require('../guard/index.cjs');
|
|
8
|
+
require('../components/index.cjs');
|
|
9
|
+
require('../../view/index.cjs');
|
|
10
|
+
require('../../util/index.cjs');
|
|
11
|
+
var authGuard = require('../guard/auth-guard/auth-guard.cjs');
|
|
12
|
+
var _404View = require('../../view/404-view/404-view.cjs');
|
|
13
|
+
var routerShell = require('../components/router-shell/router-shell.cjs');
|
|
14
|
+
var loginView = require('../../view/login-view/login-view.cjs');
|
|
15
|
+
var homeView = require('../components/home-view/home-view.cjs');
|
|
16
|
+
var viewStack = require('../../util/store/view-stack/view-stack.cjs');
|
|
17
|
+
|
|
18
|
+
"use strict";
|
|
19
|
+
var __defProp = Object.defineProperty;
|
|
20
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
21
|
+
var __publicField = (obj, key, value) => {
|
|
22
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
const getPropsCallback = (depth) => {
|
|
26
|
+
if (depth === 1) {
|
|
27
|
+
return () => ({});
|
|
28
|
+
}
|
|
29
|
+
return () => ({
|
|
30
|
+
modal: new runtime.Modal({
|
|
31
|
+
mode: runtime.ViewMode.ROUTE,
|
|
32
|
+
viewUsage: 1,
|
|
33
|
+
routeDepth: depth
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
class AppRouter {
|
|
38
|
+
/**
|
|
39
|
+
* 创建vue路由对象
|
|
40
|
+
* @author lxm
|
|
41
|
+
* @date 2023-06-29 07:56:11
|
|
42
|
+
* @protected
|
|
43
|
+
* @static
|
|
44
|
+
* @return {*}
|
|
45
|
+
*/
|
|
46
|
+
static createRouter() {
|
|
47
|
+
const beforeEnter = async () => {
|
|
48
|
+
if (!qxUtil.isNilOrEmpty(ibiz.appData)) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
const authority = await authGuard.AuthGuard();
|
|
52
|
+
return authority;
|
|
53
|
+
};
|
|
54
|
+
const placeholder = ibiz.env.routePlaceholder;
|
|
55
|
+
const paramReg = `[^/]+=[^/]+|${placeholder}`;
|
|
56
|
+
const viewReg = `[^=/]+`;
|
|
57
|
+
const children = [
|
|
58
|
+
{
|
|
59
|
+
path: "404",
|
|
60
|
+
name: "404View2",
|
|
61
|
+
meta: { preset: true },
|
|
62
|
+
component: _404View.View404
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
path: `:view2(${viewReg})/:params2(${paramReg})`,
|
|
66
|
+
component: routerShell.RouterShell,
|
|
67
|
+
props: getPropsCallback(2),
|
|
68
|
+
children: [
|
|
69
|
+
{
|
|
70
|
+
path: "404",
|
|
71
|
+
name: "404View3",
|
|
72
|
+
meta: { preset: true },
|
|
73
|
+
component: _404View.View404
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
path: `:view3(${viewReg})/:params3(${paramReg})`,
|
|
77
|
+
component: routerShell.RouterShell,
|
|
78
|
+
props: getPropsCallback(3),
|
|
79
|
+
children: [
|
|
80
|
+
{
|
|
81
|
+
path: "404",
|
|
82
|
+
name: "404View4",
|
|
83
|
+
meta: { preset: true },
|
|
84
|
+
component: _404View.View404
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
path: `:view4(${viewReg})/:params4(${paramReg})`,
|
|
88
|
+
component: routerShell.RouterShell,
|
|
89
|
+
props: getPropsCallback(4)
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
path: ":pathMatch(.*)*",
|
|
93
|
+
redirect: { name: "404View4" }
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
path: ":pathMatch(.*)*",
|
|
99
|
+
redirect: { name: "404View3" }
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
path: ":pathMatch(.*)*",
|
|
105
|
+
redirect: { name: "404View2" }
|
|
106
|
+
}
|
|
107
|
+
];
|
|
108
|
+
return vueRouter.createRouter({
|
|
109
|
+
// 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
|
|
110
|
+
history: vueRouter.createWebHashHistory(),
|
|
111
|
+
routes: [
|
|
112
|
+
{
|
|
113
|
+
path: "/",
|
|
114
|
+
redirect: {
|
|
115
|
+
replace: true,
|
|
116
|
+
path: `/${placeholder}/index/${placeholder}`
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
path: "/login",
|
|
121
|
+
name: "loginView",
|
|
122
|
+
meta: { preset: true },
|
|
123
|
+
component: loginView.LoginView
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
path: "/404",
|
|
127
|
+
name: "404View1",
|
|
128
|
+
meta: { preset: true },
|
|
129
|
+
component: _404View.View404
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
path: "/appredirectview",
|
|
133
|
+
name: "appRedirectView",
|
|
134
|
+
meta: { preset: true },
|
|
135
|
+
beforeEnter,
|
|
136
|
+
component: vue3Util.AppRedirectView
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
path: `/:appContext(${paramReg})/home/:params1(${paramReg})`,
|
|
140
|
+
meta: { home: true },
|
|
141
|
+
beforeEnter,
|
|
142
|
+
component: homeView.HomeView,
|
|
143
|
+
children
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
path: `/:appContext(${paramReg})/:view1(${viewReg})/:params1(${paramReg})`,
|
|
147
|
+
beforeEnter,
|
|
148
|
+
component: routerShell.RouterShell,
|
|
149
|
+
children
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
path: "/:pathMatch(.*)*",
|
|
153
|
+
redirect: { name: "404View1" }
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 获取路由对象
|
|
160
|
+
* @author lxm
|
|
161
|
+
* @date 2023-06-29 07:56:05
|
|
162
|
+
* @static
|
|
163
|
+
* @return {*}
|
|
164
|
+
*/
|
|
165
|
+
static getRouter() {
|
|
166
|
+
if (!this.router) {
|
|
167
|
+
this.router = this.createRouter();
|
|
168
|
+
const { init } = viewStack.useViewStack();
|
|
169
|
+
init(this.router);
|
|
170
|
+
}
|
|
171
|
+
return this.router;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
__publicField(AppRouter, "router");
|
|
175
|
+
|
|
176
|
+
exports.AppRouter = AppRouter;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var qs = require('qs');
|
|
4
|
+
var core = require('@ibiz-template/core');
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
class UnauthorizedHandler {
|
|
8
|
+
match(error) {
|
|
9
|
+
return error instanceof core.HttpError && (error.status === 401 || error.status === 403);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* cas登录处理
|
|
13
|
+
*
|
|
14
|
+
* @author lxm
|
|
15
|
+
* @date 2022-10-11 14:10:35
|
|
16
|
+
* @protected
|
|
17
|
+
* @returns {*} {Promise<void>}
|
|
18
|
+
*/
|
|
19
|
+
async casLogin() {
|
|
20
|
+
if (!ibiz.env.casLoginUrl) {
|
|
21
|
+
throw new core.RuntimeError("\u627E\u4E0D\u5230\u73AF\u5883\u53C2\u6570casLoginUrl");
|
|
22
|
+
}
|
|
23
|
+
const { origin } = window.location;
|
|
24
|
+
const baseUrl = `${origin}${ibiz.env.baseUrl}`;
|
|
25
|
+
const backUrl = `${baseUrl}/cas/v7/login${qs.stringify(
|
|
26
|
+
{
|
|
27
|
+
RU: core.UrlHelper.fullPath,
|
|
28
|
+
base: baseUrl
|
|
29
|
+
},
|
|
30
|
+
{ addQueryPrefix: true }
|
|
31
|
+
)}`;
|
|
32
|
+
const hasQueryPrefix = ibiz.env.casLoginUrl.indexOf("?") !== -1;
|
|
33
|
+
const targetUrl = ibiz.env.casLoginUrl + (hasQueryPrefix ? "&" : "?") + qs.stringify(
|
|
34
|
+
{
|
|
35
|
+
service: backUrl
|
|
36
|
+
},
|
|
37
|
+
{ addQueryPrefix: false }
|
|
38
|
+
);
|
|
39
|
+
window.location.href = targetUrl;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 普通登录处理
|
|
43
|
+
*
|
|
44
|
+
* @author lxm
|
|
45
|
+
* @date 2022-10-11 14:10:24
|
|
46
|
+
* @protected
|
|
47
|
+
* @returns {*} {Promise<void>}
|
|
48
|
+
*/
|
|
49
|
+
async normalLogin() {
|
|
50
|
+
const ru = window.location.hash.replace("#", "");
|
|
51
|
+
const targetUrl = `${core.UrlHelper.routeBase}/login?ru=${encodeURIComponent(
|
|
52
|
+
ru
|
|
53
|
+
)}`;
|
|
54
|
+
document.body.style.display = "none";
|
|
55
|
+
window.location.href = targetUrl;
|
|
56
|
+
window.location.reload();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 处理403
|
|
60
|
+
* @author lxm
|
|
61
|
+
* @date 2023-12-06 10:19:12
|
|
62
|
+
* @protected
|
|
63
|
+
* @return {*} {Promise<void>}
|
|
64
|
+
*/
|
|
65
|
+
async handle403() {
|
|
66
|
+
const result = await ibiz.modal.confirm({
|
|
67
|
+
title: "\u5F53\u524D\u8D26\u6237\u88AB\u7981\u6B62\u8BBF\u95EE",
|
|
68
|
+
desc: "\u662F\u5426\u8981\u9000\u51FA\u5F53\u524D\u8D26\u6237\uFF1F"
|
|
69
|
+
});
|
|
70
|
+
if (result) {
|
|
71
|
+
const bol = await ibiz.auth.logout();
|
|
72
|
+
if (bol) {
|
|
73
|
+
window.location.reload();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 没有权限处理
|
|
79
|
+
*
|
|
80
|
+
* @author lxm
|
|
81
|
+
* @date 2022-10-11 14:10:50
|
|
82
|
+
* @returns {*} {Promise<void>}
|
|
83
|
+
*/
|
|
84
|
+
handle(error) {
|
|
85
|
+
if (error instanceof core.HttpError) {
|
|
86
|
+
if (error.status === 401) {
|
|
87
|
+
if (ibiz.env.loginMode === core.LoginMode.CAS) {
|
|
88
|
+
this.casLogin();
|
|
89
|
+
} else {
|
|
90
|
+
this.normalLogin();
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
if (error.status === 403) {
|
|
95
|
+
this.handle403();
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
exports.UnauthorizedHandler = UnauthorizedHandler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@ibiz-template/core');
|
|
4
|
-
var
|
|
4
|
+
var Vant = require('vant');
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -17,7 +17,7 @@ class ConfirmUtil {
|
|
|
17
17
|
async info(params) {
|
|
18
18
|
const { title, desc, options } = params;
|
|
19
19
|
return new Promise((resolve) => {
|
|
20
|
-
|
|
20
|
+
Vant.showConfirmDialog({
|
|
21
21
|
title,
|
|
22
22
|
message: desc,
|
|
23
23
|
className: `${this.ns.b()} ${this.ns.e("info")}`,
|
|
@@ -32,7 +32,7 @@ class ConfirmUtil {
|
|
|
32
32
|
async success(params) {
|
|
33
33
|
const { title, desc, options } = params;
|
|
34
34
|
return new Promise((resolve) => {
|
|
35
|
-
|
|
35
|
+
Vant.showConfirmDialog({
|
|
36
36
|
title,
|
|
37
37
|
message: desc,
|
|
38
38
|
className: `${this.ns.b()} ${this.ns.e("success")}`,
|
|
@@ -47,7 +47,7 @@ class ConfirmUtil {
|
|
|
47
47
|
async warning(params) {
|
|
48
48
|
const { title, desc, options } = params;
|
|
49
49
|
return new Promise((resolve) => {
|
|
50
|
-
|
|
50
|
+
Vant.showConfirmDialog({
|
|
51
51
|
title,
|
|
52
52
|
message: desc,
|
|
53
53
|
className: `${this.ns.b()} ${this.ns.e("warning")}`,
|
|
@@ -62,7 +62,7 @@ class ConfirmUtil {
|
|
|
62
62
|
async error(params) {
|
|
63
63
|
const { title, desc, options } = params;
|
|
64
64
|
return new Promise((resolve) => {
|
|
65
|
-
|
|
65
|
+
Vant.showConfirmDialog({
|
|
66
66
|
title,
|
|
67
67
|
message: desc,
|
|
68
68
|
className: `${this.ns.b()} ${this.ns.e("error")}`,
|