@gientech/modual 1.3.0 → 1.3.2

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 (308) hide show
  1. package/README.md +129 -129
  2. package/{dist/assets/mysql.svg → assets/MySQL.svg} +14 -14
  3. package/{dist/assets → assets}/database.svg +11 -11
  4. package/{src/modules/database/assets → assets}/database_add.svg +53 -53
  5. package/{dist/assets → assets}/database_connect.svg +66 -66
  6. package/{dist/assets → assets}/database_upload.svg +29 -29
  7. package/{dist/assets → assets}/defaultWeLogo.svg +14 -14
  8. package/{dist/assets/index-DIm7RgkM.js → assets/index-D-dGaGjW.js} +93 -279
  9. package/assets/index-ldqIbm0x.js +1289 -0
  10. package/assets/style.css +1 -0
  11. package/assets/style3.css +1 -0
  12. package/{dist/chat.js → chat.js} +78 -78
  13. package/database.js +20 -0
  14. package/{dist/databaseId.js → databaseId.js} +1 -1
  15. package/{dist/databaseTable.js → databaseTable.js} +1 -1
  16. package/{dist/modelManage.js → modelManage.js} +1 -1
  17. package/package.json +39 -83
  18. package/{dist/sensitive.js → sensitive.js} +1 -1
  19. package/{dist/streamFilesReader.js → streamFilesReader.js} +11 -11
  20. package/{dist/worker → worker}/pdf.worker.min.js +21 -21
  21. package/.editorconfig +0 -38
  22. package/.prettierignore +0 -16
  23. package/.prettierrc +0 -17
  24. package/USAGE.md +0 -191
  25. package/bash.exe.stackdump +0 -40
  26. package/components.json +0 -21
  27. package/dist/README.md +0 -129
  28. package/dist/assets/database_add.svg +0 -53
  29. package/dist/assets/index-Bpnc4tRH.js +0 -1284
  30. package/dist/assets/style.css +0 -1
  31. package/dist/assets/style3.css +0 -1
  32. package/dist/database.js +0 -20
  33. package/dist/package.json +0 -56
  34. package/doc_assets/2.png +0 -0
  35. package/doc_assets/demo.md +0 -27
  36. package/doc_assets/demos/dist-app/assets/index.Dh-ZAS9Z.css +0 -2
  37. package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js +0 -23699
  38. package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js.map +0 -1
  39. package/doc_assets/demos/dist-app/index.html +0 -14
  40. package/doc_assets/demos/dist-app/vite.svg +0 -1
  41. package/doc_assets/images/1.png +0 -0
  42. package/doc_assets/images/3.png +0 -0
  43. package/doc_assets/images/component-screenshot.png +0 -1
  44. package/doc_assets/install.md +0 -5
  45. package/eslint.config.js +0 -92
  46. package/index.html +0 -13
  47. package/postcss.config.cjs +0 -19
  48. package/public/vite.svg +0 -1
  49. package/public/worker/pdf.worker.min.js +0 -22
  50. package/scripts/README.md +0 -133
  51. package/scripts/build-demo.js +0 -88
  52. package/scripts/demo-selector.js +0 -216
  53. package/scripts/dev-demo.js +0 -76
  54. package/scripts/preview-demo.js +0 -130
  55. package/scripts/run-demo.bat +0 -34
  56. package/src/assets/img/downArrow.png +0 -0
  57. package/src/assets/img/excel.png +0 -0
  58. package/src/assets/img/img.png +0 -0
  59. package/src/assets/img/pdf.png +0 -0
  60. package/src/assets/img/ppt.png +0 -0
  61. package/src/assets/img/txt.png +0 -0
  62. package/src/assets/img/word.png +0 -0
  63. package/src/assets/login/homeBg.png +0 -0
  64. package/src/assets/login/left.jpg +0 -0
  65. package/src/assets/login/logoImg.png +0 -0
  66. package/src/examples/LoginPage/index.tsx +0 -18
  67. package/src/examples/chat/components/DrawerGraphPreview.tsx +0 -77
  68. package/src/examples/chat/index.tsx +0 -179
  69. package/src/examples/gientechStreamFilesReader/index.tsx +0 -1016
  70. package/src/examples/ragDatabaseDataPage/index.tsx +0 -36
  71. package/src/examples/ragDatabaseIdPage/index.tsx +0 -44
  72. package/src/examples/ragDatabasePage/index.tsx +0 -36
  73. package/src/examples/ragModelManagePage/index.tsx +0 -37
  74. package/src/examples/ragSearchPage/index.tsx +0 -0
  75. package/src/examples/ragSensitiveWordsPage/index.tsx +0 -32
  76. package/src/examples/streamFiles/index.tsx +0 -384
  77. package/src/lib_enter.ts +0 -38
  78. package/src/main.tsx +0 -5
  79. package/src/main.tsx.backup +0 -5
  80. package/src/modules/chat/Conversations/Item.tsx +0 -167
  81. package/src/modules/chat/Conversations/List.tsx +0 -143
  82. package/src/modules/chat/Conversations/groupByTime.ts +0 -39
  83. package/src/modules/chat/Conversations/index.tsx +0 -212
  84. package/src/modules/chat/constants.tsx +0 -33
  85. package/src/modules/chat/index.tsx +0 -1836
  86. package/src/modules/chat/types.ts +0 -17
  87. package/src/modules/database/CreateModal.tsx +0 -398
  88. package/src/modules/database/assets/Doris.png +0 -0
  89. package/src/modules/database/assets/PostgreSQL.png +0 -0
  90. package/src/modules/database/assets/SQLServer.png +0 -0
  91. package/src/modules/database/assets/database.svg +0 -11
  92. package/src/modules/database/assets/database_connect.svg +0 -66
  93. package/src/modules/database/assets/database_upload.svg +0 -29
  94. package/src/modules/database/assets/empty.png +0 -0
  95. package/src/modules/database/assets/mysql.svg +0 -14
  96. package/src/modules/database/index.tsx +0 -466
  97. package/src/modules/database/server.ts +0 -196
  98. package/src/modules/databaseId/CustomCom.tsx +0 -156
  99. package/src/modules/databaseId/EditConfig.tsx +0 -268
  100. package/src/modules/databaseId/UploadDrawer.tsx +0 -520
  101. package/src/modules/databaseId/assets/aiOptimize.svg +0 -10
  102. package/src/modules/databaseId/assets/empty.png +0 -0
  103. package/src/modules/databaseId/assets/template.svg +0 -6
  104. package/src/modules/databaseId/assets/upload.svg +0 -9
  105. package/src/modules/databaseId/assets/useTemp.svg +0 -6
  106. package/src/modules/databaseId/index.tsx +0 -734
  107. package/src/modules/databaseId/server.ts +0 -286
  108. package/src/modules/databaseId/style.css +0 -5
  109. package/src/modules/databaseTable/EditRowDrawer.tsx +0 -119
  110. package/src/modules/databaseTable/index.tsx +0 -357
  111. package/src/modules/databaseTable/server.ts +0 -180
  112. package/src/modules/headlessChat/constants.tsx +0 -32
  113. package/src/modules/headlessChat/index.tsx +0 -1065
  114. package/src/modules/headlessChat/types.ts +0 -23
  115. package/src/modules/login/components/Login/LoginBox/index.tsx +0 -102
  116. package/src/modules/login/components/Login/RegisterBox/index.tsx +0 -180
  117. package/src/modules/login/components/Login/index.tsx +0 -100
  118. package/src/modules/login/index.tsx +0 -106
  119. package/src/modules/login/style.css +0 -3
  120. package/src/modules/login/useServices.ts +0 -53
  121. package/src/modules/login/utils.ts +0 -42
  122. package/src/modules/modelManage/ConfigDrawer.tsx +0 -249
  123. package/src/modules/modelManage/assets/empty.png +0 -0
  124. package/src/modules/modelManage/const.ts +0 -50
  125. package/src/modules/modelManage/index.tsx +0 -439
  126. package/src/modules/modelManage/server.ts +0 -185
  127. package/src/modules/nodegraph/index.tsx +0 -1
  128. package/src/modules/search/assets/Icon-history.svg +0 -8
  129. package/src/modules/search/assets/answerAwartar.png +0 -0
  130. package/src/modules/search/assets/doc.png +0 -0
  131. package/src/modules/search/assets/genera.gif +0 -0
  132. package/src/modules/search/assets/icon-robot.svg +0 -9
  133. package/src/modules/search/assets/icon-search-bar.svg +0 -14
  134. package/src/modules/search/assets/icon-sub-title.svg +0 -3
  135. package/src/modules/search/assets/icon-title.svg +0 -9
  136. package/src/modules/search/assets/icon-zoomOut.svg +0 -9
  137. package/src/modules/search/assets/iconAi.svg +0 -9
  138. package/src/modules/search/assets/pdf.png +0 -0
  139. package/src/modules/search/assets/ppt.png +0 -0
  140. package/src/modules/search/assets/search.svg +0 -3
  141. package/src/modules/search/assets/selected.svg +0 -4
  142. package/src/modules/search/assets/txt.png +0 -0
  143. package/src/modules/search/assets/xls.png +0 -0
  144. package/src/modules/search/components/AssisSelect.tsx +0 -137
  145. package/src/modules/search/components/Editor/ChatViewEditor.tsx +0 -261
  146. package/src/modules/search/components/Editor/aichat.css +0 -1
  147. package/src/modules/search/components/Editor/constant.ts +0 -13
  148. package/src/modules/search/components/Editor/index.tsx +0 -113
  149. package/src/modules/search/components/Editor/plugins/autofomatRules.ts +0 -332
  150. package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +0 -20
  151. package/src/modules/search/components/Editor/plugins/createIndexes.tsx +0 -38
  152. package/src/modules/search/components/Editor/plugins/displayer.ts +0 -298
  153. package/src/modules/search/components/Editor/plugins/imageClick.tsx +0 -32
  154. package/src/modules/search/components/Editor/plugins/myplugin.tsx +0 -98
  155. package/src/modules/search/components/Editor/ui/avatar.tsx +0 -19
  156. package/src/modules/search/components/Editor/ui/blockquote-element.tsx +0 -21
  157. package/src/modules/search/components/Editor/ui/button.tsx +0 -58
  158. package/src/modules/search/components/Editor/ui/calendar.tsx +0 -68
  159. package/src/modules/search/components/Editor/ui/caption.tsx +0 -46
  160. package/src/modules/search/components/Editor/ui/checkbox.tsx +0 -27
  161. package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +0 -188
  162. package/src/modules/search/components/Editor/ui/code-block-element.css +0 -434
  163. package/src/modules/search/components/Editor/ui/code-block-element.tsx +0 -39
  164. package/src/modules/search/components/Editor/ui/code-leaf.tsx +0 -24
  165. package/src/modules/search/components/Editor/ui/code-line-element.tsx +0 -10
  166. package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +0 -21
  167. package/src/modules/search/components/Editor/ui/column-element.tsx +0 -30
  168. package/src/modules/search/components/Editor/ui/column-group-element.tsx +0 -94
  169. package/src/modules/search/components/Editor/ui/command.tsx +0 -75
  170. package/src/modules/search/components/Editor/ui/comment-avatar.tsx +0 -22
  171. package/src/modules/search/components/Editor/ui/comment-create-form.tsx +0 -37
  172. package/src/modules/search/components/Editor/ui/comment-item.tsx +0 -74
  173. package/src/modules/search/components/Editor/ui/comment-leaf.tsx +0 -49
  174. package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +0 -42
  175. package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +0 -22
  176. package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +0 -32
  177. package/src/modules/search/components/Editor/ui/comment-value.tsx +0 -34
  178. package/src/modules/search/components/Editor/ui/comments-popover.tsx +0 -63
  179. package/src/modules/search/components/Editor/ui/date-element.tsx +0 -83
  180. package/src/modules/search/components/Editor/ui/dialog.tsx +0 -63
  181. package/src/modules/search/components/Editor/ui/draggable.tsx +0 -177
  182. package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +0 -180
  183. package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +0 -85
  184. package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +0 -28
  185. package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +0 -76
  186. package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +0 -8
  187. package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +0 -51
  188. package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +0 -77
  189. package/src/modules/search/components/Editor/ui/heading-element.tsx +0 -48
  190. package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +0 -17
  191. package/src/modules/search/components/Editor/ui/hr-element.tsx +0 -30
  192. package/src/modules/search/components/Editor/ui/icons.tsx +0 -267
  193. package/src/modules/search/components/Editor/ui/image-element.tsx +0 -74
  194. package/src/modules/search/components/Editor/ui/inline-combobox.tsx +0 -368
  195. package/src/modules/search/components/Editor/ui/input.tsx +0 -25
  196. package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +0 -218
  197. package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +0 -20
  198. package/src/modules/search/components/Editor/ui/link-element.tsx +0 -29
  199. package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +0 -161
  200. package/src/modules/search/components/Editor/ui/list-element.tsx +0 -30
  201. package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +0 -24
  202. package/src/modules/search/components/Editor/ui/media-embed-element.tsx +0 -133
  203. package/src/modules/search/components/Editor/ui/media-popover.tsx +0 -97
  204. package/src/modules/search/components/Editor/ui/mention-element.tsx +0 -43
  205. package/src/modules/search/components/Editor/ui/mention-input-element.tsx +0 -141
  206. package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +0 -93
  207. package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +0 -67
  208. package/src/modules/search/components/Editor/ui/paragraph-element.tsx +0 -4
  209. package/src/modules/search/components/Editor/ui/placeholder.tsx +0 -52
  210. package/src/modules/search/components/Editor/ui/popover.tsx +0 -32
  211. package/src/modules/search/components/Editor/ui/resizable.tsx +0 -66
  212. package/src/modules/search/components/Editor/ui/separator.tsx +0 -25
  213. package/src/modules/search/components/Editor/ui/style.less +0 -12
  214. package/src/modules/search/components/Editor/ui/table-cell-element.tsx +0 -143
  215. package/src/modules/search/components/Editor/ui/table-element.tsx +0 -243
  216. package/src/modules/search/components/Editor/ui/table-row-element.tsx +0 -22
  217. package/src/modules/search/components/Editor/ui/tableValue.tsx +0 -135
  218. package/src/modules/search/components/Editor/ui/todo-list-element.tsx +0 -43
  219. package/src/modules/search/components/Editor/ui/toggle-element.tsx +0 -31
  220. package/src/modules/search/components/Editor/ui/toolbar.tsx +0 -157
  221. package/src/modules/search/components/Editor/ui/tooltip.tsx +0 -65
  222. package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +0 -160
  223. package/src/modules/search/components/Editor/ui/with-draggables.tsx +0 -175
  224. package/src/modules/search/components/FileList.tsx +0 -287
  225. package/src/modules/search/components/ImageGroupView/index.tsx +0 -85
  226. package/src/modules/search/components/ResultContent.tsx +0 -232
  227. package/src/modules/search/components/SearchInput.tsx +0 -232
  228. package/src/modules/search/components/SearchLanding.tsx +0 -74
  229. package/src/modules/search/components/SearchView.tsx +0 -563
  230. package/src/modules/search/components/SimpleEditor.tsx +0 -158
  231. package/src/modules/search/components/SimpleFileList.tsx +0 -215
  232. package/src/modules/search/index.tsx +0 -10
  233. package/src/modules/search/reademe.md +0 -1
  234. package/src/modules/search/servers/apis.tsx +0 -19
  235. package/src/modules/search/servers/index.ts +0 -184
  236. package/src/modules/search/style.less +0 -503
  237. package/src/modules/search/type.ts +0 -22
  238. package/src/modules/search/utils.ts +0 -34
  239. package/src/modules/sensitive/index.tsx +0 -313
  240. package/src/modules/sensitive/server.ts +0 -122
  241. package/src/modules/streamFilesReader/GientechStreamReader.tsx +0 -1555
  242. package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
  243. package/src/modules/streamFilesReader/components/Header/index.tsx +0 -297
  244. package/src/modules/streamFilesReader/index.tsx +0 -3
  245. package/src/style.css +0 -6
  246. package/src/type.d.ts +0 -0
  247. package/src/utils/commonFn.tsx +0 -111
  248. package/src/utils/gientechCommon/components/AppError.tsx +0 -32
  249. package/src/utils/gientechCommon/components/AppLoading.tsx +0 -75
  250. package/src/utils/gientechCommon/components/DeleteModal.tsx +0 -75
  251. package/src/utils/gientechCommon/components/DisplayError.tsx +0 -33
  252. package/src/utils/gientechCommon/components/DisplayLoading.tsx +0 -38
  253. package/src/utils/gientechCommon/components/FeedBackModal.tsx +0 -310
  254. package/src/utils/gientechCommon/components/FileCardCommon.tsx +0 -82
  255. package/src/utils/gientechCommon/components/FileManager/index.tsx +0 -390
  256. package/src/utils/gientechCommon/components/FileManager/style.css +0 -5
  257. package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +0 -296
  258. package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +0 -339
  259. package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +0 -245
  260. package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +0 -209
  261. package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
  262. package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +0 -148
  263. package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +0 -14
  264. package/src/utils/gientechCommon/components/RenameModal.tsx +0 -86
  265. package/src/utils/gientechCommon/components/style.less +0 -11
  266. package/src/utils/gientechCommon/configs/commonConfig.ts +0 -2
  267. package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
  268. package/src/utils/gientechCommon/configs/stylesConfig.ts +0 -142
  269. package/src/utils/gientechCommon/hooks/AichatUseController.tsx +0 -339
  270. package/src/utils/gientechCommon/slate/converters/deserializers.ts +0 -763
  271. package/src/utils/gientechCommon/slate/converters/mockData.ts +0 -232
  272. package/src/utils/gientechCommon/slate/converters/slateConverters.ts +0 -258
  273. package/src/utils/gientechCommon/slate/richElements/index.tsx +0 -499
  274. package/src/utils/gientechCommon/utils/request.ts +0 -37
  275. package/src/utils/gientechCommon/utils/serverFn.ts +0 -172
  276. package/src/utils/index.tsx +0 -126
  277. package/src/utils/testconfigs/demologin/index.tsx +0 -32
  278. package/src/utils/testconfigs/index.ts +0 -53
  279. package/src/vite-env.d.ts +0 -11
  280. package/stats.html +0 -4949
  281. package/tailwind.config.js +0 -170
  282. package/tsconfig.app.json +0 -30
  283. package/tsconfig.app.tsbuildinfo +0 -11
  284. package/tsconfig.json +0 -13
  285. package/tsconfig.node.json +0 -22
  286. package/tsconfig.node.tsbuildinfo +0 -1
  287. package/vite.config.ts +0 -177
  288. package/workflows/release.yml +0 -60
  289. /package/{dist/assets → assets}/Doris.png +0 -0
  290. /package/{dist/assets → assets}/PostgreSQL.png +0 -0
  291. /package/{dist/assets → assets}/SQLServer.png +0 -0
  292. /package/{dist/assets → assets}/_commonjsHelpers-gnU0ypJ3.js +0 -0
  293. /package/{dist/assets → assets}/circle-alert-g2Y6zAjt.js +0 -0
  294. /package/{dist/assets → assets}/empty.png +0 -0
  295. /package/{dist/assets → assets}/index-CEK88UzR.js +0 -0
  296. /package/{dist/assets → assets}/index-CpW6Dhpp.js +0 -0
  297. /package/{dist/assets → assets}/plus-omCUN0e3.js +0 -0
  298. /package/{dist/assets → assets}/style2.css +0 -0
  299. /package/{dist/assets → assets}/styled-components.browser.esm-DPkS13KC.js +0 -0
  300. /package/{dist/assets → assets}/x-vPcWt3fC.js +0 -0
  301. /package/{dist/chat.d.ts → chat.d.ts} +0 -0
  302. /package/{dist/database.d.ts → database.d.ts} +0 -0
  303. /package/{dist/databaseId.d.ts → databaseId.d.ts} +0 -0
  304. /package/{dist/databaseTable.d.ts → databaseTable.d.ts} +0 -0
  305. /package/{dist/modelManage.d.ts → modelManage.d.ts} +0 -0
  306. /package/{dist/sensitive.d.ts → sensitive.d.ts} +0 -0
  307. /package/{dist/streamFilesReader.d.ts → streamFilesReader.d.ts} +0 -0
  308. /package/{dist/vite.svg → vite.svg} +0 -0
@@ -1,734 +0,0 @@
1
- import React, { useMemo, useState, useEffect, useRef } from 'react';
2
- import { message, Modal } from 'antd';
3
- import { uid } from 'uid';
4
- import { TriangleAlert, Upload } from 'lucide-react';
5
- import { DashboardContainer, Styles } from '@mxmweb/zui';
6
- import { Xviwer, CustomComponents } from '@mxmweb/xviewer';
7
-
8
- import '@mxmweb/zui/style.css';
9
- import UploadDrawer from './UploadDrawer';
10
- import EditConfigDrawer from './EditConfig';
11
-
12
- import AxiosInstance from './server';
13
- import {
14
- StatusComponent,
15
- TableMetaDescriptionCom,
16
- statusArr,
17
- EmptyData,
18
- OPT_BTN,
19
- DescStatus,
20
- } from './CustomCom';
21
- const { confirm } = Modal;
22
-
23
- interface DatabaseViewAdopterProps {
24
- url?: string;
25
- token?: string;
26
- role?: string;
27
- id: string;
28
- styles?: Styles;
29
- dbType: 'DataTable' | 'DirectDB';
30
- CustomComponents?: CustomComponents;
31
- eventsEmit?: (name: string, data: any) => void;
32
- getBtnDisabled?: (type: OPT_BTN, permission: number) => boolean;
33
- }
34
-
35
- const DatabaseViewAdopter: React.FC<DatabaseViewAdopterProps> = props => {
36
- const { url, token, role, id, dbType, CustomComponents, getBtnDisabled } = props;
37
-
38
- const [status, setStatus] = useState<any>({
39
- container: 'ready',
40
- content: 'ready',
41
- });
42
- // 创建ref来访问核心组件实例
43
- const coreRef = useRef<any>(null);
44
- // 轮询定时器引用,避免重复定时与内存泄漏
45
- const pollTimerRef = useRef<any>(null);
46
- //表数据
47
- const [tableData, setTableData] = useState<
48
- {
49
- id: string;
50
- data?: any[];
51
- children?: {
52
- [key: string]: {
53
- id: string;
54
- data?: any[];
55
- }[];
56
- };
57
- expanded?: boolean;
58
- }[]
59
- >();
60
-
61
- // 管理子table的pending状态,用于动画
62
- const [subTablePendingIds, setSubTablePendingIds] = useState<{ [viewKey: string]: string[] }>({});
63
-
64
- // 数据库信息
65
- const [dbInfo, setDBInfo] = useState<any>();
66
-
67
- // 抽屉状态管理
68
- const [drawerVisible, setDrawerVisible] = useState(false);
69
- const [drawerTitle, setDrawerTitle] = useState('');
70
- const [tableInfo, setTableInfo] = useState<any>();
71
-
72
- // 修改数据配置
73
- const [configDrawerVisible, setConfigDrawerVisible] = useState(false);
74
- const [configDrawerTitle, setConfigDrawerTitle] = useState('');
75
-
76
- const {
77
- getTableList,
78
- delTableById,
79
- delFileById,
80
- updateTableInfo,
81
- optimizeDesc,
82
- getTableTreeList,
83
- reParseFile,
84
- getDBDetailById,
85
- } = AxiosInstance({
86
- url,
87
- token,
88
- role,
89
- eventsEmit: props.eventsEmit,
90
- });
91
-
92
- // 模拟应用初始化过程
93
- useEffect(() => {
94
- if (id && dbType) {
95
- setStatus((prev: any) => ({ ...prev, container: 'loading' }));
96
- getDatabaseDetail();
97
- }
98
- return () => {
99
- if (pollTimerRef.current) {
100
- clearTimeout(pollTimerRef.current);
101
- pollTimerRef.current = null;
102
- }
103
- };
104
- }, [id, dbType]);
105
-
106
- const getDatabaseDetail = async () => {
107
- try {
108
- const res = await getDBDetailById(id, dbType);
109
- if (res) {
110
- setDBInfo(res);
111
- setStatus((prev: any) => ({ ...prev, container: 'ready', content: 'loading' }));
112
- }
113
- } catch (e) {
114
- console.log('[TableApiError] getDBInfo:', e);
115
- }
116
- // 获取详情后开始轮询拉取列表
117
- await pollFetchList();
118
- };
119
-
120
- const handleFetchList = async (): Promise<any[] | undefined> => {
121
- try {
122
- if (dbType == 'DirectDB') {
123
- const res = await getTableList(id);
124
- if (res) {
125
- const _data = generateDirectDBDatas(res);
126
- setTableData(_data || []);
127
- setStatus((prev: any) => ({ ...prev, content: 'ready' }));
128
- return _data || [];
129
- } else {
130
- setStatus((prev: any) => ({ ...prev, content: 'error' }));
131
- }
132
- } else {
133
- const res = await getTableTreeList(id);
134
- if (res) {
135
- const _data = generateDataTableDatas(res);
136
- setTableData(_data || []);
137
- setStatus((prev: any) => ({ ...prev, content: 'ready' }));
138
- return _data || [];
139
- } else {
140
- setStatus((prev: any) => ({ ...prev, content: 'error' }));
141
- }
142
- }
143
- } catch (e) {
144
- console.log('[TableApiError] getTableList:', e);
145
- }
146
- return undefined;
147
- };
148
-
149
- // 处理 上传数据库类型 的 表list数据
150
- function generateDataTableDatas(data: any[]) {
151
- return (data || []).map((_t, i) => {
152
- let status = statusArr.find((s: any) => s.status == _t.status);
153
-
154
- const importStatus = _t.children.some((c: any) => c.status == '00'); // 子列表于一个导入失败,父表显示追加失败
155
-
156
- return {
157
- id: _t.fileId.toString(),
158
- tableId: _t.tableId,
159
- data: [
160
- { columnId: 'name', value: _t?.originalFilename || '-', type: 'label' },
161
- {
162
- columnId: 'description',
163
- value: _t?.tableMeta?.description,
164
- type: 'customized',
165
- tableMeta: _t?.tableMeta,
166
- },
167
- { columnId: 'count', value: `${_t.rowCount}行,${_t.columnCount}列`, type: 'text' },
168
- { columnId: 'status', ...status, type: 'customized', errorMsg: _t.errorMsg },
169
- { columnId: 'importstatus', value: importStatus, type: 'customized' },
170
- {
171
- columnId: 'createdAt',
172
- value: _t.gmtCreate,
173
- type: 'date',
174
- },
175
- {
176
- columnId: 'updatedAt',
177
- value: _t.gmtModified,
178
- type: 'date',
179
- },
180
- ...(_t.status == '30'
181
- ? [
182
- {
183
- columnId: 'actions',
184
- value: 'view',
185
- label: '查看',
186
- type: 'action',
187
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.VIEW, _t.permission),
188
- },
189
- {
190
- columnId: 'actions',
191
- value: 'edit',
192
- label: '修改配置',
193
- type: 'action',
194
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.EDIT, _t.permission),
195
- },
196
- {
197
- columnId: 'actions',
198
- value: 'addData',
199
- label: '追加数据',
200
- type: 'action',
201
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.EDIT, _t.permission),
202
- },
203
- ]
204
- : []),
205
- ...(_t.status == '00'
206
- ? [
207
- {
208
- columnId: 'actions',
209
- value: 'reValidate',
210
- label: '重新导入',
211
- type: 'action',
212
- },
213
- ]
214
- : []),
215
- {
216
- columnId: 'actions',
217
- value: 'delete',
218
- label: '删除',
219
- type: 'action',
220
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.DELETE, _t.permission),
221
- },
222
- ],
223
- expanded: false,
224
- ...(_t.children &&
225
- _t.children?.length > 0 && {
226
- children: [
227
- ...(_t.children || []).map((_c: any) => {
228
- const c_status = statusArr.find((s: any) => s.status == _c.status);
229
-
230
- const data = [
231
- { columnId: 'name', value: _c.originalFilename, type: 'text' },
232
- {
233
- columnId: 'count',
234
- value: `${_c.rowCount}行,${_c.columnCount}列`,
235
- type: 'text',
236
- },
237
- {
238
- columnId: 'status',
239
- ...c_status,
240
-
241
- errorMsg: _c.errorMsg,
242
- type: 'customized',
243
- },
244
- {
245
- columnId: 'createdAt',
246
- value: _c.gmtCreate,
247
- type: 'date',
248
- },
249
- {
250
- columnId: 'updatedAt',
251
- value: _c.gmtModified,
252
- type: 'date',
253
- },
254
- ...(_c.status == '30'
255
- ? [
256
- {
257
- columnId: 'actions',
258
- value: 'view',
259
- label: '查看',
260
- type: 'action',
261
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.VIEW, _c.permission),
262
- },
263
- ]
264
- : []),
265
- ...(_c.status == '00'
266
- ? [
267
- {
268
- columnId: 'actions',
269
- value: 'reValidate',
270
- label: '重新导入',
271
- type: 'action',
272
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.ADD, _c.permission),
273
- },
274
- ]
275
- : []),
276
- {
277
- columnId: 'actions',
278
- value: 'delete_sub',
279
- label: '删除',
280
- type: 'action',
281
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.DELETE, _c.permission),
282
- },
283
- ];
284
- return {
285
- id: _c.fileId.toString(),
286
- tableId: _c.tableId,
287
- data: data,
288
- };
289
- }),
290
- ],
291
- }),
292
- };
293
- });
294
- }
295
-
296
- // 处理 直连数据库类型 的 表list数据
297
- function generateDirectDBDatas(data: any[]) {
298
- return (data || []).map((_t, i) => {
299
- return {
300
- id: _t.id || uid(8),
301
- data: [
302
- { columnId: 'name', value: _t.physicalName },
303
- {
304
- columnId: 'cnname',
305
- value: _t.businessName,
306
- },
307
- { columnId: 'colcount', value: _t.columnCount },
308
-
309
- { columnId: 'count', value: `${_t.rowCount}行,${_t.columnCount}列` },
310
- {
311
- columnId: 'actions',
312
- value: 'view',
313
- label: '查看',
314
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.VIEW, _t.permission),
315
- },
316
- ],
317
- };
318
- });
319
- }
320
-
321
- // 事件分流函数,先处理核心层UI/动画,再决定是否向上透传
322
- async function handleEventsEmit(name: string, data: any, appFn: any) {
323
- console.log('[adopter] mergedEventsEmit', name, data, appFn);
324
- // 1. 先处理核心层UI/动画/数据
325
- switch (name) {
326
- case 'table_action_delete': {
327
- try {
328
- confirm({
329
- title: '确认删除数据库?',
330
- content: '该数据表及其追加数据都将被删除且无法恢复',
331
- icon: <TriangleAlert color="#FF4D4F" className="mr-[8px]" />,
332
- okText: '删除',
333
- cancelText: '取消',
334
- async onOk() {
335
- const res = await delTableById(data.tableId, dbType);
336
- if (res && coreRef?.current) {
337
- coreRef?.current.appFn.removeItem(data.id);
338
- message.success(`删除成功`);
339
- }
340
- },
341
- });
342
- } catch (e) {
343
- console.log('删除表数据失败');
344
- }
345
- break;
346
- }
347
- case 'table_action_edit': {
348
- setConfigDrawerTitle('修改数据配置');
349
- setConfigDrawerVisible(true);
350
- setTableInfo(data);
351
- break;
352
- }
353
- //上传
354
- case 'toolbar_upload': {
355
- setDrawerTitle('上传数据文件');
356
- setDrawerVisible(true);
357
- break;
358
- }
359
- //追加
360
- case 'table_action_addData': {
361
- setDrawerTitle('追加数据');
362
- setDrawerVisible(true);
363
- setTableInfo(data);
364
- break;
365
- }
366
-
367
- //重新导入
368
- case 'table_action_reValidate': {
369
- const res = await reParseFile(data.id);
370
- if (res) {
371
- if (pollTimerRef.current) {
372
- clearTimeout(pollTimerRef.current);
373
- pollTimerRef.current = null;
374
- }
375
- await pollFetchList();
376
- }
377
- break;
378
- }
379
-
380
- //修改表配置
381
- case 'table_info:update': {
382
- try {
383
- if (tableInfo?.id) {
384
- const tbTitle = tableInfo?.data.find((d: any) => d.columnId == 'name').value || '-';
385
- const res = await updateTableInfo({
386
- tableId: tableInfo.tableId,
387
- description: data,
388
- businessName: tbTitle,
389
- });
390
- if (res && coreRef?.current) {
391
- const patch = {
392
- ...tableInfo,
393
- data: tableInfo.data.map((d: any) => {
394
- if (d.columnId == 'description') {
395
- return {
396
- ...d,
397
- value: data,
398
- };
399
- } else {
400
- return d;
401
- }
402
- }),
403
- };
404
- coreRef?.current.appFn.updateItem(patch, tableInfo.id);
405
- message.success('修改配置成功');
406
- }
407
- }
408
- } catch (e) {
409
- console.error('修改配置失败', e);
410
- } finally {
411
- handleDrawerClose();
412
- }
413
- break;
414
- }
415
-
416
- //子表删除
417
- case 'table_action_delete_sub': {
418
- try {
419
- confirm({
420
- title: '确认删除数据?',
421
- content: '删除后,该数据将无法恢复',
422
- okText: '删除',
423
- cancelText: '取消',
424
- async onOk() {
425
- const { id, tableId } = data;
426
-
427
- const res = await delFileById(data.id);
428
- if (res && coreRef?.current) {
429
- setSubTablePendingIds(prev => ({
430
- ...prev,
431
- [tableId]: [...(prev[tableId] || []), id],
432
- }));
433
- if (data.data.find((d: any) => d.status == '00')) {
434
- // 如果子表有导入失败的,删除之后刷新
435
- if (pollTimerRef.current) {
436
- clearTimeout(pollTimerRef.current);
437
- pollTimerRef.current = null;
438
- }
439
- pollFetchList();
440
- }
441
- appFn.removeItem(id, tableId);
442
-
443
- message.success('追加文件数据删除成功');
444
- }
445
- },
446
- });
447
- } catch (e) {
448
- console.log('删除表数据失败');
449
- }
450
- break;
451
- }
452
-
453
- case 'toolbar_auth': {
454
- if (typeof props.eventsEmit === 'function') {
455
- // 兼容只传2个参数的业务层eventsEmit
456
-
457
- props.eventsEmit('toolbar_auth', dbInfo);
458
- }
459
- break;
460
- }
461
-
462
- default:
463
- // 2. 透传到业务层(如有需要)
464
- if (typeof props.eventsEmit === 'function') {
465
- // 兼容只传2个参数的业务层eventsEmit
466
-
467
- props.eventsEmit(name, data);
468
- }
469
- break;
470
- }
471
- }
472
- // 根据数据库类型动态生成views配置
473
- const directDBViewConfig = useMemo(
474
- () => ({
475
- label: '数据表管理',
476
- model: null,
477
- defaultActiveId: 'direct-table-view',
478
- views: [
479
- {
480
- label: '我的数据库',
481
- id: 'direct-table-view',
482
- type: 'table' as const,
483
- viewBehavior: 'pagination' as const, //or pagination
484
- allowMultiSelect: false,
485
- columns: [
486
- { id: 'name', title: '数据表英文名称', type: 'label' },
487
- { id: 'cnname', title: '数据表中文名称', type: 'label' },
488
- { id: 'colcount', title: '字段数', type: 'text' },
489
- { id: 'count', title: '数据量', type: 'text' },
490
- { id: 'actions', title: '操作', type: 'action' },
491
- ],
492
-
493
- toolbar: [
494
- {
495
- type: 'fuzzy_search' as const,
496
- key: 'search',
497
- label: '搜索',
498
- searchKeys: ['name', 'description'],
499
- position: 'right',
500
- },
501
- {
502
- type: 'button',
503
- key: 'auth',
504
- label: '配置',
505
- btnType: 'default' as const,
506
- position: 'right',
507
- },
508
- ],
509
- },
510
- ],
511
- }),
512
- [tableData, dbType]
513
- );
514
-
515
- const dataTableViewConfig = useMemo(
516
- () => ({
517
- label: '数据表管理',
518
- model: null,
519
- defaultActiveId: 'data-table-view',
520
- views: [
521
- {
522
- label: '上传数据列表',
523
- id: 'data-table-view',
524
- type: 'table' as const,
525
- viewBehavior: 'pagination' as const, //or pagination
526
- allowMultiSelect: false,
527
- viewPageSize: 10,
528
- columns: [
529
- { id: 'name', title: '文件名', type: 'label', tip: '文件名' },
530
- {
531
- id: 'description',
532
- title: '描述',
533
- type: 'customized',
534
- component: <TableMetaDescriptionCom />,
535
- helpText:
536
- '打开自动生成描述开关后,若描述未正常生成,则描述内容为空,如您仍然需要描述,则需要手动添加',
537
- },
538
- { id: 'count', title: '数据量', type: 'text', tip: '数据量' },
539
- {
540
- id: 'status',
541
- title: '导入状态',
542
- type: 'customized',
543
- component: <StatusComponent />,
544
- },
545
- {
546
- id: 'importstatus',
547
- title: '追加提示',
548
- type: 'customized',
549
- component: <StatusComponent />,
550
- },
551
- { id: 'createdAt', title: '创建时间', type: 'date', tip: '创建时间' },
552
- { id: 'updatedAt', title: '更新时间', type: 'date', tip: '更新时间' },
553
- { id: 'actions', title: '操作', type: 'action' },
554
- ],
555
-
556
- toolbar: [
557
- {
558
- type: 'button' as const,
559
- key: 'upload',
560
- label: '上传数据文件',
561
- btnType: 'primary' as const,
562
- disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.ADD, dbInfo?.permission),
563
- icon: <Upload size={12} />,
564
- },
565
- {
566
- type: 'fuzzy_search' as const,
567
- key: 'search',
568
- label: '搜索',
569
- searchKeys: ['name', 'description', ['name']],
570
- position: 'right',
571
- },
572
- {
573
- type: 'button',
574
- key: 'auth',
575
- label: '配置',
576
- btnType: 'default' as const,
577
- position: 'right',
578
- },
579
- ],
580
- },
581
- ],
582
- subTableConfig: {
583
- type: 'table' as const,
584
- allowMultiSelect: false,
585
- viewBehavior: 'pagination' as const, //or pagination
586
- viewPageSize: 5,
587
- columns: [
588
- { title: '追加文件名', id: 'name', type: 'text', tip: '追加文件名' },
589
- { title: '数据量', id: 'count', type: 'text', tip: '数据量' },
590
- {
591
- id: 'status',
592
- title: '导入状态',
593
- type: 'customized',
594
- tip: '导入状态',
595
- component: <StatusComponent />,
596
- },
597
- { title: '创建时间', id: 'createdAt', type: 'date', tip: '创建时间' },
598
- { title: '更改时间', id: 'updatedAt', type: 'date', tip: '更改时间' },
599
- { title: '操作', id: 'actions', type: 'action' },
600
- ],
601
- },
602
- // 传递子table的pending状态
603
- subTablePendingIds: subTablePendingIds,
604
- // 子table动画完成回调
605
- onSubTableRowAnimationComplete: (viewKey: string, rowId: string) => {
606
- // 清除pending状态
607
- setSubTablePendingIds(prev => ({
608
- ...prev,
609
- [viewKey]: (prev[viewKey] || []).filter(id => id !== rowId),
610
- }));
611
- },
612
- }),
613
- [subTablePendingIds, tableData, dbType, dbInfo]
614
- );
615
-
616
- // 抽屉相关处理函数
617
- const handleDrawerClose = (type?: 'refresh') => {
618
- setDrawerVisible(false);
619
- setConfigDrawerVisible(false);
620
- setTableInfo(undefined);
621
- if (type == 'refresh') {
622
- // 关闭抽屉后静默轮询刷新列表
623
- if (pollTimerRef.current) {
624
- clearTimeout(pollTimerRef.current);
625
- pollTimerRef.current = null;
626
- }
627
- pollFetchList();
628
- }
629
- };
630
-
631
- // 检查所有数据及其 children 的 status 是否都不是 '11' 或 '20'
632
- function isAllFinished(data: any[]): boolean {
633
- if (!Array.isArray(data)) return true;
634
-
635
- for (const item of data) {
636
- if (item.data) {
637
- const statusCell = item.data.find((d: any) => d.columnId === 'status');
638
- const descCell = item.data.find((d: any) => d.columnId === 'description');
639
- // 导入中 20,导入中未建表 11,自动生成描述生成中,这三个状态时,轮询
640
- if (
641
- statusCell &&
642
- (statusCell.status === '20' ||
643
- statusCell.status === '11' ||
644
- descCell?.tableMeta?.generateDescriptionStatus == DescStatus.GENERATING)
645
- ) {
646
- return false;
647
- }
648
- }
649
- if (Array.isArray(item.children)) {
650
- for (const child of item.children) {
651
- if (child.data) {
652
- const statusCell = child.data.find((d: any) => d.columnId === 'status');
653
- // 子表无需生成描述
654
- if (statusCell && (statusCell.status === '20' || statusCell.status === '11')) {
655
- return false;
656
- }
657
- }
658
- }
659
- }
660
- }
661
- return true;
662
- }
663
-
664
- // 轮询 handleFetchList,直到所有 status 完成
665
- const pollFetchList = async () => {
666
- const latest = await handleFetchList();
667
- const finished = isAllFinished(latest || []);
668
- if (!finished) {
669
- if (pollTimerRef.current) {
670
- clearTimeout(pollTimerRef.current);
671
- pollTimerRef.current = null;
672
- }
673
- pollTimerRef.current = setTimeout(() => {
674
- pollFetchList();
675
- }, 5000);
676
- } else {
677
- if (pollTimerRef.current) {
678
- clearTimeout(pollTimerRef.current);
679
- pollTimerRef.current = null;
680
- }
681
- }
682
- };
683
-
684
- return (
685
- <DashboardContainer
686
- title={dbInfo?.name}
687
- description={dbInfo?.description || '-'}
688
- goBack={() => {
689
- props.eventsEmit?.('goBack', {});
690
- }}
691
- >
692
- <Xviwer
693
- dataSource={tableData}
694
- ref={coreRef}
695
- eventsEmit={handleEventsEmit}
696
- status={status}
697
- CustomComponents={{
698
- EmptyData: () => (
699
- <EmptyData
700
- dbInfo={dbInfo}
701
- setDrawerTitle={setDrawerTitle}
702
- setDrawerVisible={setDrawerVisible}
703
- getBtnDisabled={getBtnDisabled}
704
- />
705
- ),
706
-
707
- ...CustomComponents,
708
- }}
709
- {...(dbType == 'DataTable' ? dataTableViewConfig : directDBViewConfig)}
710
- />
711
- {/* 右侧抽屉 - 添加数据库连接 */}
712
- <UploadDrawer
713
- drawerTitle={drawerTitle}
714
- drawerVisible={drawerVisible}
715
- handleDrawerClose={handleDrawerClose}
716
- dbId={id}
717
- token={token}
718
- url={url}
719
- role={role}
720
- tableInfo={tableInfo}
721
- />
722
- <EditConfigDrawer
723
- drawerTitle={configDrawerTitle}
724
- drawerVisible={configDrawerVisible}
725
- handleDrawerClose={handleDrawerClose}
726
- tableInfo={tableInfo}
727
- optimizeDesc={optimizeDesc}
728
- eventsEmit={handleEventsEmit}
729
- />
730
- </DashboardContainer>
731
- );
732
- };
733
-
734
- export default DatabaseViewAdopter;