@gientech/modual 1.3.2 → 1.3.3

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 (309) hide show
  1. package/.editorconfig +38 -0
  2. package/.prettierignore +16 -0
  3. package/.prettierrc +17 -0
  4. package/README.md +129 -129
  5. package/USAGE.md +191 -0
  6. package/bash.exe.stackdump +40 -0
  7. package/components.json +21 -0
  8. package/dist/README.md +129 -0
  9. package/{assets → dist/assets}/database.svg +11 -11
  10. package/{assets → dist/assets}/database_add.svg +53 -53
  11. package/{assets → dist/assets}/database_connect.svg +66 -66
  12. package/{assets → dist/assets}/database_upload.svg +29 -29
  13. package/{assets → dist/assets}/defaultWeLogo.svg +14 -14
  14. package/{assets/index-ldqIbm0x.js → dist/assets/index-XvC_4jDB.js} +106 -101
  15. package/{assets/index-D-dGaGjW.js → dist/assets/index-mPgEc8KC.js} +288 -102
  16. package/{assets/MySQL.svg → dist/assets/mysql.svg} +14 -14
  17. package/dist/assets/style.css +1 -0
  18. package/dist/assets/style3.css +1 -0
  19. package/{chat.js → dist/chat.js} +78 -78
  20. package/dist/database.js +20 -0
  21. package/{databaseId.js → dist/databaseId.js} +1 -1
  22. package/{databaseTable.js → dist/databaseTable.js} +1 -1
  23. package/{modelManage.js → dist/modelManage.js} +1 -1
  24. package/dist/package.json +56 -0
  25. package/{sensitive.js → dist/sensitive.js} +1 -1
  26. package/{streamFilesReader.js → dist/streamFilesReader.js} +11 -11
  27. package/{worker → dist/worker}/pdf.worker.min.js +21 -21
  28. package/doc_assets/2.png +0 -0
  29. package/doc_assets/demo.md +27 -0
  30. package/doc_assets/demos/dist-app/assets/index.Dh-ZAS9Z.css +2 -0
  31. package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js +23699 -0
  32. package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js.map +1 -0
  33. package/doc_assets/demos/dist-app/index.html +14 -0
  34. package/doc_assets/demos/dist-app/vite.svg +1 -0
  35. package/doc_assets/images/1.png +0 -0
  36. package/doc_assets/images/3.png +0 -0
  37. package/doc_assets/images/component-screenshot.png +1 -0
  38. package/doc_assets/install.md +5 -0
  39. package/eslint.config.js +92 -0
  40. package/index.html +13 -0
  41. package/package.json +83 -39
  42. package/postcss.config.cjs +19 -0
  43. package/public/vite.svg +1 -0
  44. package/public/worker/pdf.worker.min.js +22 -0
  45. package/scripts/README.md +133 -0
  46. package/scripts/build-demo.js +88 -0
  47. package/scripts/demo-selector.js +216 -0
  48. package/scripts/dev-demo.js +76 -0
  49. package/scripts/preview-demo.js +130 -0
  50. package/scripts/run-demo.bat +34 -0
  51. package/src/assets/img/downArrow.png +0 -0
  52. package/src/assets/img/excel.png +0 -0
  53. package/src/assets/img/img.png +0 -0
  54. package/src/assets/img/pdf.png +0 -0
  55. package/src/assets/img/ppt.png +0 -0
  56. package/src/assets/img/txt.png +0 -0
  57. package/src/assets/img/word.png +0 -0
  58. package/src/assets/login/homeBg.png +0 -0
  59. package/src/assets/login/left.jpg +0 -0
  60. package/src/assets/login/logoImg.png +0 -0
  61. package/src/examples/LoginPage/index.tsx +18 -0
  62. package/src/examples/aaa/index.tsx +3758 -0
  63. package/src/examples/chat/components/DrawerGraphPreview.tsx +78 -0
  64. package/src/examples/chat/index.tsx +190 -0
  65. package/src/examples/gientechStreamFilesReader/index.tsx +1016 -0
  66. package/src/examples/ragDatabaseDataPage/index.tsx +36 -0
  67. package/src/examples/ragDatabaseIdPage/index.tsx +44 -0
  68. package/src/examples/ragDatabasePage/index.tsx +36 -0
  69. package/src/examples/ragModelManagePage/index.tsx +37 -0
  70. package/src/examples/ragSearchPage/index.tsx +0 -0
  71. package/src/examples/ragSensitiveWordsPage/index.tsx +32 -0
  72. package/src/examples/streamFiles/index.tsx +384 -0
  73. package/src/lib_enter.ts +38 -0
  74. package/src/main.tsx +5 -0
  75. package/src/main.tsx.backup +5 -0
  76. package/src/modules/chat/Conversations/Item.tsx +167 -0
  77. package/src/modules/chat/Conversations/List.tsx +143 -0
  78. package/src/modules/chat/Conversations/groupByTime.ts +39 -0
  79. package/src/modules/chat/Conversations/index.tsx +212 -0
  80. package/src/modules/chat/constants.tsx +33 -0
  81. package/src/modules/chat/data.txt +82 -0
  82. package/src/modules/chat/index.tsx +1908 -0
  83. package/src/modules/chat/types.ts +17 -0
  84. package/src/modules/database/CreateModal.tsx +398 -0
  85. package/src/modules/database/assets/Doris.png +0 -0
  86. package/src/modules/database/assets/PostgreSQL.png +0 -0
  87. package/src/modules/database/assets/SQLServer.png +0 -0
  88. package/src/modules/database/assets/database.svg +11 -0
  89. package/src/modules/database/assets/database_add.svg +53 -0
  90. package/src/modules/database/assets/database_connect.svg +66 -0
  91. package/src/modules/database/assets/database_upload.svg +29 -0
  92. package/src/modules/database/assets/empty.png +0 -0
  93. package/src/modules/database/assets/mysql.svg +14 -0
  94. package/src/modules/database/index.tsx +466 -0
  95. package/src/modules/database/server.ts +196 -0
  96. package/src/modules/databaseId/CustomCom.tsx +156 -0
  97. package/src/modules/databaseId/EditConfig.tsx +268 -0
  98. package/src/modules/databaseId/UploadDrawer.tsx +520 -0
  99. package/src/modules/databaseId/assets/aiOptimize.svg +10 -0
  100. package/src/modules/databaseId/assets/empty.png +0 -0
  101. package/src/modules/databaseId/assets/template.svg +6 -0
  102. package/src/modules/databaseId/assets/upload.svg +9 -0
  103. package/src/modules/databaseId/assets/useTemp.svg +6 -0
  104. package/src/modules/databaseId/index.tsx +734 -0
  105. package/src/modules/databaseId/server.ts +286 -0
  106. package/src/modules/databaseId/style.css +5 -0
  107. package/src/modules/databaseTable/EditRowDrawer.tsx +119 -0
  108. package/src/modules/databaseTable/index.tsx +357 -0
  109. package/src/modules/databaseTable/server.ts +180 -0
  110. package/src/modules/headlessChat/constants.tsx +32 -0
  111. package/src/modules/headlessChat/index.tsx +1065 -0
  112. package/src/modules/headlessChat/types.ts +23 -0
  113. package/src/modules/login/components/Login/LoginBox/index.tsx +102 -0
  114. package/src/modules/login/components/Login/RegisterBox/index.tsx +180 -0
  115. package/src/modules/login/components/Login/index.tsx +100 -0
  116. package/src/modules/login/index.tsx +106 -0
  117. package/src/modules/login/style.css +3 -0
  118. package/src/modules/login/useServices.ts +53 -0
  119. package/src/modules/login/utils.ts +42 -0
  120. package/src/modules/modelManage/ConfigDrawer.tsx +249 -0
  121. package/src/modules/modelManage/assets/empty.png +0 -0
  122. package/src/modules/modelManage/const.ts +50 -0
  123. package/src/modules/modelManage/index.tsx +439 -0
  124. package/src/modules/modelManage/server.ts +185 -0
  125. package/src/modules/nodegraph/index.tsx +1 -0
  126. package/src/modules/search/assets/Icon-history.svg +8 -0
  127. package/src/modules/search/assets/answerAwartar.png +0 -0
  128. package/src/modules/search/assets/doc.png +0 -0
  129. package/src/modules/search/assets/genera.gif +0 -0
  130. package/src/modules/search/assets/icon-robot.svg +9 -0
  131. package/src/modules/search/assets/icon-search-bar.svg +14 -0
  132. package/src/modules/search/assets/icon-sub-title.svg +3 -0
  133. package/src/modules/search/assets/icon-title.svg +9 -0
  134. package/src/modules/search/assets/icon-zoomOut.svg +9 -0
  135. package/src/modules/search/assets/iconAi.svg +9 -0
  136. package/src/modules/search/assets/pdf.png +0 -0
  137. package/src/modules/search/assets/ppt.png +0 -0
  138. package/src/modules/search/assets/search.svg +3 -0
  139. package/src/modules/search/assets/selected.svg +4 -0
  140. package/src/modules/search/assets/txt.png +0 -0
  141. package/src/modules/search/assets/xls.png +0 -0
  142. package/src/modules/search/components/AssisSelect.tsx +137 -0
  143. package/src/modules/search/components/Editor/ChatViewEditor.tsx +261 -0
  144. package/src/modules/search/components/Editor/aichat.css +1 -0
  145. package/src/modules/search/components/Editor/constant.ts +13 -0
  146. package/src/modules/search/components/Editor/index.tsx +113 -0
  147. package/src/modules/search/components/Editor/plugins/autofomatRules.ts +332 -0
  148. package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +20 -0
  149. package/src/modules/search/components/Editor/plugins/createIndexes.tsx +38 -0
  150. package/src/modules/search/components/Editor/plugins/displayer.ts +298 -0
  151. package/src/modules/search/components/Editor/plugins/imageClick.tsx +32 -0
  152. package/src/modules/search/components/Editor/plugins/myplugin.tsx +98 -0
  153. package/src/modules/search/components/Editor/ui/avatar.tsx +19 -0
  154. package/src/modules/search/components/Editor/ui/blockquote-element.tsx +21 -0
  155. package/src/modules/search/components/Editor/ui/button.tsx +58 -0
  156. package/src/modules/search/components/Editor/ui/calendar.tsx +68 -0
  157. package/src/modules/search/components/Editor/ui/caption.tsx +46 -0
  158. package/src/modules/search/components/Editor/ui/checkbox.tsx +27 -0
  159. package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +188 -0
  160. package/src/modules/search/components/Editor/ui/code-block-element.css +434 -0
  161. package/src/modules/search/components/Editor/ui/code-block-element.tsx +39 -0
  162. package/src/modules/search/components/Editor/ui/code-leaf.tsx +24 -0
  163. package/src/modules/search/components/Editor/ui/code-line-element.tsx +10 -0
  164. package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +21 -0
  165. package/src/modules/search/components/Editor/ui/column-element.tsx +30 -0
  166. package/src/modules/search/components/Editor/ui/column-group-element.tsx +94 -0
  167. package/src/modules/search/components/Editor/ui/command.tsx +75 -0
  168. package/src/modules/search/components/Editor/ui/comment-avatar.tsx +22 -0
  169. package/src/modules/search/components/Editor/ui/comment-create-form.tsx +37 -0
  170. package/src/modules/search/components/Editor/ui/comment-item.tsx +74 -0
  171. package/src/modules/search/components/Editor/ui/comment-leaf.tsx +49 -0
  172. package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +42 -0
  173. package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +22 -0
  174. package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +32 -0
  175. package/src/modules/search/components/Editor/ui/comment-value.tsx +34 -0
  176. package/src/modules/search/components/Editor/ui/comments-popover.tsx +63 -0
  177. package/src/modules/search/components/Editor/ui/date-element.tsx +83 -0
  178. package/src/modules/search/components/Editor/ui/dialog.tsx +63 -0
  179. package/src/modules/search/components/Editor/ui/draggable.tsx +177 -0
  180. package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +180 -0
  181. package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +85 -0
  182. package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +28 -0
  183. package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +76 -0
  184. package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +8 -0
  185. package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +51 -0
  186. package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +77 -0
  187. package/src/modules/search/components/Editor/ui/heading-element.tsx +48 -0
  188. package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +17 -0
  189. package/src/modules/search/components/Editor/ui/hr-element.tsx +30 -0
  190. package/src/modules/search/components/Editor/ui/icons.tsx +267 -0
  191. package/src/modules/search/components/Editor/ui/image-element.tsx +74 -0
  192. package/src/modules/search/components/Editor/ui/inline-combobox.tsx +368 -0
  193. package/src/modules/search/components/Editor/ui/input.tsx +25 -0
  194. package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +218 -0
  195. package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +20 -0
  196. package/src/modules/search/components/Editor/ui/link-element.tsx +29 -0
  197. package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +161 -0
  198. package/src/modules/search/components/Editor/ui/list-element.tsx +30 -0
  199. package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +24 -0
  200. package/src/modules/search/components/Editor/ui/media-embed-element.tsx +133 -0
  201. package/src/modules/search/components/Editor/ui/media-popover.tsx +97 -0
  202. package/src/modules/search/components/Editor/ui/mention-element.tsx +43 -0
  203. package/src/modules/search/components/Editor/ui/mention-input-element.tsx +141 -0
  204. package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +93 -0
  205. package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +67 -0
  206. package/src/modules/search/components/Editor/ui/paragraph-element.tsx +4 -0
  207. package/src/modules/search/components/Editor/ui/placeholder.tsx +52 -0
  208. package/src/modules/search/components/Editor/ui/popover.tsx +32 -0
  209. package/src/modules/search/components/Editor/ui/resizable.tsx +66 -0
  210. package/src/modules/search/components/Editor/ui/separator.tsx +25 -0
  211. package/src/modules/search/components/Editor/ui/style.less +12 -0
  212. package/src/modules/search/components/Editor/ui/table-cell-element.tsx +143 -0
  213. package/src/modules/search/components/Editor/ui/table-element.tsx +243 -0
  214. package/src/modules/search/components/Editor/ui/table-row-element.tsx +22 -0
  215. package/src/modules/search/components/Editor/ui/tableValue.tsx +135 -0
  216. package/src/modules/search/components/Editor/ui/todo-list-element.tsx +43 -0
  217. package/src/modules/search/components/Editor/ui/toggle-element.tsx +31 -0
  218. package/src/modules/search/components/Editor/ui/toolbar.tsx +157 -0
  219. package/src/modules/search/components/Editor/ui/tooltip.tsx +65 -0
  220. package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +160 -0
  221. package/src/modules/search/components/Editor/ui/with-draggables.tsx +175 -0
  222. package/src/modules/search/components/FileList.tsx +287 -0
  223. package/src/modules/search/components/ImageGroupView/index.tsx +85 -0
  224. package/src/modules/search/components/ResultContent.tsx +232 -0
  225. package/src/modules/search/components/SearchInput.tsx +232 -0
  226. package/src/modules/search/components/SearchLanding.tsx +74 -0
  227. package/src/modules/search/components/SearchView.tsx +563 -0
  228. package/src/modules/search/components/SimpleEditor.tsx +158 -0
  229. package/src/modules/search/components/SimpleFileList.tsx +215 -0
  230. package/src/modules/search/index.tsx +10 -0
  231. package/src/modules/search/reademe.md +1 -0
  232. package/src/modules/search/servers/apis.tsx +19 -0
  233. package/src/modules/search/servers/index.ts +184 -0
  234. package/src/modules/search/style.less +503 -0
  235. package/src/modules/search/type.ts +22 -0
  236. package/src/modules/search/utils.ts +34 -0
  237. package/src/modules/sensitive/index.tsx +313 -0
  238. package/src/modules/sensitive/server.ts +122 -0
  239. package/src/modules/streamFilesReader/GientechStreamReader.tsx +1555 -0
  240. package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
  241. package/src/modules/streamFilesReader/components/Header/index.tsx +297 -0
  242. package/src/modules/streamFilesReader/index.tsx +3 -0
  243. package/src/style.css +6 -0
  244. package/src/type.d.ts +0 -0
  245. package/src/utils/commonFn.tsx +111 -0
  246. package/src/utils/gientechCommon/components/AppError.tsx +32 -0
  247. package/src/utils/gientechCommon/components/AppLoading.tsx +75 -0
  248. package/src/utils/gientechCommon/components/DeleteModal.tsx +75 -0
  249. package/src/utils/gientechCommon/components/DisplayError.tsx +33 -0
  250. package/src/utils/gientechCommon/components/DisplayLoading.tsx +38 -0
  251. package/src/utils/gientechCommon/components/FeedBackModal.tsx +310 -0
  252. package/src/utils/gientechCommon/components/FileCardCommon.tsx +82 -0
  253. package/src/utils/gientechCommon/components/FileManager/index.tsx +390 -0
  254. package/src/utils/gientechCommon/components/FileManager/style.css +5 -0
  255. package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +296 -0
  256. package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +339 -0
  257. package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +245 -0
  258. package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +209 -0
  259. package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
  260. package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +148 -0
  261. package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +14 -0
  262. package/src/utils/gientechCommon/components/RenameModal.tsx +86 -0
  263. package/src/utils/gientechCommon/components/style.less +11 -0
  264. package/src/utils/gientechCommon/configs/commonConfig.ts +2 -0
  265. package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
  266. package/src/utils/gientechCommon/configs/stylesConfig.ts +142 -0
  267. package/src/utils/gientechCommon/hooks/AichatUseController.tsx +345 -0
  268. package/src/utils/gientechCommon/slate/converters/deserializers.ts +763 -0
  269. package/src/utils/gientechCommon/slate/converters/mockData.ts +232 -0
  270. package/src/utils/gientechCommon/slate/converters/slateConverters.ts +258 -0
  271. package/src/utils/gientechCommon/slate/richElements/index.tsx +499 -0
  272. package/src/utils/gientechCommon/utils/request.ts +37 -0
  273. package/src/utils/gientechCommon/utils/serverFn.ts +172 -0
  274. package/src/utils/index.tsx +126 -0
  275. package/src/utils/testconfigs/demologin/index.tsx +32 -0
  276. package/src/utils/testconfigs/index.ts +53 -0
  277. package/src/vite-env.d.ts +11 -0
  278. package/stats.html +4949 -0
  279. package/tailwind.config.js +170 -0
  280. package/tsconfig.app.json +30 -0
  281. package/tsconfig.app.tsbuildinfo +11 -0
  282. package/tsconfig.json +13 -0
  283. package/tsconfig.node.json +22 -0
  284. package/tsconfig.node.tsbuildinfo +1 -0
  285. package/vite.config.ts +177 -0
  286. package/workflows/release.yml +60 -0
  287. package/assets/style.css +0 -1
  288. package/assets/style3.css +0 -1
  289. package/database.js +0 -20
  290. /package/{assets → dist/assets}/Doris.png +0 -0
  291. /package/{assets → dist/assets}/PostgreSQL.png +0 -0
  292. /package/{assets → dist/assets}/SQLServer.png +0 -0
  293. /package/{assets → dist/assets}/_commonjsHelpers-gnU0ypJ3.js +0 -0
  294. /package/{assets → dist/assets}/circle-alert-g2Y6zAjt.js +0 -0
  295. /package/{assets → dist/assets}/empty.png +0 -0
  296. /package/{assets → dist/assets}/index-CEK88UzR.js +0 -0
  297. /package/{assets → dist/assets}/index-CpW6Dhpp.js +0 -0
  298. /package/{assets → dist/assets}/plus-omCUN0e3.js +0 -0
  299. /package/{assets → dist/assets}/style2.css +0 -0
  300. /package/{assets → dist/assets}/styled-components.browser.esm-DPkS13KC.js +0 -0
  301. /package/{assets → dist/assets}/x-vPcWt3fC.js +0 -0
  302. /package/{chat.d.ts → dist/chat.d.ts} +0 -0
  303. /package/{database.d.ts → dist/database.d.ts} +0 -0
  304. /package/{databaseId.d.ts → dist/databaseId.d.ts} +0 -0
  305. /package/{databaseTable.d.ts → dist/databaseTable.d.ts} +0 -0
  306. /package/{modelManage.d.ts → dist/modelManage.d.ts} +0 -0
  307. /package/{sensitive.d.ts → dist/sensitive.d.ts} +0 -0
  308. /package/{streamFilesReader.d.ts → dist/streamFilesReader.d.ts} +0 -0
  309. /package/{vite.svg → dist/vite.svg} +0 -0
@@ -0,0 +1,734 @@
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;