@skyfox2000/webui 1.0.13 → 1.2.0

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 (162) hide show
  1. package/lib/assets/modules/file-upload-CBUcsUnR.js +170 -0
  2. package/lib/assets/modules/form-validate-CgX7aR7T.js +297 -0
  3. package/lib/assets/modules/index-Civhd8xG.js +112 -0
  4. package/lib/assets/modules/index-DQMdt51R.js +726 -0
  5. package/lib/assets/modules/{index-BEWJ_qAH.js → index-DmWrkTXX.js} +1 -1
  6. package/lib/assets/modules/{menuTabs-BXdbFZor.js → menuTabs-BRYvFWA-.js} +131 -121
  7. package/lib/assets/modules/settingInfo-BZakNKIN.js +999 -0
  8. package/lib/assets/modules/uploadList-B7XoxGOh.js +278 -0
  9. package/lib/components/common/icon/index.vue.d.ts +1 -1
  10. package/lib/components/content/dialog/index.vue.d.ts +1 -1
  11. package/lib/components/content/drawer/index.vue.d.ts +1 -1
  12. package/lib/components/content/form/index.vue.d.ts +1 -1
  13. package/lib/components/content/search/index.vue.d.ts +1 -1
  14. package/lib/components/content/table/index.vue.d.ts +1 -1
  15. package/lib/components/content/table/tableOperate.vue.d.ts +1 -1
  16. package/lib/components/content/toolbar/icontool.vue.d.ts +1 -1
  17. package/lib/components/content/toolbar/index.vue.d.ts +1 -1
  18. package/lib/components/content/tree/index.vue.d.ts +1 -1
  19. package/lib/components/form/transfer/transferTable.vue.d.ts +1 -1
  20. package/lib/components/form/treeSelect/index.vue.d.ts +1 -1
  21. package/lib/components/form/upload/uploadList.vue.d.ts +1 -1
  22. package/lib/const/options.d.ts +32 -0
  23. package/lib/directives/enter-submit.d.ts +4 -0
  24. package/lib/directives/index.d.ts +2 -0
  25. package/lib/directives/permission.d.ts +5 -0
  26. package/lib/es/AceEditor/index.js +9 -8
  27. package/lib/es/BasicLayout/index.js +28 -24
  28. package/lib/es/Error403/index.js +15 -10
  29. package/lib/es/Error404/index.js +15 -10
  30. package/lib/es/ExcelForm/index.js +380 -175
  31. package/lib/es/UploadForm/index.js +23 -20
  32. package/lib/index.d.ts +42 -2
  33. package/lib/router/index.d.ts +16 -0
  34. package/lib/stores/appInfo.d.ts +34 -0
  35. package/lib/stores/hostInfo.d.ts +9 -0
  36. package/lib/stores/pageInfo.d.ts +18 -0
  37. package/lib/stores/pinia.d.ts +3 -0
  38. package/lib/stores/settingInfo.d.ts +8 -0
  39. package/lib/stores/userInfo.d.ts +21 -0
  40. package/lib/typings/data.d.ts +80 -0
  41. package/lib/typings/form.d.ts +171 -0
  42. package/lib/typings/menu.d.ts +7 -0
  43. package/lib/typings/option.d.ts +175 -0
  44. package/lib/typings/page.d.ts +69 -0
  45. package/lib/typings/table.d.ts +181 -0
  46. package/lib/typings/tools.d.ts +130 -0
  47. package/lib/typings/tree.d.ts +72 -0
  48. package/lib/typings/upload.d.ts +161 -0
  49. package/lib/typings/urls.d.ts +69 -0
  50. package/lib/utils/cache.d.ts +23 -0
  51. package/lib/utils/data.d.ts +6 -0
  52. package/lib/utils/download.d.ts +4 -0
  53. package/lib/utils/eventbus.d.ts +16 -0
  54. package/lib/utils/export-table.d.ts +12 -0
  55. package/lib/utils/file-upload.d.ts +15 -0
  56. package/lib/utils/form-excel.d.ts +30 -0
  57. package/lib/utils/form-validate.d.ts +29 -0
  58. package/lib/utils/form.d.ts +9 -0
  59. package/lib/utils/icon-loader.d.ts +125 -0
  60. package/lib/utils/isEmpty.d.ts +1 -0
  61. package/lib/utils/main-openapis.d.ts +9 -0
  62. package/lib/utils/menu.d.ts +6 -0
  63. package/lib/utils/options.d.ts +10 -0
  64. package/lib/utils/page.d.ts +25 -0
  65. package/lib/utils/table.d.ts +21 -0
  66. package/lib/utils/tools.d.ts +18 -0
  67. package/lib/utils/tree.d.ts +3 -0
  68. package/lib/vite-env.d.ts +8 -0
  69. package/lib/webui.css +1 -1
  70. package/lib/webui.es.js +1020 -854
  71. package/package.json +7 -6
  72. package/src/components/common/icon/appicon.vue +1 -1
  73. package/src/components/common/icon/fullscreen.vue +2 -1
  74. package/src/components/common/icon/index.vue +1 -1
  75. package/src/components/common/icon/layoutIcon.vue +1 -1
  76. package/src/components/common/icon/projectIcon.vue +1 -1
  77. package/src/components/common/icon/toolIcon.vue +1 -1
  78. package/src/components/content/dialog/excelForm.vue +2 -2
  79. package/src/components/content/dialog/index.vue +1 -1
  80. package/src/components/content/dialog/uploadForm.vue +7 -6
  81. package/src/components/content/drawer/index.vue +43 -18
  82. package/src/components/content/form/formItem.vue +1 -1
  83. package/src/components/content/form/index.vue +1 -1
  84. package/src/components/content/search/index.vue +1 -1
  85. package/src/components/content/search/searchItem.vue +1 -1
  86. package/src/components/content/table/index.vue +8 -5
  87. package/src/components/content/table/tableOperate.vue +8 -4
  88. package/src/components/content/toolbar/icontool.vue +2 -2
  89. package/src/components/content/toolbar/index.vue +9 -5
  90. package/src/components/content/tree/index.vue +1 -1
  91. package/src/components/error/error403.vue +2 -2
  92. package/src/components/error/error404.vue +2 -2
  93. package/src/components/form/autoComplete/index.vue +1 -1
  94. package/src/components/form/cascader/index.vue +1 -2
  95. package/src/components/form/checkbox/index.vue +11 -5
  96. package/src/components/form/datePicker/index.vue +1 -1
  97. package/src/components/form/input/index.vue +1 -1
  98. package/src/components/form/input/inputNumber.vue +1 -1
  99. package/src/components/form/input/inputPassword.vue +1 -1
  100. package/src/components/form/radio/index.vue +1 -1
  101. package/src/components/form/radio/radioStatus.vue +1 -1
  102. package/src/components/form/rangePicker/index.vue +1 -1
  103. package/src/components/form/select/index.vue +1 -1
  104. package/src/components/form/switch/index.vue +7 -3
  105. package/src/components/form/textarea/index.vue +1 -1
  106. package/src/components/form/transfer/index.vue +1 -1
  107. package/src/components/form/transfer/transferTable.vue +42 -22
  108. package/src/components/form/treeSelect/index.vue +2 -3
  109. package/src/components/form/upload/uploadList.vue +1 -1
  110. package/src/components/layout/breadcrumb/index.vue +1 -1
  111. package/src/components/layout/header/headerExits.vue +1 -1
  112. package/src/components/layout/header/index.vue +1 -1
  113. package/src/components/layout/header/user.vue +2 -1
  114. package/src/components/layout/menu/index.vue +9 -3
  115. package/src/components/layout/menu/menuTabs.vue +10 -12
  116. package/src/components/layout/page/basicLayout.vue +1 -1
  117. package/src/const/options.ts +114 -0
  118. package/src/directives/enter-submit.ts +13 -0
  119. package/src/directives/index.ts +26 -0
  120. package/src/directives/permission.ts +144 -0
  121. package/src/index.ts +201 -0
  122. package/src/router/index.ts +196 -0
  123. package/src/stores/appInfo.ts +471 -0
  124. package/src/stores/hostInfo.ts +117 -0
  125. package/src/stores/pageInfo.ts +131 -0
  126. package/src/stores/pinia.ts +10 -0
  127. package/src/stores/settingInfo.ts +53 -0
  128. package/src/stores/userInfo.ts +392 -0
  129. package/src/typings/data.d.ts +81 -0
  130. package/src/typings/form.d.ts +172 -0
  131. package/src/typings/menu.d.ts +7 -0
  132. package/src/typings/option.d.ts +177 -0
  133. package/src/typings/page.d.ts +70 -0
  134. package/src/typings/table.d.ts +182 -0
  135. package/src/typings/tools.d.ts +131 -0
  136. package/src/typings/tree.d.ts +73 -0
  137. package/src/typings/upload.d.ts +162 -0
  138. package/src/typings/urls.d.ts +70 -0
  139. package/src/utils/cache.ts +175 -0
  140. package/src/utils/data.ts +189 -0
  141. package/src/utils/download.ts +80 -0
  142. package/src/utils/eventbus.ts +78 -0
  143. package/src/utils/export-table.ts +155 -0
  144. package/src/utils/file-upload.ts +304 -0
  145. package/src/utils/form-excel.ts +523 -0
  146. package/src/utils/form-validate.ts +368 -0
  147. package/src/utils/form.ts +188 -0
  148. package/src/utils/icon-loader.ts +412 -0
  149. package/src/utils/isEmpty.ts +18 -0
  150. package/src/utils/main-openapis.ts +72 -0
  151. package/src/utils/menu.ts +89 -0
  152. package/src/utils/options.ts +324 -0
  153. package/src/utils/page.ts +262 -0
  154. package/src/utils/table.ts +274 -0
  155. package/src/utils/tools.ts +362 -0
  156. package/src/utils/tree.ts +28 -0
  157. package/tsconfig.json +1 -8
  158. package/vite.config.ts +7 -4
  159. package/lib/assets/modules/index-BahGnrAq.js +0 -415
  160. package/lib/assets/modules/index-BoKIa2sr.js +0 -109
  161. package/lib/assets/modules/index-D47Ci-T3.js +0 -107
  162. package/lib/assets/modules/uploadList-Dzlg47V0.js +0 -182
package/src/index.ts ADDED
@@ -0,0 +1,201 @@
1
+ // 类型定义 - 明确导出
2
+ export type {
3
+ // 基础数据类型
4
+ AnyControl,
5
+ PostOptions,
6
+ ExecuteOptions,
7
+ } from '@/typings/data.d';
8
+
9
+ export type {
10
+ // 页面类型
11
+ PageControl,
12
+ PageControlOption,
13
+ PrimaryKey,
14
+ } from '@/typings/page.d';
15
+
16
+ // 导出枚举
17
+ export { ProviderKeys } from '@/typings/page.d';
18
+
19
+ export type {
20
+ // 表格类型
21
+ GridControl,
22
+ GridControlOption,
23
+ } from '@/typings/table.d';
24
+
25
+ export type {
26
+ // 表单类型
27
+ EditorControl,
28
+ EditorControlOption,
29
+ InputFactoryItems,
30
+ ValidateRule,
31
+ ValidateRuleItem,
32
+ ValidateError,
33
+ } from '@/typings/form.d';
34
+
35
+ export type {
36
+ // 工具按钮类型
37
+ ButtonTool,
38
+ ButtonTools,
39
+ ButtonType,
40
+ IconTool,
41
+ RowRecord,
42
+ } from '@/typings/tools.d';
43
+
44
+ export type {
45
+ // 树控件类型
46
+ TreeControl,
47
+ TreeControlOption,
48
+ TreeNode,
49
+ } from '@/typings/tree.d';
50
+
51
+ export type {
52
+ // 上传类型
53
+ UploadFile,
54
+ MinioFile,
55
+ ExcelFileParams,
56
+ } from '@/typings/upload.d';
57
+
58
+ // 导出上传状态枚举
59
+ export { UploadStatus } from '@/typings/upload.d';
60
+
61
+ export type {
62
+ // URL类型
63
+ ApiUrls,
64
+ ReqUrls,
65
+ } from '@/typings/urls.d';
66
+
67
+ export type {
68
+ // 选项类型
69
+ OptionItemProps,
70
+ OptionProps,
71
+ SelectValue,
72
+ } from '@/typings/option.d';
73
+
74
+ export type {
75
+ // 菜单类型
76
+ BreadcrumbRoute,
77
+ } from '@/typings/menu.d';
78
+
79
+ // 常量导出 - 明确导出
80
+ export { OPTIONS } from '@/const/options';
81
+ export { OptionCommProps } from '@/typings/option.d';
82
+
83
+ // 指令模块导出
84
+ export { initDirective } from '@/directives/index';
85
+
86
+ // 工具函数导出 - 明确导出每个函数
87
+ // isEmpty 工具
88
+ export { isEmpty } from '@/utils/isEmpty';
89
+
90
+ // tree 工具
91
+ export { queryTree } from '@/utils/tree';
92
+
93
+ // tools 工具
94
+ export {
95
+ getToolByKey,
96
+ getToolGroup,
97
+ getToolStatus,
98
+ getToolVisible,
99
+ onReloadClick,
100
+ onToolClicked,
101
+ onFullscreenClick,
102
+ onColumnVisibleChanged,
103
+ defaultTools,
104
+ useToolFactory,
105
+ } from '@/utils/tools';
106
+
107
+ // page 工具
108
+ export { initPageFactory, useEditorFactory, useGridFactory, useTreeFactory, usePageFactory } from '@/utils/page';
109
+
110
+ // options 工具
111
+ export {
112
+ loadOption,
113
+ unloadOption,
114
+ getSelectedValues,
115
+ outFormDataFields,
116
+ onOptionChanged,
117
+ getSelectedLabels,
118
+ } from '@/utils/options';
119
+
120
+ // download 工具
121
+ export { downloadBlob, donwloadFromMinio } from '@/utils/download';
122
+
123
+ // icon-loader 工具
124
+ export {
125
+ ICONS_LIB,
126
+ checkIconsExpired,
127
+ circleLoading,
128
+ createFromIconfont,
129
+ parseIcons,
130
+ getIconTransform,
131
+ } from '@/utils/icon-loader';
132
+
133
+ // cache 工具
134
+ export { CacheKeys, Cache, initCacheCheck } from '@/utils/cache';
135
+
136
+ // menu 工具
137
+ export { initMenu, crumbs, showBreadcrumb } from '@/utils/menu';
138
+
139
+ // form 工具
140
+ export { onFormSave, onFormSaveAs, onFormClose, saveForm, getFormDetail, openNewForm, setFormData } from '@/utils/form';
141
+
142
+ // form-validate 工具
143
+ export {
144
+ initValidate,
145
+ formValidate,
146
+ validateData,
147
+ resetRules,
148
+ getRuleTexts,
149
+ useInputFactory,
150
+ useFormItemFactory,
151
+ } from '@/utils/form-validate';
152
+
153
+ // form-excel 工具
154
+ export { validateExcel, checkExcelDuplicates, processExcelFile } from '@/utils/form-excel';
155
+ export type { ExcelMarkCell, ExcelMarkInfo } from '@/utils/form-excel';
156
+
157
+ // table 工具
158
+ export {
159
+ filterColumns,
160
+ mergeColumns,
161
+ gridQueryList,
162
+ gridQueryFind,
163
+ gridRowUpdate,
164
+ gridStatusUpdate,
165
+ getRecordDetail,
166
+ onGridRowExpand,
167
+ onGridRowEdit,
168
+ onGridRowDelete,
169
+ } from '@/utils/table';
170
+
171
+ // data 工具
172
+ export { doQuery, doExecute, doSave, doDelete } from '@/utils/data';
173
+
174
+ // export-table 工具
175
+ export { exportSelectedRows, exportResults } from '@/utils/export-table';
176
+
177
+ // file-upload 工具
178
+ export { path, AsyncUploader } from '@/utils/file-upload';
179
+
180
+ // eventbus 工具
181
+ export { EventPrefix } from '@/utils/eventbus';
182
+ export { default as eventBus } from '@/utils/eventbus';
183
+
184
+ export {
185
+ getHostInfo,
186
+ getAppInfo,
187
+ userLogin,
188
+ userLogout,
189
+ getToken,
190
+ getUserInfo,
191
+ mainAppPush,
192
+ } from '@/utils/main-openapis';
193
+
194
+ import router from '@/router';
195
+ export { router as AppRouter };
196
+
197
+ export { useAppInfo } from '@/stores/appInfo';
198
+ export { useHostInfo } from '@/stores/hostInfo';
199
+ export { useUserInfo } from '@/stores/userInfo';
200
+ export { usePageInfo } from '@/stores/pageInfo';
201
+ export { useSettingInfo } from '@/stores/settingInfo';
@@ -0,0 +1,196 @@
1
+ import { useUserInfo } from '@/stores/userInfo';
2
+ import { isMicroApp, mainAppApis, RouteRecord, EnvConfig } from '@skyfox2000/microbase';
3
+ import { RouteLocationNormalizedGeneric, RouteRecordRaw, Router, createRouter, createWebHashHistory } from 'vue-router';
4
+ import { useAppInfo } from '@/stores/appInfo';
5
+ import { Ref, ref } from 'vue';
6
+
7
+ export const LOGIN_PATH = '/login/';
8
+
9
+ /**
10
+ * 默认路由
11
+ */
12
+ const routes: RouteRecord[] = [];
13
+
14
+ /**
15
+ * 添加子应用路径
16
+ * @param subRoutes 子应用路由
17
+ */
18
+ export const addAppRoutes = (subRoutes: RouteRecord[]) => {
19
+ for (const route of subRoutes) {
20
+ /// 删除重复的路由
21
+ const index = routes.findIndex((r) => r.path === route.path);
22
+ if (index !== -1) {
23
+ routes.splice(index, 1);
24
+ }
25
+ routes.push(route);
26
+ router.addRoute(route);
27
+ }
28
+ };
29
+
30
+ /**
31
+ * 平铺路由地址,方便快速查找
32
+ */
33
+ export const flattenRoute = (
34
+ route: RouteRecordRaw,
35
+ flattenRoutes: Record<string, RouteRecord>,
36
+ parent?: RouteRecord,
37
+ parentPath = '',
38
+ ): void => {
39
+ const path = parentPath + (parentPath ? '/' : '') + route.path;
40
+ flattenRoutes[path] = { ...route, parent: parent };
41
+ if (route.children) {
42
+ route.children.forEach((child) => flattenRoute(child, flattenRoutes, route as RouteRecord, path));
43
+ }
44
+ };
45
+
46
+ const router: Router = createRouter({
47
+ history: createWebHashHistory('/'),
48
+ routes: routes,
49
+ });
50
+
51
+ export { routes };
52
+
53
+ /**
54
+ * 路由权限判断
55
+ * @param route 指定路由
56
+ * @param isLogin 是否已登录
57
+ * @returns 权限判断结果
58
+ */
59
+ export const hasPermission = (route: RouteRecord, isLogin: boolean): boolean => {
60
+ const roles = route.meta?.roles ?? [];
61
+ const permission = route.meta?.permission;
62
+
63
+ // 如果用户未登录,且路由没有角色和权限要求,则允许访问
64
+ if (!isLogin) {
65
+ return roles.length === 0 && !permission;
66
+ }
67
+
68
+ // 如果用户已登录
69
+ if (isLogin) {
70
+ const userInfoStore = useUserInfo();
71
+
72
+ if (EnvConfig.VITE_PERMISSION_MODE === 'role') {
73
+ // 仅判断角色权限,未配置或者长度为0则可以访问
74
+ if (roles.length === 0) {
75
+ return true;
76
+ }
77
+ return userInfoStore.hasRole(roles);
78
+ } else if (EnvConfig.VITE_PERMISSION_MODE === 'permit') {
79
+ // 角色或权限任意满足要求即可
80
+
81
+ // 如果都没有配置,默认允许访问
82
+ if (roles.length === 0 && !permission) {
83
+ return true;
84
+ }
85
+
86
+ let hasRolePermission = false;
87
+ let hasPermitPermission = false;
88
+
89
+ // 检查角色权限
90
+ if (roles.length > 0) {
91
+ hasRolePermission = userInfoStore.hasRole(roles);
92
+ }
93
+
94
+ // 检查功能权限
95
+ if (permission) {
96
+ hasPermitPermission = userInfoStore.hasPermit(route.path, ':page');
97
+ }
98
+
99
+ // 任意一个有权限即可访问
100
+ return hasRolePermission || hasPermitPermission;
101
+ }
102
+ }
103
+
104
+ // 默认返回 false,即无匹配条件时不允许访问
105
+ return false;
106
+ };
107
+
108
+ // 保存等待处理的路由导航
109
+ export const pendingNavigation: Ref<{ to: RouteLocationNormalizedGeneric; next: Function } | null> = ref(null);
110
+
111
+ /**
112
+ * 路由导航守卫
113
+ * 处理权限检查和登录重定向
114
+ */
115
+ router.beforeEach((to, _from, next) => {
116
+ const toRoute = to as unknown as RouteRecord;
117
+
118
+ if (to.path.startsWith('/error/') || to.path.startsWith(LOGIN_PATH)) {
119
+ return next();
120
+ }
121
+ const meta = toRoute.meta;
122
+ const roles = meta?.roles ?? [];
123
+ const requiresAuth = roles.length > 0 || meta?.permission?.length; // 判断是否需要权限
124
+
125
+ // 如果是根路径,重定向到默认页面
126
+ if (to.path === '/') {
127
+ const appInfoStore = useAppInfo();
128
+ if (!appInfoStore.menuLoaded) {
129
+ pendingNavigation.value = {
130
+ to,
131
+ next: (defaultPage: string) => {
132
+ next({ path: defaultPage });
133
+ },
134
+ };
135
+ return;
136
+ }
137
+ // 获取默认应用
138
+ appInfoStore.toDefaultApp();
139
+ return;
140
+ }
141
+
142
+ if (!requiresAuth) {
143
+ next(); // 不需要权限的页面,直接允许访问
144
+ } else {
145
+ const userInfoStore = useUserInfo();
146
+ if (!userInfoStore.isLogin) {
147
+ // 未登录,跳转到登录界面
148
+ next({ path: LOGIN_PATH });
149
+ } else {
150
+ const appInfoStore = useAppInfo();
151
+ // 如果菜单未加载完成且不是登录页,先保存当前导航信息,等待菜单加载完成
152
+ if (!appInfoStore.menuLoaded) {
153
+ pendingNavigation.value = {
154
+ to,
155
+ next,
156
+ };
157
+ return;
158
+ }
159
+
160
+ const permitResult = hasPermission(toRoute, userInfoStore.isLogin);
161
+ if (permitResult) {
162
+ next();
163
+ } else {
164
+ next(); // 无权限时重定向到403页面
165
+ }
166
+ }
167
+ }
168
+ });
169
+
170
+ /**
171
+ * 子应用更新主应用路由
172
+ */
173
+ router.afterEach((to: RouteLocationNormalizedGeneric) => {
174
+ if (isMicroApp() && mainAppApis.value) {
175
+ const { mainAppPush } = mainAppApis.value;
176
+ if (mainAppPush) mainAppPush(to.hash);
177
+ }
178
+ });
179
+
180
+ /**
181
+ * 继续执行之前挂起的导航
182
+ * @param path 默认路径
183
+ */
184
+ export const continueNavigation = (defaultPage: string) => {
185
+ if (pendingNavigation.value) {
186
+ const { to, next } = pendingNavigation.value;
187
+ pendingNavigation.value = null;
188
+ if (to.path === '/') {
189
+ next(defaultPage);
190
+ } else {
191
+ next(to.path);
192
+ }
193
+ }
194
+ };
195
+
196
+ export default router;