@utogether/udp-core 1.0.1-beta.3 → 1.0.1-beta.5

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 (94) hide show
  1. package/build/plugins.ts +39 -37
  2. package/dist/{403-BuP9jvH9.js → 403-CP2RkkAy.js} +10 -10
  3. package/dist/{404-DfQk8kKl.js → 404-DwK-0wNQ.js} +4 -4
  4. package/dist/{500-OgROWdiZ.js → 500-CLbJDqnd.js} +1 -1
  5. package/dist/{AuthorityInfo-q2ksfkWH.js → AuthorityInfo-Bi1_uhMu.js} +1 -1
  6. package/dist/{AuthorityInfo.vue_vue_type_style_index_0_lang-Bwsf6lMH.js → AuthorityInfo.vue_vue_type_style_index_0_lang-RUhvzu76.js} +8 -9
  7. package/dist/{Company-DgqowAxc.js → Company-B--cokc6.js} +3 -3
  8. package/dist/{CompanyPanel-BNb1rUhD.js → CompanyPanel-B_gmcZ9L.js} +6 -6
  9. package/dist/{Department-Cl8CROSU.js → Department-DbKdyNzK.js} +3 -3
  10. package/dist/{DepartmentPanel-D5VkqKeP.js → DepartmentPanel-BmEttboJ.js} +23 -24
  11. package/dist/{DesignPanel-BGvEusHC.js → DesignPanel-LL68_36s.js} +1 -1
  12. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-BQF1uQ7w.js → DesignPanel.vue_vue_type_style_index_0_lang-DWPmFegv.js} +8 -9
  13. package/dist/{DictView-BnxfaOBv.js → DictView-B8j-EWx5.js} +1 -1
  14. package/dist/{InvOrganization-5y79ZLdY.js → InvOrganization-DnGQlESM.js} +7 -8
  15. package/dist/Org-Dg9Xkd34.js +34 -0
  16. package/dist/{Preview-BaGmXH7r.js → Preview-yot4NBW5.js} +1 -1
  17. package/dist/{ReportDefine-DkQdBErt.js → ReportDefine-DHadqNYy.js} +1 -1
  18. package/dist/{ReportDesign-DzB_A_G6.js → ReportDesign-CBihGRth.js} +23 -24
  19. package/dist/{ReportQuery-DRcMb6ya.js → ReportQuery-CwHQ6LUU.js} +1 -1
  20. package/dist/{ReportQueryFrom-CeA9xhR4.js → ReportQueryFrom-ie6lQcGL.js} +1 -1
  21. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-CgGtcs5V.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-B8LJNK0m.js} +1 -1
  22. package/dist/{ReportTemplate-qaiTMQuT.js → ReportTemplate-B2Smwo-z.js} +18 -18
  23. package/dist/{Role-DsFulAjq.js → Role-Cf7DB7uS.js} +3 -3
  24. package/dist/{RoleAssign-DMRdocpa.js → RoleAssign-upUnqs_i.js} +3 -3
  25. package/dist/{RolePanel-wXVysDHM.js → RolePanel-BBGDGK8V.js} +1 -1
  26. package/dist/{RolePanel-B9POS_pg.js → RolePanel-EXL_FLvM.js} +1 -1
  27. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-t6S_0zmJ.js → RolePanel.vue_vue_type_script_setup_true_lang-BwfL_JVZ.js} +8 -9
  28. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-CleVvkcY.js → RolePanel.vue_vue_type_script_setup_true_lang-DF8qJKwW.js} +9 -9
  29. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-DlXUs0j9.js → ScrollPanel.vue_vue_type_style_index_0_lang-DbBGg32H.js} +13 -13
  30. package/dist/{Staff-Cq4V7ruC.js → Staff-DYu5ZEyR.js} +3 -3
  31. package/dist/{StaffInfo-CJDKMbud.js → StaffInfo-CHvNGjtz.js} +1 -1
  32. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-DQ4DL1KY.js → StaffInfo.vue_vue_type_script_setup_true_lang-XRJVEJ-s.js} +14 -14
  33. package/dist/{StaffPanel-CG-uggdr.js → StaffPanel-C-ygEY65.js} +1 -1
  34. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-DAgN7zN2.js → StaffPanel.vue_vue_type_script_setup_true_lang-BvLrF4Yw.js} +6 -6
  35. package/dist/{SysUser-kwnzRNdD.js → SysUser-BHk_szpK.js} +2 -2
  36. package/dist/{SysUserPanel-DTlZf3vk.js → SysUserPanel-DFvzA5d-.js} +1 -1
  37. package/dist/{SysUserPanel.vue_vue_type_script_setup_true_lang-BW6PlGjM.js → SysUserPanel.vue_vue_type_script_setup_true_lang-B9zUXXwa.js} +24 -25
  38. package/dist/{SystemMenu-BVT0n-L2.js → SystemMenu-5TK9ZA11.js} +34 -35
  39. package/dist/{UserInfo-BbTQ9Zat.js → UserInfo-Bx3zQqHa.js} +1 -1
  40. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-D_bpYDmI.js → UserInfo.vue_vue_type_style_index_0_lang-C2sqUQdg.js} +12 -13
  41. package/dist/{childView-BJbIhjmf.js → childView-BSUWnii7.js} +1 -1
  42. package/dist/{childView-DCsGFrG-.js → childView-CFC3gA_U.js} +1 -1
  43. package/dist/{childView.vue_vue_type_style_index_0_lang-CDtsalCm.js → childView.vue_vue_type_style_index_0_lang-EcT-Dux7.js} +48 -49
  44. package/dist/{childView.vue_vue_type_style_index_0_lang-BCDxpVoD.js → childView.vue_vue_type_style_index_0_lang-WQVLSJR8.js} +9 -10
  45. package/dist/{code-rule-DePU6cdp.js → code-rule-DybjhotB.js} +6 -8
  46. package/dist/core.es.js +14 -11
  47. package/dist/{cron-task-DUM1SIGL.js → cron-task-DGdknqaF.js} +7 -8
  48. package/dist/{frameView-CEUTDtSm.js → frameView-BOOZRv1S.js} +1 -1
  49. package/dist/index-BDE4-ZvN.js +5091 -0
  50. package/dist/{layoutView-PCjwVwkX.js → layoutView-BWeDLY9C.js} +11 -12
  51. package/dist/{login-B1CjWVKu.js → login-BcuCHhGE.js} +21 -21
  52. package/dist/{login-log-CvVnyGi3.js → login-log-kqKzKTto.js} +1 -1
  53. package/dist/{lov-view-D8wwkxFJ.js → lov-view-DDgzqYSW.js} +8 -9
  54. package/dist/{menuInfo-B5JKVwrB.js → menuInfo-B3MOxomU.js} +1 -1
  55. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-CcM9WX4n.js → menuInfo.vue_vue_type_style_index_0_lang-BXMrNMUs.js} +19 -18
  56. package/dist/{pda-app-DIa1p1Ww.js → pda-app-Dy9WMHEG.js} +19 -20
  57. package/dist/{resource-CCQ7Dd-5.js → resource-BoCP7-dM.js} +8 -8
  58. package/dist/{su-welcome-CLp9YaJa.js → su-welcome-DXpI1MHr.js} +97 -98
  59. package/dist/{sys-config-BBmf_SqF.js → sys-config-BiUWzxGU.js} +19 -20
  60. package/dist/udp-core.css +2 -2
  61. package/dist/{utogether-Bkptx2lB.js → utogether-DXDcsKt7.js} +1 -1
  62. package/index.ts +40 -36
  63. package/package.json +1 -1
  64. package/src/App.vue +1 -1
  65. package/src/api/index.ts +1 -1
  66. package/src/components/udp/count-down.vue +536 -0
  67. package/src/components/udp/form.vue +107 -0
  68. package/src/components/udp/grid.vue +6 -1
  69. package/src/components/udp/index.ts +4 -1
  70. package/src/components/udp/modal-form.vue +9 -0
  71. package/src/components/udp/upload.vue +425 -0
  72. package/src/components/udp/utils.ts +72 -3
  73. package/src/directives/permission/index.ts +1 -1
  74. package/src/layout/components/lay-panel/index.vue +3 -3
  75. package/src/main.ts +111 -110
  76. package/src/plugins/vxe-table/index.ts +3 -3
  77. package/src/router/index.ts +187 -183
  78. package/src/router/modules/remaining.ts +58 -83
  79. package/src/style/vxetable.scss +30 -1
  80. package/src/utils/authority/index.ts +1 -1
  81. package/src/utils/{http → udp/http}/index.ts +8 -24
  82. package/src/utils/{http → udp/http}/types.d.ts +8 -5
  83. package/src/views/login/login-view.vue +1 -1
  84. package/src/views/system/menu/menuInfo.vue +7 -3
  85. package/src/views/system/sys/sys-config.vue +1 -1
  86. package/src/views/udev/dict/childView.vue +6 -1
  87. package/src/views/uhome/su-welcome.vue +1 -1
  88. package/src/views/ulogin/login.vue +3 -2
  89. package/src/views/upms/user/login-log.vue +1 -1
  90. package/src/views/urpt/design/ReportDesign.vue +3 -3
  91. package/types/global.d.ts +2 -1
  92. package/dist/Org-2oBAXN2r.js +0 -35
  93. package/dist/await-to-js.es5-BtRbN2QH.js +0 -10
  94. package/dist/index-ZdgOD7cF.js +0 -3399
@@ -2,7 +2,7 @@
2
2
  * @Author: wei.li
3
3
  * @Date: 2021-12-23 17:33:20
4
4
  * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2025-04-16 15:54:13
5
+ * @LastEditTime: 2025-07-31 10:15:40
6
6
  * @Description: 个性化设置页面
7
7
  -->
8
8
  <script setup lang="ts">
@@ -52,7 +52,7 @@ onBeforeUnmount(() => {
52
52
  <template>
53
53
  <div :class="{ show }">
54
54
  <div class="right-panel-background" />
55
- <div ref="target" class="right-panel bg-bg_color">
55
+ <div ref="target" class="right-panel bg-bg_color bg-white">
56
56
  <div
57
57
  class="project-configuration border-0 border-b-[1px] border-solid border-[var(--pure-border-color)]"
58
58
  >
@@ -118,7 +118,7 @@ onBeforeUnmount(() => {
118
118
  position: fixed;
119
119
  top: 0;
120
120
  right: 0;
121
- z-index: 40000;
121
+ z-index: 400000;
122
122
  width: 100%;
123
123
  max-width: 300px;
124
124
  box-shadow: 0 0 15px 0 rgb(0 0 0 / 5%);
package/src/main.ts CHANGED
@@ -1,110 +1,111 @@
1
- /*
2
- * @Author: wei.li
3
- * @Date: 2022-10-18 18:13:54
4
- * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2025-07-21 11:28:01
6
- * @Description: file content
7
- */
8
- import { createApp, type Directive } from 'vue';
9
- import App from './App.vue';
10
- import router from './router';
11
- import { setViews } from './router';
12
- import { setupStore } from './store';
13
- import { setConfig, setSystemEnv } from './config';
14
- import { useI18n } from '../src/plugins/i18n';
15
- import { setTableConfig } from '../src/plugins/vxe-table';
16
- import { injectResponsiveStorage } from './utils/storage';
17
- import hasAuthority from './utils/authority';
18
- import { getServiceApi, getBaseURL, setRouter } from './api';
19
-
20
- import 'nprogress/nprogress.css';
21
- // 一定要在main.ts中导入tailwind.css,防止vite每次hmr都会请求src/style/index.scss整体css文件导致热更新慢的问题
22
- import './style/tailwind.css';
23
- // // 引入重置样式
24
- import './style/reset.scss';
25
- // 导入公共样式
26
- import './style/index.scss';
27
-
28
- import 'viewerjs/dist/viewer.css';
29
-
30
- import VueViewer from 'v-viewer';
31
-
32
- // import SuTable from './components/SuTable/SuTable.vue';
33
-
34
- // import {
35
- // UtButton,
36
- // utLov2,
37
- // UGrid,
38
- // UtDivider,
39
- // UtModalForm2,
40
- // FormUpload2
41
- // UtForm,
42
- // UtGrid2
43
- // UtContent,
44
- // UtCountdown,
45
- // UtIconSelect,
46
- // UtCalendar
47
- // uAttachment
48
- // } from './components/udp';
49
-
50
- const app = createApp(App);
51
-
52
- // 全局注册`@iconify/vue`图标库
53
- import { IconifyIconOffline, FontIcon } from './components/ReIcon';
54
- // 全局注册`vue-tippy`
55
- import 'tippy.js/dist/tippy.css';
56
- import 'tippy.js/animations/perspective.css';
57
- import VueTippy from 'vue-tippy';
58
-
59
- app.use(VueTippy, {
60
- defaultProps: { animation: 'perspective' }
61
- });
62
-
63
- // 自定义指令
64
- import * as directives from './directives';
65
-
66
- const setGlobal = app => {
67
- app.config.globalProperties.$hasAuthority = hasAuthority;
68
- app.config.globalProperties.$serviceApi = getServiceApi();
69
- app.config.globalProperties.$url = getBaseURL();
70
- };
71
-
72
- const setGlobalDirective = app => {
73
- Object.keys(directives).forEach(key => {
74
- app.directive(key, (directives as { [key: string]: Directive })[key]);
75
- });
76
- };
77
-
78
- const init = ({ config, lang, views, env, tableConfig }) => {
79
- app.use(router);
80
- setRouter(router);
81
- setConfig(app, config);
82
- setSystemEnv(env);
83
- setViews(views);
84
- setTableConfig(tableConfig);
85
- return new Promise(resolve => {
86
- useI18n(app, lang);
87
- app.component('IconifyIconOffline', IconifyIconOffline);
88
- app.component('FontIcon', FontIcon);
89
- // app.component('uAttachment', uAttachment).component('UGrid', UGrid);
90
- // .component('UtDivider', UtDivider)
91
- // .component('UtModalForm2', UtModalForm2)
92
- // app.component('UtGrid2', UtGrid2);
93
- // .component('UtForm', UtForm)
94
- // .component('UtContent', UtContent)
95
- // .component('UtIconSelect', UtIconSelect)
96
- // .component('UtCountdown', UtCountdown)
97
- // .component('UtCalendar', UtCalendar)
98
- // .component('UtModalGrid', UtModalGrid);
99
- app.use(VueViewer, { defaultOptions: { zIndex: 9999 } });
100
- setGlobal(app);
101
- setGlobalDirective(app);
102
- // 全局组件
103
- setupStore(app);
104
- injectResponsiveStorage(app, config);
105
- const result = { app, router };
106
- resolve(result);
107
- });
108
- };
109
-
110
- export default init;
1
+ /*
2
+ * @Author: wei.li
3
+ * @Date: 2022-10-18 18:13:54
4
+ * @LastEditors: levi7754 levi7754@163.com
5
+ * @LastEditTime: 2025-07-31 17:17:32
6
+ * @Description: file content
7
+ */
8
+ import { createApp, type Directive } from 'vue';
9
+ import App from './App.vue';
10
+ // import router from './router';
11
+ import { setViews } from './router';
12
+ import { setupStore } from './store';
13
+ import { setConfig, setSystemEnv } from './config';
14
+ import { useI18n } from '../src/plugins/i18n';
15
+ import { setTableConfig } from '../src/plugins/vxe-table';
16
+ import { injectResponsiveStorage } from './utils/storage';
17
+ import hasAuthority from './utils/authority';
18
+ import { getServiceApi, getBaseURL, setRouter } from './api';
19
+
20
+ import 'nprogress/nprogress.css';
21
+ // 一定要在main.ts中导入tailwind.css,防止vite每次hmr都会请求src/style/index.scss整体css文件导致热更新慢的问题
22
+ import './style/tailwind.css';
23
+ // // 引入重置样式
24
+ import './style/reset.scss';
25
+ // 导入公共样式
26
+ import './style/index.scss';
27
+
28
+ import 'viewerjs/dist/viewer.css';
29
+
30
+ import VueViewer from 'v-viewer';
31
+
32
+ // import SuTable from './components/SuTable/SuTable.vue';
33
+
34
+ import {
35
+ // UtButton,
36
+ // utLov2,
37
+ // UGrid,
38
+ // UtDivider,
39
+ UtModalForm2,
40
+ // FormUpload2
41
+ UtForm2,
42
+ UtGrid2,
43
+ // UtContent,
44
+ // UtCountdown2,
45
+ UtUpload2
46
+ // UtIconSelect,
47
+ // UtCalendar
48
+ // uAttachment
49
+ } from './components/udp';
50
+
51
+ const app = createApp(App);
52
+
53
+ // 全局注册`@iconify/vue`图标库
54
+ import { IconifyIconOffline, FontIcon } from './components/ReIcon';
55
+ // 全局注册`vue-tippy`
56
+ import 'tippy.js/dist/tippy.css';
57
+ import 'tippy.js/animations/perspective.css';
58
+ import VueTippy from 'vue-tippy';
59
+
60
+ app.use(VueTippy, {
61
+ defaultProps: { animation: 'perspective' }
62
+ });
63
+
64
+ // 自定义指令
65
+ import * as directives from './directives';
66
+
67
+ const setGlobal = app => {
68
+ app.config.globalProperties.$hasAuthority = hasAuthority;
69
+ app.config.globalProperties.$serviceApi = getServiceApi();
70
+ app.config.globalProperties.$url = getBaseURL();
71
+ };
72
+
73
+ const setGlobalDirective = app => {
74
+ Object.keys(directives).forEach(key => {
75
+ app.directive(key, (directives as { [key: string]: Directive })[key]);
76
+ });
77
+ };
78
+
79
+ const init = ({ router, config, lang, views, env, tableConfig }) => {
80
+ setViews(views, router);
81
+ app.use(router);
82
+ setRouter(router);
83
+ setConfig(app, config);
84
+ setSystemEnv(env);
85
+ setTableConfig(tableConfig);
86
+ return new Promise(resolve => {
87
+ useI18n(app, lang);
88
+ app.component('IconifyIconOffline', IconifyIconOffline);
89
+ app.component('FontIcon', FontIcon);
90
+ // app.component('uAttachment', uAttachment).component('UGrid', UGrid);
91
+ // .component('UtDivider', UtDivider)
92
+ app.component('UtModalForm2', UtModalForm2);
93
+ app.component('UtGrid2', UtGrid2);
94
+ app.component('UtForm2', UtForm2);
95
+ // .component('UtContent', UtContent)
96
+ // .component('UtIconSelect', UtIconSelect)
97
+ app.component('UtUpload2', UtUpload2);
98
+ // .component('UtCalendar', UtCalendar)
99
+ // .component('UtModalGrid', UtModalGrid);
100
+ app.use(VueViewer, { defaultOptions: { zIndex: 9999 } });
101
+ setGlobal(app);
102
+ setGlobalDirective(app);
103
+ // 全局组件
104
+ setupStore(app);
105
+ injectResponsiveStorage(app, config);
106
+ const result = { app, router };
107
+ resolve(result);
108
+ });
109
+ };
110
+
111
+ export default init;
@@ -2,7 +2,7 @@
2
2
  * @Author: levi7754 levi7754@163.com
3
3
  * @Date: 2024-06-05 14:32:03
4
4
  * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2025-07-21 11:37:34
5
+ * @LastEditTime: 2025-07-30 09:51:55
6
6
  * @FilePath: /udp-front/packages/udp-core/src/plugins/vxe-table/index.ts
7
7
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
8
  */
@@ -10,8 +10,8 @@ import 'xe-utils';
10
10
  import { merge } from 'xe-utils';
11
11
  import { geti18n, transformI18n } from '../i18n/index';
12
12
  // import { storageLocal } from '@utogether/utils';
13
- // import { VxetableRender } from '@utogether/utils';
14
- import { VxetableRender } from './render';
13
+ import { VxetableRender } from '@utogether/utils';
14
+ // import { VxetableRender } from './render';
15
15
  import { getServiceApi } from '../../api';
16
16
 
17
17
  import VXETable, { VxeUI } from 'vxe-table';
@@ -1,183 +1,187 @@
1
- import { findIndexOf, isEmpty } from 'xe-utils';
2
- import {
3
- type Router,
4
- createRouter,
5
- type RouteRecordRaw,
6
- type RouteComponent,
7
- createWebHistory
8
- } from 'vue-router';
9
- import { cookies, NProgress, openLink, isUrl, buildHierarchyTree } from '@utogether/utils';
10
- import { useMultiTagsStoreHook } from '../store/modules/multiTags';
11
- import { usePermissionStoreHook } from '../store/modules/permission';
12
- import {
13
- ascending,
14
- initRouter,
15
- findRouteByPath,
16
- handleAliveRoute,
17
- formatTwoStageRoutes,
18
- formatFlatteningRoutes
19
- } from './utils';
20
- import { getEnv } from '../config';
21
- import { kLOGINER } from '../contant';
22
-
23
- import homeRouter from './modules/home';
24
- import errorRouter from './modules/error';
25
- import remainingRouter from './modules/remaining';
26
-
27
- const systemRouter = import.meta.glob([
28
- '../views/system/**/*.{vue,tsx}',
29
- '../views/uapp/**/*.{vue,tsx}',
30
- '../views/upms/**/*.{vue,tsx}',
31
- '../views/ufile/**/*.{vue}',
32
- '../views/urpt/**/*.{vue,tsx}',
33
- '../views/organization/**/*.{vue,tsx}',
34
- '../views/udev/**/*.{vue, tsx}'
35
- ]);
36
-
37
- // 原始静态路由(未做任何处理)
38
- const routes = [homeRouter, errorRouter];
39
- /** 导出处理后的静态路由(三级及以上的路由全部拍成二级) */
40
- export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes(
41
- formatFlatteningRoutes(buildHierarchyTree(ascending(routes)))
42
- );
43
-
44
- /** 用于渲染菜单,保持原始层级 */
45
- export const constantMenus: Array<RouteComponent> = ascending(routes).concat(...remainingRouter);
46
-
47
- /** 不参与菜单的路由 */
48
- export const remainingPaths = Object.keys(remainingRouter).map(v => {
49
- return remainingRouter[v].path;
50
- });
51
-
52
- /** 创建路由实例 */
53
- export const router: Router = createRouter({
54
- history: createWebHistory(getEnv().VITE_ROUTER_HISTORY),
55
- routes: constantRoutes.concat(...(remainingRouter as any)),
56
- strict: true,
57
- scrollBehavior(to, from, savedPosition) {
58
- return new Promise(resolve => {
59
- if (savedPosition) {
60
- return savedPosition;
61
- } else {
62
- if (from.meta.saveSrollTop) {
63
- const top: number = document.documentElement.scrollTop || document.body.scrollTop;
64
- resolve({ left: 0, top });
65
- }
66
- }
67
- });
68
- }
69
- });
70
-
71
- /** 重置路由 */
72
- export function resetRouter() {
73
- router.getRoutes().forEach(route => {
74
- const { name, meta } = route;
75
- if (name && router.hasRoute(name) && meta?.backstage) {
76
- router.removeRoute(name);
77
- router.options.routes = formatTwoStageRoutes(
78
- formatFlatteningRoutes(buildHierarchyTree(ascending(routes)))
79
- );
80
- }
81
- });
82
- usePermissionStoreHook().clearAllCachePage();
83
- }
84
-
85
- let views = null;
86
- export function setViews(cviews) {
87
- views = cviews;
88
- Object.assign(views, systemRouter);
89
- }
90
-
91
- export function getViews() {
92
- return views;
93
- }
94
-
95
- /** 路由白名单 */
96
- const whiteList = ['/login'];
97
-
98
- router.beforeEach((to: ToRouteType, _from, next) => {
99
- if (to.meta?.keepAlive) {
100
- handleAliveRoute(to, 'add');
101
- // 页面整体刷新和点击标签页刷新
102
- if (_from.name === undefined || _from.name === 'redirect') {
103
- handleAliveRoute(to);
104
- }
105
- }
106
- const userName = cookies.get(kLOGINER);
107
- NProgress.start();
108
- const externalLink = isUrl(to?.name as string);
109
- /** 如果已经登录并存在登录信息后不能跳转到路由白名单,而是继续保持在当前页面 */
110
- function toCorrectRoute() {
111
- whiteList.includes(to.fullPath) ? next(_from.fullPath) : next();
112
- }
113
- if (userName) {
114
- // TODO 无权限跳转403页面
115
- // if (to.meta?.roles && !isOneOfArray(to.meta?.roles, userInfo?.roles)) {
116
- // next({ path: "/error/403" });
117
- // }
118
- if (_from?.name && _from?.name !== 'login') {
119
- // m.name === to.name 判断param路由跳转
120
- const cmp = to.matched.find(
121
- m => m.path === to.path || (m.name === to.name && to.params)
122
- )?.components;
123
- // 如果路由包含http 则是超链接 反之是普通路由
124
- if (externalLink) {
125
- openLink(to?.name as string);
126
- NProgress?.done();
127
- } else if (cmp?.default || to.name === 'redirect') {
128
- toCorrectRoute();
129
- } else {
130
- next({ path: '/error/404' });
131
- }
132
- } else {
133
- // 刷新
134
- if (usePermissionStoreHook().wholeMenus.length === 0) {
135
- initRouter(userName).then((router: Router) => {
136
- if (!useMultiTagsStoreHook().getMultiTagsCache) {
137
- const { path } = to;
138
- const index = findIndexOf(remainingRouter, v => v.path === path);
139
- const routes: any = index === -1 ? router.options.routes[0].children : router.options.routes;
140
- const route = findRouteByPath(path, routes);
141
- if (route && route.meta?.title) {
142
- const { path, name, meta } = route;
143
- useMultiTagsStoreHook().handleTags('push', { path, name, meta });
144
- }
145
- }
146
- // 确保动态路由完全加入路由列表并且不影响静态路由
147
- // (注意:动态路由刷新时router.beforeEach可能会触发两次,
148
- // 第一次触发动态路由还未完全添加,第二次动态路由才完全添加到路由列表,
149
- // 如果需要在router.beforeEach做一些判断可以在to.name存在的条件下去判断,这样就只会触发一次)
150
- if (isEmpty(to.name)) router.push(to.fullPath);
151
- });
152
- }
153
- if (_from.fullPath === '/' && to.fullPath === '/login' && !to.query?.tokenExpire) {
154
- to.path = '/welcome';
155
- to.fullPath = '/welcome';
156
- to.name = 'SuHome';
157
- } else if (_from.fullPath === '/' && to.path === '/workflow/approve/index') {
158
- to.path = '/welcome';
159
- to.fullPath = '/welcome';
160
- to.name = 'SuHome';
161
- to.query = {};
162
- }
163
- // next();
164
- toCorrectRoute();
165
- }
166
- } else {
167
- if (to.path !== '/login') {
168
- if (whiteList.indexOf(to.path) !== -1) {
169
- next();
170
- } else {
171
- next({ path: '/login' });
172
- }
173
- } else {
174
- next();
175
- }
176
- }
177
- });
178
-
179
- router.afterEach(() => {
180
- NProgress?.done();
181
- });
182
-
183
- export default router;
1
+ import { findIndexOf, isEmpty } from 'xe-utils';
2
+ import type { Router, RouteRecordRaw, RouteComponent } from 'vue-router';
3
+ import { cookies, NProgress, openLink, isUrl, buildHierarchyTree } from '@utogether/utils';
4
+ import { useMultiTagsStoreHook } from '../store/modules/multiTags';
5
+ import { usePermissionStoreHook } from '../store/modules/permission';
6
+ import {
7
+ ascending,
8
+ initRouter,
9
+ findRouteByPath,
10
+ formatTwoStageRoutes,
11
+ formatFlatteningRoutes
12
+ } from './utils';
13
+ // import { getEnv } from '../config';
14
+ import { kLOGINER } from '../contant';
15
+
16
+ import homeRouter from './modules/home';
17
+ import errorRouter from './modules/error';
18
+ import remainingRouter from './modules/remaining';
19
+
20
+ const systemRouter = import.meta.glob([
21
+ '../views/system/**/*.{vue,tsx}',
22
+ '../views/uapp/**/*.{vue,tsx}',
23
+ '../views/upms/**/*.{vue,tsx}',
24
+ '../views/ufile/**/*.{vue}',
25
+ '../views/urpt/**/*.{vue,tsx}',
26
+ '../views/organization/**/*.{vue,tsx}',
27
+ '../views/udev/**/*.{vue, tsx}'
28
+ ]);
29
+
30
+ export const remainingRouters = remainingRouter;
31
+
32
+ // 原始静态路由(未做任何处理)
33
+ const routes = [homeRouter, errorRouter];
34
+ /** 导出处理后的静态路由(三级及以上的路由全部拍成二级) */
35
+ export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes(
36
+ formatFlatteningRoutes(buildHierarchyTree(ascending(routes)))
37
+ );
38
+
39
+ /** 用于渲染菜单,保持原始层级 */
40
+ export const constantMenus: Array<RouteComponent> = ascending(routes).concat(...remainingRouter);
41
+
42
+ /** 不参与菜单的路由 */
43
+ export const remainingPaths = Object.keys(remainingRouter).map(v => {
44
+ return remainingRouter[v].path;
45
+ });
46
+
47
+ /** 创建路由实例 */
48
+ // export const router: Router = createRouter({
49
+ // history: createWebHistory(window.__HISTORY_PATH__),
50
+ // routes: constantRoutes.concat(...(remainingRouter as any)),
51
+ // strict: true,
52
+ // scrollBehavior(to, from, savedPosition) {
53
+ // return new Promise(resolve => {
54
+ // if (savedPosition) {
55
+ // return savedPosition;
56
+ // } else {
57
+ // if (from.meta.saveSrollTop) {
58
+ // const top: number = document.documentElement.scrollTop || document.body.scrollTop;
59
+ // resolve({ left: 0, top });
60
+ // }
61
+ // }
62
+ // });
63
+ // }
64
+ // });
65
+
66
+ /** 重置路由 */
67
+ export function resetRouter() {
68
+ router.getRoutes().forEach(route => {
69
+ const { name, meta } = route;
70
+ if (name && router.hasRoute(name) && meta?.backstage) {
71
+ router.removeRoute(name);
72
+ router.options.routes = formatTwoStageRoutes(
73
+ formatFlatteningRoutes(buildHierarchyTree(ascending(routes)))
74
+ );
75
+ }
76
+ });
77
+ usePermissionStoreHook().clearAllCachePage();
78
+ }
79
+
80
+ let views = null;
81
+ export let router = null;
82
+ export function setViews(cviews, crouter) {
83
+ views = cviews;
84
+ router = crouter;
85
+ Object.assign(views, systemRouter);
86
+ }
87
+
88
+ export function getViews() {
89
+ return views;
90
+ }
91
+
92
+ /** 路由白名单 */
93
+ const whiteList = ['/login'];
94
+ /*
95
+ router.beforeEach((to: ToRouteType, _from, next) => {
96
+ if (to.meta?.keepAlive) {
97
+ handleAliveRoute(to, 'add');
98
+ // 页面整体刷新和点击标签页刷新
99
+ if (_from.name === undefined || _from.name === 'redirect') {
100
+ handleAliveRoute(to);
101
+ }
102
+ }
103
+ const userName = cookies.get(kLOGINER);
104
+ NProgress.start();
105
+ if (userName) {
106
+ routerBefore(to, _from, next);
107
+ } else {
108
+ if (to.path !== '/login') {
109
+ if (whiteList.indexOf(to.path) !== -1) {
110
+ next();
111
+ } else {
112
+ next({ path: '/login' });
113
+ }
114
+ } else {
115
+ next();
116
+ }
117
+ }
118
+ });
119
+
120
+ router.afterEach(() => {
121
+ NProgress?.done();
122
+ });
123
+
124
+ */
125
+ export const routerBefore = (to, _from, next) => {
126
+ // TODO 无权限跳转403页面
127
+ // if (to.meta?.roles && !isOneOfArray(to.meta?.roles, userInfo?.roles)) {
128
+ // next({ path: "/error/403" });
129
+ // }
130
+ const userName = cookies.get(kLOGINER);
131
+
132
+ const externalLink = isUrl(to?.name as string);
133
+ /** 如果已经登录并存在登录信息后不能跳转到路由白名单,而是继续保持在当前页面 */
134
+ function toCorrectRoute() {
135
+ whiteList.includes(to.fullPath) ? next(_from.fullPath) : next();
136
+ }
137
+ if (_from?.name && _from?.name !== 'login') {
138
+ // m.name === to.name 判断param路由跳转
139
+ const cmp = to.matched.find(
140
+ m => m.path === to.path || (m.name === to.name && to.params)
141
+ )?.components;
142
+ // 如果路由包含http 则是超链接 反之是普通路由
143
+ if (externalLink) {
144
+ openLink(to?.name as string);
145
+ NProgress?.done();
146
+ } else if (cmp?.default || to.name === 'redirect') {
147
+ toCorrectRoute();
148
+ } else {
149
+ next({ path: '/error/404' });
150
+ }
151
+ } else {
152
+ // 刷新
153
+ if (usePermissionStoreHook().wholeMenus.length === 0) {
154
+ initRouter(userName).then((router: Router) => {
155
+ if (!useMultiTagsStoreHook().getMultiTagsCache) {
156
+ const { path } = to;
157
+ const index = findIndexOf(remainingRouter, v => v.path === path);
158
+ const routes: any = index === -1 ? router.options.routes[0].children : router.options.routes;
159
+ const route = findRouteByPath(path, routes);
160
+ if (route && route.meta?.title) {
161
+ const { path, name, meta } = route;
162
+ useMultiTagsStoreHook().handleTags('push', { path, name, meta });
163
+ }
164
+ }
165
+ // 确保动态路由完全加入路由列表并且不影响静态路由
166
+ // (注意:动态路由刷新时router.beforeEach可能会触发两次,
167
+ // 第一次触发动态路由还未完全添加,第二次动态路由才完全添加到路由列表,
168
+ // 如果需要在router.beforeEach做一些判断可以在to.name存在的条件下去判断,这样就只会触发一次)
169
+ if (isEmpty(to.name)) router.push(to.fullPath);
170
+ });
171
+ }
172
+ if (_from.fullPath === '/' && to.fullPath === '/login' && !to.query?.tokenExpire) {
173
+ to.path = '/welcome';
174
+ to.fullPath = '/welcome';
175
+ to.name = 'SuHome';
176
+ } else if (_from.fullPath === '/' && to.path === '/workflow/approve/index') {
177
+ to.path = '/welcome';
178
+ to.fullPath = '/welcome';
179
+ to.name = 'SuHome';
180
+ to.query = {};
181
+ }
182
+ // next();
183
+ toCorrectRoute();
184
+ }
185
+ };
186
+
187
+ // export default router;