@gientech/modual 2.2.3-fix.6 → 2.2.3-fix.8

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 (523) hide show
  1. package/README.md +761 -761
  2. package/{dist/assets/GientechStreamReader-Bae2-4f7.js → assets/GientechStreamReader-r5ZTSZk2.js} +1 -1
  3. package/{dist/assets/LeftOutlined-COk0w5nY.js → assets/LeftOutlined-DZMeGbKk.js} +1 -1
  4. package/{dist/assets/circle-plus-DOKqXUMk.js → assets/circle-plus-B73z_SUN.js} +1 -1
  5. package/{src/modules/database/assets → assets}/database.svg +11 -11
  6. package/{src/modules/database/assets → assets}/database_add.svg +53 -53
  7. package/{dist/assets → assets}/database_connect.svg +66 -66
  8. package/{dist/assets → assets}/database_upload.svg +29 -29
  9. package/{dist/assets → assets}/databse.svg +6 -6
  10. package/{dist/assets → assets}/defaultWeLogo.svg +14 -14
  11. package/{dist/assets → assets}/graph.svg +4 -4
  12. package/{src/assets/img → assets}/iconAi.svg +9 -9
  13. package/{dist/assets/index-BKbpfN9S.js → assets/index-97Oe7YBe.js} +1 -1
  14. package/{dist/assets/index-BXdyn2W3.js → assets/index-B4k3tK0f.js} +1 -1
  15. package/{dist/assets/index-Bin0NZwF.js → assets/index-BDc2zBbG.js} +7 -3
  16. package/assets/index-BIEKgWu0.js +27 -0
  17. package/assets/index-CzZQWA2P.js +1 -0
  18. package/{dist/assets/index-CpSzj-Sx.js → assets/index-DHK_n74G.js} +58 -73
  19. package/assets/index-DPA1HCWQ.js +1372 -0
  20. package/assets/index-DPyRygOA.js +745 -0
  21. package/assets/index-YHUI3QVz.js +943 -0
  22. package/{dist/assets/index-vfI1_Qg0.js → assets/index-iOuQJ8vu.js} +1 -1
  23. package/{dist/assets/index-Ct_k24Ar.js → assets/index-usBlUHOb.js} +1 -1
  24. package/{src/modules/assistantConfig/assets → assets}/knowledge.svg +4 -4
  25. package/{src/modules/database/assets → assets}/mysql.svg +14 -14
  26. package/assets/plus-BICgMvz9.js +6 -0
  27. package/assets/search-CD5YKija.js +6 -0
  28. package/{dist/assets → assets}/sensitive.svg +5 -5
  29. package/assets/style-Blt3Kyyt.js +196 -0
  30. package/assets/style2.css +1 -0
  31. package/{dist/assets/triangle-alert-CaJaaCaZ.js → assets/triangle-alert-C4Z1AkGW.js} +1 -1
  32. package/{dist/assets/x-B65AntWN.js → assets/x-DWGzNb9c.js} +1 -1
  33. package/{dist/assistantConfig.js → assistantConfig.js} +14 -9
  34. package/chat.js +1 -0
  35. package/chatCompare.js +1 -0
  36. package/database.js +20 -0
  37. package/{dist/databaseId.js → databaseId.js} +1 -1
  38. package/{dist/databaseTable.js → databaseTable.js} +1 -1
  39. package/index.js +1 -0
  40. package/modelManage.js +1 -0
  41. package/package.json +44 -125
  42. package/{dist/sensitive.js → sensitive.js} +6 -6
  43. package/streamFilesReader.js +1 -0
  44. package/{public/worker → worker}/pdf.worker.min.js +21 -21
  45. package/.editorconfig +0 -38
  46. package/.prettierignore +0 -16
  47. package/.prettierrc +0 -17
  48. package/CHANGELOG.md +0 -162
  49. package/Dockerfile +0 -15
  50. package/USAGE.md +0 -247
  51. package/bash.exe.stackdump +0 -40
  52. package/components.json +0 -21
  53. package/default.conf +0 -19
  54. package/dist/README.md +0 -761
  55. package/dist/assets/database.svg +0 -11
  56. package/dist/assets/database_add.svg +0 -53
  57. package/dist/assets/iconAi.svg +0 -9
  58. package/dist/assets/index-1PwCuRjv.js +0 -1061
  59. package/dist/assets/index-7QvYA6eT.js +0 -1
  60. package/dist/assets/index-BhUNGJOe.js +0 -27
  61. package/dist/assets/index-DT3qkjJ3.js +0 -750
  62. package/dist/assets/index-lFBFf_0k.js +0 -1890
  63. package/dist/assets/knowledge.svg +0 -4
  64. package/dist/assets/mysql.svg +0 -14
  65. package/dist/assets/style-CfNUqKAA.js +0 -196
  66. package/dist/assets/style2.css +0 -1
  67. package/dist/chat.js +0 -1
  68. package/dist/chatCompare.js +0 -1
  69. package/dist/database.js +0 -20
  70. package/dist/index.js +0 -1
  71. package/dist/modelManage.js +0 -1
  72. package/dist/package.json +0 -73
  73. package/dist/streamFilesReader.js +0 -1
  74. package/dist/worker/pdf.worker.min.js +0 -22
  75. package/doc_assets/images/1.png +0 -0
  76. package/doc_assets/images/3.png +0 -0
  77. package/doc_assets/images/component-screenshot.png +0 -1
  78. package/doc_assets//346/226/271/346/241/210/v2.0.7/345/217/230/346/233/264/346/200/273/347/273/223.md +0 -115
  79. package/doc_assets//346/226/271/346/241/210//344/274/230/345/214/226/346/226/271/346/241/210-/345/244/232/344/274/232/350/257/235SSE/350/277/236/346/216/245/347/256/241/347/220/206.md +0 -504
  80. package/doc_assets//346/226/271/346/241/210//346/215/242/350/241/214/346/240/274/345/274/217/344/277/235/346/214/201/344/274/230/345/214/226/346/226/271/346/241/210.md +0 -359
  81. package/eslint.config.js +0 -92
  82. package/index.html +0 -13
  83. package/package.json.demo-backup +0 -109
  84. package/postcss.config.cjs +0 -19
  85. package/public/icons/answerAwartar.png +0 -0
  86. package/public/icons/docx-file.png +0 -0
  87. package/public/icons/folder.png +0 -0
  88. package/public/icons/html.png +0 -0
  89. package/public/icons/image.png +0 -0
  90. package/public/icons/jpg-file.png +0 -0
  91. package/public/icons/json.png +0 -0
  92. package/public/icons/md.png +0 -0
  93. package/public/icons/pdf.png +0 -0
  94. package/public/icons/pptx.png +0 -0
  95. package/public/icons/questionAwartar.png +0 -0
  96. package/public/icons/sheets.png +0 -0
  97. package/public/icons/txt.png +0 -0
  98. package/public/icons/xlsx.png +0 -0
  99. package/public/vite.svg +0 -1
  100. package/rag/assets/index.Bd0tNzw0.js +0 -2797
  101. package/rag/assets/index.D6t67hlu.css +0 -1
  102. package/rag/assets/left.KBHV5h7q.jpg +0 -0
  103. package/rag/assets/worker-BbpylX7l.DptbXke_.js +0 -13
  104. package/release-it.json +0 -21
  105. package/scripts/README.md +0 -133
  106. package/scripts/build-demo.js +0 -88
  107. package/scripts/check-changelog.cjs +0 -124
  108. package/scripts/check-version.cjs +0 -49
  109. package/scripts/decrypt-api-key.js +0 -95
  110. package/scripts/demo-selector.js +0 -216
  111. package/scripts/dev-demo.js +0 -85
  112. package/scripts/open-file.cjs +0 -61
  113. package/scripts/preview-demo.js +0 -130
  114. package/scripts/run-demo.bat +0 -34
  115. package/src/assets/img/close.png +0 -0
  116. package/src/assets/img/database.png +0 -0
  117. package/src/assets/img/downArrow.png +0 -0
  118. package/src/assets/img/downLoad.png +0 -0
  119. package/src/assets/img/excel.png +0 -0
  120. package/src/assets/img/graphIcon.png +0 -0
  121. package/src/assets/img/img.png +0 -0
  122. package/src/assets/img/pdf.png +0 -0
  123. package/src/assets/img/ppt.png +0 -0
  124. package/src/assets/img/search.svg +0 -3
  125. package/src/assets/img/selected.svg +0 -4
  126. package/src/assets/img/singleQa.png +0 -0
  127. package/src/assets/img/txt.png +0 -0
  128. package/src/assets/img/webSearch.png +0 -0
  129. package/src/assets/img/word.png +0 -0
  130. package/src/assets/login/homeBg.png +0 -0
  131. package/src/assets/login/left.jpg +0 -0
  132. package/src/assets/login/logoImg.png +0 -0
  133. package/src/examples/ConversationAssistantPage/index.tsx +0 -42
  134. package/src/examples/LoginPage/index.tsx +0 -20
  135. package/src/examples/chat/components/DrawerGraphPreview.tsx +0 -78
  136. package/src/examples/chat/index.tsx +0 -171
  137. package/src/examples/chat/logo03.png +0 -0
  138. package/src/examples/chatCompare/icons/rag_think.svg +0 -8
  139. package/src/examples/chatCompare/icons/wenda_lianwangsousuo.svg +0 -9
  140. package/src/examples/chatCompare/index.tsx +0 -154
  141. package/src/examples/gientechStreamFilesReader/index.tsx +0 -979
  142. package/src/examples/headlessChat/assets/mind.svg +0 -6
  143. package/src/examples/headlessChat/assets/net.svg +0 -7
  144. package/src/examples/headlessChat/index.tsx +0 -298
  145. package/src/examples/knowledgebaseDetails/index.tsx +0 -119
  146. package/src/examples/ragDatabaseDataPage/index.tsx +0 -40
  147. package/src/examples/ragDatabaseIdPage/index.tsx +0 -126
  148. package/src/examples/ragDatabasePage/index.tsx +0 -36
  149. package/src/examples/ragModelManagePage/index.tsx +0 -107
  150. package/src/examples/ragModelManagePage/style.css +0 -7
  151. package/src/examples/ragSearchPage/index.tsx +0 -0
  152. package/src/examples/ragSensitiveWordsPage/index.tsx +0 -117
  153. package/src/examples/ragSensitiveWordsPage/style.css +0 -16
  154. package/src/examples/sensitiveId/index.tsx +0 -41
  155. package/src/examples/streamFiles/index.tsx +0 -417
  156. package/src/examples/utils/demo_setting_pannel.ts +0 -0
  157. package/src/lib_enter.ts +0 -44
  158. package/src/main.tsx +0 -5
  159. package/src/main.tsx.backup +0 -5
  160. package/src/modules/CHAT_UNIFICATION_PLAN.md +0 -324
  161. package/src/modules/assistantConfig/assets/databse.svg +0 -6
  162. package/src/modules/assistantConfig/assets/empty.png +0 -0
  163. package/src/modules/assistantConfig/assets/graph.svg +0 -4
  164. package/src/modules/assistantConfig/assets/sensitive.svg +0 -5
  165. package/src/modules/assistantConfig/components/Database.tsx +0 -171
  166. package/src/modules/assistantConfig/components/Graph.tsx +0 -177
  167. package/src/modules/assistantConfig/components/Knowledge.tsx +0 -276
  168. package/src/modules/assistantConfig/components/NotFoundContent.tsx +0 -21
  169. package/src/modules/assistantConfig/components/Paragraph.tsx +0 -51
  170. package/src/modules/assistantConfig/components/ParamsItem.tsx +0 -40
  171. package/src/modules/assistantConfig/components/ResourceBinderItem.tsx +0 -133
  172. package/src/modules/assistantConfig/components/SearchableSelector.tsx +0 -500
  173. package/src/modules/assistantConfig/components/Sensitive.tsx +0 -221
  174. package/src/modules/assistantConfig/components/SliderInput.tsx +0 -66
  175. package/src/modules/assistantConfig/constants.tsx +0 -75
  176. package/src/modules/assistantConfig/index.tsx +0 -785
  177. package/src/modules/assistantConfig/server.ts +0 -262
  178. package/src/modules/chat/AllFiles.tsx +0 -158
  179. package/src/modules/chat/Conversations/Item.tsx +0 -169
  180. package/src/modules/chat/Conversations/List.tsx +0 -210
  181. package/src/modules/chat/Conversations/groupByTime.ts +0 -39
  182. package/src/modules/chat/Conversations/index.tsx +0 -255
  183. package/src/modules/chat/ReferenceBar.tsx +0 -659
  184. package/src/modules/chat/constants.tsx +0 -66
  185. package/src/modules/chat/i18n.ts +0 -151
  186. package/src/modules/chat/i18n.tsx +0 -151
  187. package/src/modules/chat/icons/rag_think.svg +0 -8
  188. package/src/modules/chat/icons/wenda_lianwangsousuo.svg +0 -9
  189. package/src/modules/chat/index.tsx +0 -2400
  190. package/src/modules/chat/referenceCom/DeleteModal.tsx +0 -75
  191. package/src/modules/chat/referenceCom/DrawerContent.tsx +0 -136
  192. package/src/modules/chat/referenceCom/DrawerDatabase.tsx +0 -102
  193. package/src/modules/chat/referenceCom/DrawerGraphPreview.tsx +0 -86
  194. package/src/modules/chat/referenceCom/DrawerPreview.tsx +0 -73
  195. package/src/modules/chat/referenceCom/DrawerTitle.tsx +0 -26
  196. package/src/modules/chat/referenceCom/RenameModal.tsx +0 -86
  197. package/src/modules/chat/referenceCom/TagCom.tsx +0 -30
  198. package/src/modules/chat/style.css +0 -6
  199. package/src/modules/chat/style.less +0 -7
  200. package/src/modules/chat/types.ts +0 -17
  201. package/src/modules/chat/utils/index.ts +0 -348
  202. package/src/modules/chatCompare/UseChatCompareHooks.ts +0 -103
  203. package/src/modules/chatCompare/components/AichatCompareUseController.tsx +0 -754
  204. package/src/modules/chatCompare/components/AssistantSelector.tsx +0 -127
  205. package/src/modules/chatCompare/components/ChatInputer.tsx +0 -67
  206. package/src/modules/chatCompare/components/ChatInstance.tsx +0 -426
  207. package/src/modules/chatCompare/components/ChatItem.tsx +0 -556
  208. package/src/modules/chatCompare/components/Sender/FileCardCommon.tsx +0 -97
  209. package/src/modules/chatCompare/components/Sender/FileUpload.tsx +0 -89
  210. package/src/modules/chatCompare/components/Sender/FilesDisplay.tsx +0 -309
  211. package/src/modules/chatCompare/components/Sender/VoiceInput.tsx +0 -80
  212. package/src/modules/chatCompare/components/Sender/contexts/BadgeContext.tsx +0 -36
  213. package/src/modules/chatCompare/components/Sender/fileIcon.tsx +0 -100
  214. package/src/modules/chatCompare/components/Sender/index.tsx +0 -850
  215. package/src/modules/chatCompare/components/UseChatInstanceHooks.ts +0 -406
  216. package/src/modules/chatCompare/components/UseScrollHooks.ts +0 -36
  217. package/src/modules/chatCompare/components/components/AllFiles.tsx +0 -156
  218. package/src/modules/chatCompare/components/components/DeleteModal.tsx +0 -75
  219. package/src/modules/chatCompare/components/components/DrawerContent.tsx +0 -138
  220. package/src/modules/chatCompare/components/components/DrawerDatabase.tsx +0 -110
  221. package/src/modules/chatCompare/components/components/DrawerGraphPreview.tsx +0 -95
  222. package/src/modules/chatCompare/components/components/DrawerPreview.tsx +0 -75
  223. package/src/modules/chatCompare/components/components/DrawerTitle.tsx +0 -26
  224. package/src/modules/chatCompare/components/components/DrawerVideo.tsx +0 -85
  225. package/src/modules/chatCompare/components/components/ReferenceBar.tsx +0 -659
  226. package/src/modules/chatCompare/components/components/RenameModal.tsx +0 -86
  227. package/src/modules/chatCompare/components/components/TagCom.tsx +0 -30
  228. package/src/modules/chatCompare/components/defaultStyleSet.tsx +0 -148
  229. package/src/modules/chatCompare/components/server.ts +0 -208
  230. package/src/modules/chatCompare/components/serverFn.ts +0 -172
  231. package/src/modules/chatCompare/components/style.less +0 -97
  232. package/src/modules/chatCompare/components/useFileManager.ts +0 -173
  233. package/src/modules/chatCompare/components/utils.ts +0 -31
  234. package/src/modules/chatCompare/data.ts +0 -842
  235. package/src/modules/chatCompare/index.tsx +0 -537
  236. package/src/modules/chatCompare/utils/AiChat.types.tsx +0 -110
  237. package/src/modules/chatCompare/utils/constants.tsx +0 -70
  238. package/src/modules/chatCompare/utils/fileUploadValidator.ts +0 -183
  239. package/src/modules/chatCompare/utils/icons/rag_think.svg +0 -8
  240. package/src/modules/chatCompare/utils/icons/wenda_lianwangsousuo.svg +0 -9
  241. package/src/modules/chatCompare/utils/index.ts +0 -46
  242. package/src/modules/database/CreateModal.tsx +0 -402
  243. package/src/modules/database/assets/Doris.png +0 -0
  244. package/src/modules/database/assets/PostgreSQL.png +0 -0
  245. package/src/modules/database/assets/SQLServer.png +0 -0
  246. package/src/modules/database/assets/database_connect.svg +0 -66
  247. package/src/modules/database/assets/database_upload.svg +0 -29
  248. package/src/modules/database/assets/empty.png +0 -0
  249. package/src/modules/database/index.tsx +0 -477
  250. package/src/modules/database/server.ts +0 -196
  251. package/src/modules/databaseId/CustomCom.tsx +0 -156
  252. package/src/modules/databaseId/EditConfig.tsx +0 -280
  253. package/src/modules/databaseId/UploadDrawer.tsx +0 -535
  254. package/src/modules/databaseId/assets/aiOptimize.svg +0 -10
  255. package/src/modules/databaseId/assets/empty.png +0 -0
  256. package/src/modules/databaseId/assets/template.svg +0 -6
  257. package/src/modules/databaseId/assets/upload.svg +0 -9
  258. package/src/modules/databaseId/assets/useTemp.svg +0 -6
  259. package/src/modules/databaseId/i18n.ts +0 -360
  260. package/src/modules/databaseId/index.tsx +0 -855
  261. package/src/modules/databaseId/server.ts +0 -286
  262. package/src/modules/databaseId/style.css +0 -5
  263. package/src/modules/databaseTable/EditRowDrawer.tsx +0 -124
  264. package/src/modules/databaseTable/index.tsx +0 -359
  265. package/src/modules/databaseTable/server.ts +0 -180
  266. package/src/modules/headlessChat/ReferenceBar.tsx +0 -783
  267. package/src/modules/headlessChat/constants.tsx +0 -54
  268. package/src/modules/headlessChat/index.tsx +0 -1903
  269. package/src/modules/headlessChat/referenceCom/DeleteModal.tsx +0 -75
  270. package/src/modules/headlessChat/referenceCom/DrawerContent.tsx +0 -136
  271. package/src/modules/headlessChat/referenceCom/DrawerDatabase.tsx +0 -102
  272. package/src/modules/headlessChat/referenceCom/DrawerGraphPreview.tsx +0 -86
  273. package/src/modules/headlessChat/referenceCom/DrawerPreview.tsx +0 -73
  274. package/src/modules/headlessChat/referenceCom/DrawerTitle.tsx +0 -26
  275. package/src/modules/headlessChat/referenceCom/RenameModal.tsx +0 -86
  276. package/src/modules/headlessChat/referenceCom/TagCom.tsx +0 -30
  277. package/src/modules/headlessChat/style.less +0 -3
  278. package/src/modules/headlessChat/types.ts +0 -23
  279. package/src/modules/headlessChat/utils/index.ts +0 -348
  280. package/src/modules/knowledgeBase/index.tsx +0 -58
  281. package/src/modules/knowledgeBase/server.ts +0 -196
  282. package/src/modules/knowledgebaseDetails/KnowledgeBaseDetails.tsx +0 -169
  283. package/src/modules/knowledgebaseDetails/components/KnowledgeBaseSummaryCard.tsx +0 -193
  284. package/src/modules/knowledgebaseDetails/components/fileManagementParts.tsx +0 -534
  285. package/src/modules/knowledgebaseDetails/components/index.ts +0 -3
  286. package/src/modules/knowledgebaseDetails/index.ts +0 -3
  287. package/src/modules/knowledgebaseDetails/modules/ConfigModule.tsx +0 -49
  288. package/src/modules/knowledgebaseDetails/modules/FaqModule.tsx +0 -47
  289. package/src/modules/knowledgebaseDetails/modules/KnowledgeParseModule.tsx +0 -771
  290. package/src/modules/knowledgebaseDetails/modules/RetrievalTestModule.tsx +0 -49
  291. package/src/modules/knowledgebaseDetails/modules/UploadManagementModule.tsx +0 -49
  292. package/src/modules/knowledgebaseDetails/modules/types.ts +0 -44
  293. package/src/modules/knowledgebaseDetails/modules-shim.d.ts +0 -14
  294. package/src/modules/knowledgebaseDetails/servers/analysis.ts +0 -5
  295. package/src/modules/knowledgebaseDetails/servers/index.ts +0 -318
  296. package/src/modules/login/components/Login/LoginBox/index.tsx +0 -105
  297. package/src/modules/login/components/Login/RegisterBox/index.tsx +0 -181
  298. package/src/modules/login/components/Login/index.tsx +0 -100
  299. package/src/modules/login/i18n.ts +0 -217
  300. package/src/modules/login/index.tsx +0 -113
  301. package/src/modules/login/style.css +0 -3
  302. package/src/modules/login/useServices.ts +0 -53
  303. package/src/modules/login/utils.ts +0 -42
  304. package/src/modules/modelManage/ConfigDrawer.tsx +0 -267
  305. package/src/modules/modelManage/ReplaceModal.tsx +0 -113
  306. package/src/modules/modelManage/assets/empty.png +0 -0
  307. package/src/modules/modelManage/const.ts +0 -51
  308. package/src/modules/modelManage/i18n.ts +0 -407
  309. package/src/modules/modelManage/index.tsx +0 -668
  310. package/src/modules/modelManage/server.ts +0 -231
  311. package/src/modules/nodegraph/index.tsx +0 -1
  312. package/src/modules/search/assets/Icon-history.svg +0 -8
  313. package/src/modules/search/assets/answerAwartar.png +0 -0
  314. package/src/modules/search/assets/doc.png +0 -0
  315. package/src/modules/search/assets/genera.gif +0 -0
  316. package/src/modules/search/assets/icon-robot.svg +0 -9
  317. package/src/modules/search/assets/icon-search-bar.svg +0 -14
  318. package/src/modules/search/assets/icon-sub-title.svg +0 -3
  319. package/src/modules/search/assets/icon-title.svg +0 -9
  320. package/src/modules/search/assets/icon-zoomOut.svg +0 -9
  321. package/src/modules/search/assets/iconAi.svg +0 -9
  322. package/src/modules/search/assets/pdf.png +0 -0
  323. package/src/modules/search/assets/ppt.png +0 -0
  324. package/src/modules/search/assets/search.svg +0 -3
  325. package/src/modules/search/assets/selected.svg +0 -4
  326. package/src/modules/search/assets/txt.png +0 -0
  327. package/src/modules/search/assets/xls.png +0 -0
  328. package/src/modules/search/components/AssisSelect.tsx +0 -137
  329. package/src/modules/search/components/Editor/ChatViewEditor.tsx +0 -261
  330. package/src/modules/search/components/Editor/aichat.css +0 -1
  331. package/src/modules/search/components/Editor/constant.ts +0 -13
  332. package/src/modules/search/components/Editor/index.tsx +0 -113
  333. package/src/modules/search/components/Editor/plugins/autofomatRules.ts +0 -332
  334. package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +0 -20
  335. package/src/modules/search/components/Editor/plugins/createIndexes.tsx +0 -38
  336. package/src/modules/search/components/Editor/plugins/displayer.ts +0 -298
  337. package/src/modules/search/components/Editor/plugins/imageClick.tsx +0 -32
  338. package/src/modules/search/components/Editor/plugins/myplugin.tsx +0 -98
  339. package/src/modules/search/components/Editor/ui/avatar.tsx +0 -19
  340. package/src/modules/search/components/Editor/ui/blockquote-element.tsx +0 -21
  341. package/src/modules/search/components/Editor/ui/button.tsx +0 -58
  342. package/src/modules/search/components/Editor/ui/calendar.tsx +0 -68
  343. package/src/modules/search/components/Editor/ui/caption.tsx +0 -46
  344. package/src/modules/search/components/Editor/ui/checkbox.tsx +0 -27
  345. package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +0 -188
  346. package/src/modules/search/components/Editor/ui/code-block-element.css +0 -434
  347. package/src/modules/search/components/Editor/ui/code-block-element.tsx +0 -39
  348. package/src/modules/search/components/Editor/ui/code-leaf.tsx +0 -24
  349. package/src/modules/search/components/Editor/ui/code-line-element.tsx +0 -10
  350. package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +0 -21
  351. package/src/modules/search/components/Editor/ui/column-element.tsx +0 -30
  352. package/src/modules/search/components/Editor/ui/column-group-element.tsx +0 -94
  353. package/src/modules/search/components/Editor/ui/command.tsx +0 -75
  354. package/src/modules/search/components/Editor/ui/comment-avatar.tsx +0 -22
  355. package/src/modules/search/components/Editor/ui/comment-create-form.tsx +0 -37
  356. package/src/modules/search/components/Editor/ui/comment-item.tsx +0 -74
  357. package/src/modules/search/components/Editor/ui/comment-leaf.tsx +0 -49
  358. package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +0 -42
  359. package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +0 -22
  360. package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +0 -32
  361. package/src/modules/search/components/Editor/ui/comment-value.tsx +0 -34
  362. package/src/modules/search/components/Editor/ui/comments-popover.tsx +0 -63
  363. package/src/modules/search/components/Editor/ui/date-element.tsx +0 -83
  364. package/src/modules/search/components/Editor/ui/dialog.tsx +0 -63
  365. package/src/modules/search/components/Editor/ui/draggable.tsx +0 -177
  366. package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +0 -180
  367. package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +0 -85
  368. package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +0 -28
  369. package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +0 -76
  370. package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +0 -8
  371. package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +0 -51
  372. package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +0 -77
  373. package/src/modules/search/components/Editor/ui/heading-element.tsx +0 -48
  374. package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +0 -17
  375. package/src/modules/search/components/Editor/ui/hr-element.tsx +0 -30
  376. package/src/modules/search/components/Editor/ui/icons.tsx +0 -267
  377. package/src/modules/search/components/Editor/ui/image-element.tsx +0 -74
  378. package/src/modules/search/components/Editor/ui/inline-combobox.tsx +0 -368
  379. package/src/modules/search/components/Editor/ui/input.tsx +0 -25
  380. package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +0 -218
  381. package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +0 -20
  382. package/src/modules/search/components/Editor/ui/link-element.tsx +0 -29
  383. package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +0 -161
  384. package/src/modules/search/components/Editor/ui/list-element.tsx +0 -30
  385. package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +0 -24
  386. package/src/modules/search/components/Editor/ui/media-embed-element.tsx +0 -133
  387. package/src/modules/search/components/Editor/ui/media-popover.tsx +0 -97
  388. package/src/modules/search/components/Editor/ui/mention-element.tsx +0 -43
  389. package/src/modules/search/components/Editor/ui/mention-input-element.tsx +0 -141
  390. package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +0 -93
  391. package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +0 -67
  392. package/src/modules/search/components/Editor/ui/paragraph-element.tsx +0 -4
  393. package/src/modules/search/components/Editor/ui/placeholder.tsx +0 -52
  394. package/src/modules/search/components/Editor/ui/popover.tsx +0 -32
  395. package/src/modules/search/components/Editor/ui/resizable.tsx +0 -66
  396. package/src/modules/search/components/Editor/ui/separator.tsx +0 -25
  397. package/src/modules/search/components/Editor/ui/style.less +0 -12
  398. package/src/modules/search/components/Editor/ui/table-cell-element.tsx +0 -143
  399. package/src/modules/search/components/Editor/ui/table-element.tsx +0 -243
  400. package/src/modules/search/components/Editor/ui/table-row-element.tsx +0 -22
  401. package/src/modules/search/components/Editor/ui/tableValue.tsx +0 -135
  402. package/src/modules/search/components/Editor/ui/todo-list-element.tsx +0 -43
  403. package/src/modules/search/components/Editor/ui/toggle-element.tsx +0 -31
  404. package/src/modules/search/components/Editor/ui/toolbar.tsx +0 -157
  405. package/src/modules/search/components/Editor/ui/tooltip.tsx +0 -65
  406. package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +0 -160
  407. package/src/modules/search/components/Editor/ui/with-draggables.tsx +0 -175
  408. package/src/modules/search/components/FileList.tsx +0 -287
  409. package/src/modules/search/components/ImageGroupView/index.tsx +0 -85
  410. package/src/modules/search/components/ResultContent.tsx +0 -232
  411. package/src/modules/search/components/SearchInput.tsx +0 -232
  412. package/src/modules/search/components/SearchLanding.tsx +0 -74
  413. package/src/modules/search/components/SearchView.tsx +0 -563
  414. package/src/modules/search/components/SimpleEditor.tsx +0 -158
  415. package/src/modules/search/components/SimpleFileList.tsx +0 -215
  416. package/src/modules/search/index.tsx +0 -10
  417. package/src/modules/search/reademe.md +0 -1
  418. package/src/modules/search/servers/apis.tsx +0 -19
  419. package/src/modules/search/servers/index.ts +0 -184
  420. package/src/modules/search/style.less +0 -503
  421. package/src/modules/search/type.ts +0 -22
  422. package/src/modules/search/utils.ts +0 -34
  423. package/src/modules/sensitive/i18n.ts +0 -391
  424. package/src/modules/sensitive/index.tsx +0 -604
  425. package/src/modules/sensitive/sensitiveEditor.tsx +0 -543
  426. package/src/modules/sensitive/server.ts +0 -197
  427. package/src/modules/sensitiveId/AutoTag.tsx +0 -311
  428. package/src/modules/sensitiveId/UploadModal.tsx +0 -181
  429. package/src/modules/sensitiveId/VirtualWrap.tsx +0 -125
  430. package/src/modules/sensitiveId/index.tsx +0 -253
  431. package/src/modules/sensitiveId/server.ts +0 -142
  432. package/src/modules/streamFilesReader/GientechStreamReader.tsx +0 -1658
  433. package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
  434. package/src/modules/streamFilesReader/components/Header/index.tsx +0 -297
  435. package/src/modules/streamFilesReader/index.tsx +0 -3
  436. package/src/style.css +0 -6
  437. package/src/type.d.ts +0 -0
  438. package/src/utils/commonFn.tsx +0 -153
  439. package/src/utils/decryptApiKey.ts +0 -40
  440. package/src/utils/gientechCommon/components/AppError.tsx +0 -32
  441. package/src/utils/gientechCommon/components/AppLoading.tsx +0 -75
  442. package/src/utils/gientechCommon/components/DeleteModal.tsx +0 -75
  443. package/src/utils/gientechCommon/components/DisplayError.tsx +0 -33
  444. package/src/utils/gientechCommon/components/DisplayLoading.tsx +0 -38
  445. package/src/utils/gientechCommon/components/FeedBackModal.tsx +0 -319
  446. package/src/utils/gientechCommon/components/FileCardCommon.tsx +0 -82
  447. package/src/utils/gientechCommon/components/FileManager/index.tsx +0 -418
  448. package/src/utils/gientechCommon/components/FileManager/style.css +0 -5
  449. package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +0 -583
  450. package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +0 -359
  451. package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +0 -245
  452. package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +0 -209
  453. package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
  454. package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +0 -148
  455. package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +0 -14
  456. package/src/utils/gientechCommon/components/RenameModal.tsx +0 -86
  457. package/src/utils/gientechCommon/components/style.less +0 -11
  458. package/src/utils/gientechCommon/configs/commonConfig.ts +0 -2
  459. package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
  460. package/src/utils/gientechCommon/configs/stylesConfig.ts +0 -142
  461. package/src/utils/gientechCommon/hooks/AichatUseController.tsx +0 -761
  462. package/src/utils/gientechCommon/hooks/style.less +0 -8
  463. package/src/utils/gientechCommon/hooks/useFileDisplayTools.tsx +0 -352
  464. package/src/utils/gientechCommon/hooks/useFileManager.ts +0 -169
  465. package/src/utils/gientechCommon/slate/converters/deserializers.ts +0 -763
  466. package/src/utils/gientechCommon/slate/converters/mockData.ts +0 -232
  467. package/src/utils/gientechCommon/slate/converters/slateConverters.ts +0 -258
  468. package/src/utils/gientechCommon/slate/richElements/index.tsx +0 -499
  469. package/src/utils/gientechCommon/utils/fileUtils.ts +0 -86
  470. package/src/utils/gientechCommon/utils/index.ts +0 -386
  471. package/src/utils/gientechCommon/utils/request.ts +0 -37
  472. package/src/utils/gientechCommon/utils/serverFn.ts +0 -172
  473. package/src/utils/index.tsx +0 -186
  474. package/src/utils/testconfigs/demologin/index.tsx +0 -32
  475. package/src/utils/testconfigs/index.ts +0 -66
  476. package/src/vite-env.d.ts +0 -49
  477. package/stats.html +0 -4949
  478. package/tailwind.config.js +0 -170
  479. package/tsconfig.app.json +0 -31
  480. package/tsconfig.app.tsbuildinfo +0 -11
  481. package/tsconfig.json +0 -17
  482. package/tsconfig.node.json +0 -23
  483. package/tsconfig.node.tsbuildinfo +0 -1
  484. package/vite.config.app.ts +0 -91
  485. package/vite.config.ts +0 -238
  486. /package/{dist/assets → assets}/Doris.png +0 -0
  487. /package/{dist/assets → assets}/PostgreSQL.png +0 -0
  488. /package/{dist/assets → assets}/SQLServer.png +0 -0
  489. /package/{dist/assets → assets}/empty.png +0 -0
  490. /package/{dist/assets → assets}/homeBg.png +0 -0
  491. /package/{dist/assets → assets}/index-CpW6Dhpp.js +0 -0
  492. /package/{dist/assets → assets}/left.jpg +0 -0
  493. /package/{dist/assets → assets}/logoImg.png +0 -0
  494. /package/{dist/assets → assets}/style.css +0 -0
  495. /package/{dist/assets → assets}/style3.css +0 -0
  496. /package/{dist/assets → assets}/style4.css +0 -0
  497. /package/{dist/assets → assets}/style5.css +0 -0
  498. /package/{dist/assets → assets}/worker-BbpylX7l.js +0 -0
  499. /package/{dist/assistantConfig.d.ts → assistantConfig.d.ts} +0 -0
  500. /package/{dist/chat.d.ts → chat.d.ts} +0 -0
  501. /package/{dist/chatCompare.d.ts → chatCompare.d.ts} +0 -0
  502. /package/{dist/database.d.ts → database.d.ts} +0 -0
  503. /package/{dist/databaseId.d.ts → databaseId.d.ts} +0 -0
  504. /package/{dist/databaseTable.d.ts → databaseTable.d.ts} +0 -0
  505. /package/{dist/icons → icons}/answerAwartar.png +0 -0
  506. /package/{dist/icons → icons}/docx-file.png +0 -0
  507. /package/{dist/icons → icons}/folder.png +0 -0
  508. /package/{dist/icons → icons}/html.png +0 -0
  509. /package/{dist/icons → icons}/image.png +0 -0
  510. /package/{dist/icons → icons}/jpg-file.png +0 -0
  511. /package/{dist/icons → icons}/json.png +0 -0
  512. /package/{dist/icons → icons}/md.png +0 -0
  513. /package/{dist/icons → icons}/pdf.png +0 -0
  514. /package/{dist/icons → icons}/pptx.png +0 -0
  515. /package/{dist/icons → icons}/questionAwartar.png +0 -0
  516. /package/{dist/icons → icons}/sheets.png +0 -0
  517. /package/{dist/icons → icons}/txt.png +0 -0
  518. /package/{dist/icons → icons}/xlsx.png +0 -0
  519. /package/{dist/index.d.ts → index.d.ts} +0 -0
  520. /package/{dist/modelManage.d.ts → modelManage.d.ts} +0 -0
  521. /package/{dist/sensitive.d.ts → sensitive.d.ts} +0 -0
  522. /package/{dist/streamFilesReader.d.ts → streamFilesReader.d.ts} +0 -0
  523. /package/{dist/vite.svg → vite.svg} +0 -0
@@ -1,1658 +0,0 @@
1
- import React, { useState, useCallback, useEffect, useRef, useMemo } from 'react';
2
- import styled from 'styled-components';
3
- import axios from 'axios';
4
- import { Fviewer, parseFile, registerPDFWorker } from '@mxmweb/fviewer';
5
- import type { ParseResult } from '@mxmweb/fviewer';
6
- import Header from './components/Header';
7
- export { registerPDFWorker };
8
- import type { Annotation, ToolsConfig } from '@mxmweb/fviewer';
9
-
10
- import { Styles } from '@mxmweb/zui';
11
- // Stream接口参数类型
12
- interface StreamRequestParams {
13
- convertedFilePath: string;
14
- pageNo: number;
15
- pageSize: number;
16
- }
17
-
18
- // Markdown完整内容缓存类型
19
- interface MarkdownContentCache {
20
- data: string; // markdown完整内容
21
- timestamp: number;
22
- }
23
-
24
- // GientechStreamReader组件属性接口
25
- export interface GientechStreamReaderProps {
26
- // 文件相关
27
- convertedFilePath: string;
28
- csrfToken?: string;
29
- fileName?: string;
30
- fileType: string;
31
- initialPage?: number;
32
- initialZoom?: number; // 初始缩放比例
33
- totalPages?: number; // 添加总页数参数
34
- annotations?: (Annotation | any)[]; // 统一的标注数据
35
-
36
- // 用户信息
37
- userName?: string;
38
- userId?: string;
39
- pageSize?: number;
40
-
41
- // API配置
42
- streamApiUrl?: string;
43
- authorization?: string;
44
-
45
- // 事件回调
46
- eventsEmit?: (name: string, data?: any, innerFn?: any) => void;
47
-
48
- // 工具配置 - 用户可自定义,与默认配置合并
49
- tools?: Partial<ToolsConfig>;
50
-
51
- // 样式配置
52
- styles?: Styles;
53
-
54
- // 自定义组件
55
- customComponents?: {
56
- LoadingComponent?: React.ComponentType<{
57
- status: string;
58
- theme: Styles;
59
- }>;
60
- ErrorComponent?: React.ComponentType<{
61
- error: string;
62
- theme: Styles;
63
- }>;
64
- };
65
-
66
- // 自定义类名
67
- className?: string;
68
- headerClass?: string;
69
- contentClass?: string;
70
- }
71
-
72
- // 页面缓存类型 - 重新设计支持分页chunk缓存
73
- interface PageChunkCache {
74
- [chunkKey: string]: {
75
- data: ArrayBuffer;
76
- pages: number[]; // 这个chunk包含的页面范围
77
- timestamp: number;
78
- totalPages?: number; // 从响应头获取的总页数
79
- pdfDocument?: any; // 缓存解析后的PDF文档
80
- };
81
- }
82
-
83
- // 单个页面缓存类型
84
- interface PageCache {
85
- [pageNo: number]: {
86
- data: ArrayBuffer;
87
- timestamp: number;
88
- pdfDocument?: any; // 缓存解析后的PDF文档
89
- };
90
- }
91
-
92
- // 样式组件
93
- const ReaderContainer = styled.div<{ $theme: Styles }>`
94
- display: flex;
95
- flex-direction: column;
96
- height: 100%;
97
- width: 100%;
98
- background: ${props => props.$theme.colors.background};
99
- border: 1px solid ${props => props.$theme.colors.border};
100
- border-radius: ${props => props.$theme.space.radius};
101
- overflow: hidden;
102
- min-height: 0;
103
- position: relative; // 添加相对定位,用于loading遮罩的绝对定位
104
-
105
- /* 添加动画样式 */
106
- @keyframes spin {
107
- 0% {
108
- transform: rotate(0deg);
109
- }
110
- 100% {
111
- transform: rotate(360deg);
112
- }
113
- }
114
- `;
115
-
116
- /**
117
- * 默认文件加载动画组件
118
- * 提供美观的文件加载动画效果,支持状态文本显示
119
- */
120
- const DefaultLoadingComponent: React.FC<{
121
- status: string;
122
- theme: Styles;
123
- }> = ({ status, theme }) => {
124
- return (
125
- <div
126
- style={{
127
- display: 'flex',
128
- flexDirection: 'column',
129
- alignItems: 'center',
130
- justifyContent: 'center',
131
- height: '100%',
132
- padding: '40px',
133
- background: theme.colors.background,
134
- }}
135
- >
136
- {/* 文件图标动画 */}
137
- <div
138
- style={{
139
- position: 'relative',
140
- width: '80px',
141
- height: '80px',
142
- marginBottom: '24px',
143
- }}
144
- >
145
- {/* 文件图标背景 */}
146
- <div
147
- style={{
148
- width: '60px',
149
- height: '80px',
150
- background: theme.colors.primary,
151
- borderRadius: '8px 8px 0 0',
152
- position: 'relative',
153
- margin: '0 auto',
154
- }}
155
- >
156
- {/* 文件折角 */}
157
- <div
158
- style={{
159
- position: 'absolute',
160
- top: '0',
161
- right: '0',
162
- width: '0',
163
- height: '0',
164
- borderStyle: 'solid',
165
- borderWidth: '0 20px 20px 0',
166
- borderColor: `transparent ${theme.colors.background} transparent transparent`,
167
- }}
168
- />
169
- </div>
170
-
171
- {/* 加载动画圆点 */}
172
- <div
173
- style={{
174
- position: 'absolute',
175
- top: '50%',
176
- left: '50%',
177
- transform: 'translate(-50%, -50%)',
178
- width: '20px',
179
- height: '20px',
180
- borderRadius: '50%',
181
- background: theme.colors.background,
182
- animation: 'pulse 1.5s ease-in-out infinite',
183
- }}
184
- />
185
- </div>
186
-
187
- {/* 状态文本 */}
188
- <div
189
- style={{
190
- fontSize: '16px',
191
- fontWeight: '500',
192
- color: theme.colors.text,
193
- marginBottom: '8px',
194
- textAlign: 'center',
195
- }}
196
- >
197
- {status}
198
- </div>
199
-
200
- {/* 进度指示器 */}
201
- <div
202
- style={{
203
- width: '200px',
204
- height: '4px',
205
- background: theme.colors.border,
206
- borderRadius: '2px',
207
- overflow: 'hidden',
208
- position: 'relative',
209
- }}
210
- >
211
- <div
212
- style={{
213
- width: '30%',
214
- height: '100%',
215
- background: theme.colors.primary,
216
- borderRadius: '2px',
217
- animation: 'loading-progress 2s ease-in-out infinite',
218
- }}
219
- />
220
- </div>
221
-
222
- {/* 动画样式 */}
223
- <style>{`
224
- @keyframes pulse {
225
- 0%, 100% {
226
- opacity: 1;
227
- transform: translate(-50%, -50%) scale(1);
228
- }
229
- 50% {
230
- opacity: 0.5;
231
- transform: translate(-50%, -50%) scale(1.1);
232
- }
233
- }
234
-
235
- @keyframes loading-progress {
236
- 0% {
237
- transform: translateX(-100%);
238
- }
239
- 50% {
240
- transform: translateX(0%);
241
- }
242
- 100% {
243
- transform: translateX(100%);
244
- }
245
- }
246
- `}</style>
247
- </div>
248
- );
249
- };
250
-
251
- // 移除未使用的 LoadingContainer
252
-
253
- const ErrorContainer = styled.div<{ $theme: Styles }>`
254
- display: flex;
255
- flex-direction: column;
256
- align-items: center;
257
- justify-content: center;
258
- height: 100%;
259
- color: ${props => props.$theme.colors.error};
260
- text-align: center;
261
- padding: 20px;
262
- `;
263
-
264
- // 默认配置
265
- const DEFAULT_STREAM_API_URL = 'http://10.15.12.13:9005/proxy/index/knowledgeBase/file/stream';
266
- const CACHE_EXPIRY_TIME = 5 * 60 * 1000; // 5分钟缓存过期
267
-
268
- // 默认主题
269
- const defaultTheme: Styles = {
270
- colors: {
271
- primary: '#007bff',
272
- secondary: '#6c757d',
273
- success: '#008000',
274
- warning: '#FFA500',
275
- error: '#FF0000',
276
- info: '#0000FF',
277
- background: '#f8f9fa',
278
- text: '#343a40',
279
- border: '#dee2e6',
280
- disabled: '#808080',
281
- disabledBackground: '#F5F5F5',
282
- disabledText: '#808080',
283
- },
284
- space: {
285
- sidebar: '12px',
286
- size: '12px',
287
- radius: '4px',
288
- padding: '8px 12px',
289
- margin: '4px',
290
- shadow: '0 2px 4px rgba(0,0,0,0.1)',
291
- lineHeight: '1.5',
292
- },
293
- };
294
-
295
- /**
296
- * 将 ArrayBuffer 按文本解码:优先 UTF-8,若出现大量替换字符则尝试 GB18030(常见中文编码),避免中文 txt 显示乱码
297
- */
298
- function decodeArrayBufferAsText(buffer: ArrayBuffer): string {
299
- const utf8 = new TextDecoder('utf-8', { fatal: false }).decode(buffer);
300
- const replacementCount = (utf8.match(/\uFFFD/g) || []).length;
301
- if (replacementCount === 0 || utf8.length < 20) return utf8;
302
- try {
303
- const gb = new TextDecoder('gb18030', { fatal: false }).decode(buffer);
304
- const gbReplacement = (gb.match(/\uFFFD/g) || []).length;
305
- return gbReplacement < replacementCount ? gb : utf8;
306
- } catch {
307
- return utf8;
308
- }
309
- }
310
-
311
- /**
312
- * GientechStreamReader组件
313
- * 基于stream接口的文件读取器,支持分页获取PDF数据并渲染
314
- * 遵循adopter_develop规范,使用HOC模式封装core组件
315
- *
316
- * @param props - 组件属性
317
- * @returns GientechStreamReader组件
318
- */
319
- const GientechStreamReader: React.FC<GientechStreamReaderProps> = ({
320
- convertedFilePath,
321
- fileName,
322
- fileType,
323
- csrfToken,
324
- initialPage = 1,
325
- initialZoom = 1, // 默认初始缩放比例为1
326
- totalPages: userTotalPages, // 接收用户传入的总页数
327
- annotations = [],
328
- pageSize = 5, // 更新默认值为5,与StreamPreview一致
329
- streamApiUrl = DEFAULT_STREAM_API_URL,
330
- authorization,
331
- eventsEmit = () => {},
332
- tools: userTools, // 接收用户传入的工具配置
333
- styles,
334
- customComponents,
335
- className,
336
- headerClass,
337
- contentClass,
338
- }) => {
339
- // 状态管理
340
- const [isLoading, setIsLoading] = useState(true); // 初始为loading状态
341
- const [loadingStatus, setLoadingStatus] = useState<string>('正在加载文档...'); // 加载提示文本
342
- const [error, setError] = useState<string | null>(null);
343
- const [currentPage, setCurrentPage] = useState(initialPage);
344
- const [totalPages, setTotalPages] = useState(userTotalPages || 0); // 使用用户传入的总页数,不自动覆盖
345
- const [scale, setScale] = useState(initialZoom);
346
- const [rotation, setRotation] = useState(0);
347
- const [pdfDocument, setPdfDocument] = useState<any>(null);
348
- const [imageContent, setImageContent] = useState<any>(null);
349
-
350
- // Markdown相关状态
351
- const [markdownContent, setMarkdownContent] = useState<string>('');
352
-
353
- // 通用文件内容状态
354
- const [textContent, setTextContent] = useState<any>(null);
355
- const [htmlContent, setHtmlContent] = useState<any>(null);
356
-
357
- // 通用文件缓存状态
358
- const [genericContentCache, setGenericContentCache] = useState<{
359
- [key: string]: { content: any; timestamp: number };
360
- }>({});
361
-
362
- // 防抖状态 - 防止重复请求
363
- const isGenericLoadingRef = useRef(false);
364
- const hasLoadedGenericRef = useRef(false);
365
-
366
- // 引用
367
- const pageCache = useRef<PageCache>({});
368
- const chunkCache = useRef<PageChunkCache>({});
369
- const markdownContentCache = useRef<MarkdownContentCache | null>(null);
370
- const scrollContainerRef = useRef<HTMLDivElement>(null);
371
- const currentPageRef = useRef<number>(initialPage); // 添加ref来跟踪当前页面
372
- // 调试:跟踪每次渲染计数(必须放在任何条件 return 之前,避免 Hook 次数不一致)
373
- const renderCountRef = useRef(0);
374
- renderCountRef.current += 1;
375
- console.log('[GientechStreamReader] render count:', renderCountRef.current);
376
- console.log('[GientechStreamReader] props snapshot (early):', {
377
- fileType,
378
- currentPage,
379
- totalPages,
380
- hasMarkdown: !!markdownContent,
381
- hasImage: !!imageContent,
382
- hasText: !!textContent,
383
- hasHtml: !!htmlContent,
384
- isLoading,
385
- error,
386
- });
387
-
388
- // 使用主题
389
- const mergedTheme = styles?.theme || defaultTheme;
390
-
391
- // 当文件类型或文件路径改变时,重置通用加载的防抖/已加载标记,避免影响其它文件类型
392
- useEffect(() => {
393
- isGenericLoadingRef.current = false;
394
- hasLoadedGenericRef.current = false;
395
- }, [fileType, convertedFilePath]);
396
-
397
- /**
398
- * 根据文件类型动态配置工具,并合并用户自定义配置
399
- */
400
- const getToolsConfig = useCallback((): ToolsConfig => {
401
- const baseTools = {
402
- annotation: true,
403
- download: true,
404
- zoom: true,
405
- close: true,
406
- navigation: true,
407
- rotate: false,
408
- };
409
-
410
- let defaultTools: ToolsConfig;
411
-
412
- switch (fileType) {
413
- case 'pdf':
414
- case 'pdf_slides':
415
- defaultTools = {
416
- ...baseTools,
417
- annotation: false, // PDF模式关闭标注功能
418
- download: false, // PDF模式关闭下载功能
419
- navigation: true, // PDF模式开启翻页导航
420
- rotate: false, // PDF模式关闭旋转功能
421
- };
422
- break;
423
- case 'image':
424
- defaultTools = {
425
- ...baseTools,
426
- annotation: false, // 图片模式关闭标注功能
427
- download: false, // 图片模式关闭下载功能
428
- navigation: false, // 图片模式关闭翻页导航
429
- rotate: true, // 图片模式开启旋转功能
430
- zoom: true,
431
- };
432
- break;
433
- case 'markdown':
434
- case 'markdown_table':
435
- defaultTools = {
436
- ...baseTools,
437
- annotation: false, // Markdown模式开启标注功能
438
- download: false, // Markdown模式关闭下载功能
439
- navigation: false, // Markdown模式关闭翻页导航
440
- rotate: false, // Markdown模式关闭旋转功能
441
- zoom: false, // Markdown模式关闭缩放功能
442
- };
443
- break;
444
- case 'text':
445
- case 'html':
446
- case 'unknown':
447
- defaultTools = {
448
- ...baseTools,
449
- annotation: false, // 其他模式关闭标注功能
450
- download: false, // 其他模式关闭下载功能
451
- navigation: false, // 其他模式关闭翻页导航
452
- rotate: false, // 其他模式关闭旋转功能
453
- zoom: false, // 其他模式关闭缩放功能
454
- };
455
- break;
456
- default:
457
- defaultTools = baseTools;
458
- }
459
-
460
- // 合并用户自定义配置,用户配置优先
461
- if (userTools) {
462
- return {
463
- ...defaultTools,
464
- ...userTools,
465
- };
466
- }
467
-
468
- return defaultTools;
469
- }, [fileType, userTools]);
470
-
471
- // 获取当前文件类型的工具配置
472
- const tools = getToolsConfig();
473
-
474
- /**
475
- * 计算chunk的key
476
- * @param pageNo 页码
477
- * @param pageSize 页面大小
478
- * @returns chunk key
479
- */
480
- const getChunkKey = useCallback((pageNo: number, pageSize: number): string => {
481
- const chunkStart = Math.floor((pageNo - 1) / pageSize) * pageSize + 1;
482
- return `${chunkStart}-${chunkStart + pageSize - 1}`;
483
- }, []);
484
-
485
- /**
486
- * 检查页面是否在缓存中,并返回解析后的PDF文档
487
- * @param pageNo 页码
488
- * @returns 缓存的PDF文档或null
489
- */
490
- const getCachedPage = useCallback(
491
- async (pageNo: number): Promise<any | null> => {
492
- // 根据文件类型决定处理方式
493
- const isPDF = fileType === 'pdf' || fileType === 'pdf_slides';
494
-
495
- if (!isPDF) {
496
- console.log(`文件类型 ${fileType} 不是PDF,跳过缓存检查`);
497
- return null;
498
- }
499
-
500
- console.log(`检查页面 ${pageNo} 是否在缓存中`);
501
-
502
- // 先检查单个页面缓存
503
- const pageCached = pageCache.current[pageNo];
504
- if (pageCached && Date.now() - pageCached.timestamp < CACHE_EXPIRY_TIME) {
505
- console.log(`使用单个页面缓存: ${pageNo}`);
506
- if (pageCached.pdfDocument) {
507
- console.log(`直接返回缓存的PDF文档: ${pageNo}`);
508
- return pageCached.pdfDocument;
509
- }
510
- // 如果没有缓存的PDF文档,需要重新解析
511
- return null;
512
- }
513
-
514
- // 检查chunk缓存
515
- const chunkKey = getChunkKey(pageNo, pageSize);
516
- const chunkCached = chunkCache.current[chunkKey];
517
- console.log(
518
- `检查chunk缓存: ${chunkKey}, 存在: ${!!chunkCached}, 包含页面: ${chunkCached?.pages?.join(', ') || '无'}`
519
- );
520
-
521
- if (chunkCached && Date.now() - chunkCached.timestamp < CACHE_EXPIRY_TIME) {
522
- // 验证页面是否真的在这个chunk中
523
- if (chunkCached.pages.includes(pageNo)) {
524
- console.log(`使用chunk缓存: ${pageNo} (chunk: ${chunkKey})`);
525
- if (chunkCached.pdfDocument) {
526
- console.log(`直接返回缓存的PDF文档: ${pageNo}`);
527
- return chunkCached.pdfDocument;
528
- }
529
- // 如果没有缓存的PDF文档,需要重新解析
530
- return null;
531
- } else {
532
- console.log(
533
- `页面 ${pageNo} 不在chunk ${chunkKey} 中,chunk包含: ${chunkCached.pages.join(', ')}`
534
- );
535
- }
536
- }
537
-
538
- console.log(`页面 ${pageNo} 不在任何缓存中,需要重新请求`);
539
- return null;
540
- },
541
- [pageSize, getChunkKey, fileType]
542
- );
543
-
544
- /**
545
- * 获取stream数据(仅用于PDF文件)
546
- * @param pageNo 页码
547
- * @returns Promise<ArrayBuffer>
548
- */
549
- const fetchStreamData = useCallback(
550
- async (pageNo: number): Promise<ArrayBuffer> => {
551
- try {
552
- // 根据文件类型决定是否传递分页参数
553
- const isPDF = fileType === 'pdf' || fileType === 'pdf_slides';
554
-
555
- if (!isPDF) {
556
- console.log(`文件类型 ${fileType} 不需要分页参数,获取完整内容`);
557
- throw new Error(`文件类型 ${fileType} 不支持分页加载`);
558
- }
559
-
560
- // 计算需要请求的chunk
561
- const chunkStart = Math.floor((pageNo - 1) / pageSize) * pageSize + 1;
562
- const chunkKey = getChunkKey(pageNo, pageSize);
563
-
564
- console.log(
565
- `请求PDF chunk数据: ${chunkStart} (包含页面 ${chunkStart}-${chunkStart + pageSize - 1})`
566
- );
567
-
568
- const headers: Record<string, string> = {
569
- 'Content-Type': 'application/json',
570
- };
571
-
572
- if (authorization) {
573
- headers['Authorization'] = authorization;
574
- }
575
-
576
- if (csrfToken) {
577
- headers['X-CSRF-TOKEN-IN'] = csrfToken;
578
- }
579
-
580
- // PDF文件类型传递分页参数
581
- const requestData = {
582
- convertedFilePath,
583
- pageNo: chunkStart, // 使用chunk的起始页
584
- pageSize,
585
- };
586
-
587
- const response = await axios.post<ArrayBuffer>(streamApiUrl, requestData, {
588
- headers,
589
- responseType: 'arraybuffer',
590
- });
591
-
592
- // 获取响应头中的CSRF Token并触发事件
593
- const responseCsrfToken =
594
- response.headers['x-csrf-token-out'] || response.headers['X-CSRF-TOKEN-OUT'];
595
- if (responseCsrfToken) {
596
- console.log('获取到响应头中的CSRF Token:', responseCsrfToken);
597
- eventsEmit('request_finish', responseCsrfToken);
598
- }
599
-
600
- // 缓存chunk数据
601
- const chunkPages = Array.from({ length: pageSize }, (_, i) => chunkStart + i);
602
- chunkCache.current[chunkKey] = {
603
- data: response.data,
604
- pages: chunkPages,
605
- timestamp: Date.now(),
606
- totalPages: userTotalPages, // 始终使用用户传入的总页数,不覆盖
607
- };
608
-
609
- console.log(
610
- `缓存PDF chunk数据: ${chunkKey}, 包含页面: ${chunkPages.join(', ')}, 请求的页面: ${pageNo}`
611
- );
612
- console.log(`当前所有缓存:`, Object.keys(chunkCache.current));
613
-
614
- return response.data;
615
- } catch (error: any) {
616
- console.error('获取PDF stream数据失败:', error);
617
- throw new Error(`PDF请求失败: ${error.response?.status || '网络错误'}`);
618
- }
619
- },
620
- [
621
- streamApiUrl,
622
- convertedFilePath,
623
- pageSize,
624
- authorization,
625
- getChunkKey,
626
- userTotalPages,
627
- totalPages,
628
- fileType,
629
- eventsEmit,
630
- ]
631
- );
632
-
633
- /**
634
- * 加载PDF文档(仅用于PDF文件类型)
635
- * @param pageNo 页码
636
- * @param isInitialLoad 是否为初始加载
637
- */
638
- const loadPDFDocument = useCallback(
639
- async (pageNo: number, isInitialLoad: boolean = false) => {
640
- if (!pageNo) return;
641
-
642
- // 根据文件类型决定处理方式
643
- const isPDF = fileType === 'pdf' || fileType === 'pdf_slides';
644
-
645
- if (!isPDF) {
646
- console.log(`文件类型 ${fileType} 不是PDF,跳过PDF加载逻辑`);
647
- return null; // 直接返回,不进行任何操作
648
- }
649
-
650
- try {
651
- if (isInitialLoad) {
652
- setIsLoading(true);
653
- setLoadingStatus('正在加载PDF文档...');
654
- } else {
655
- setIsLoading(true);
656
- setLoadingStatus(`正在加载第 ${pageNo} 页...`);
657
- }
658
- setError(null);
659
-
660
- console.log(`开始加载PDF页面: ${pageNo}, 初始加载: ${isInitialLoad}`);
661
-
662
- // 先检查缓存
663
- const cachedPdf = await getCachedPage(pageNo);
664
- if (cachedPdf) {
665
- // 如果缓存中有PDF文档,直接使用,无需重新解析
666
- console.log(`使用缓存的PDF文档: ${pageNo}`);
667
- setPdfDocument(cachedPdf);
668
- setIsLoading(false);
669
- setLoadingStatus('');
670
- console.log(`页面 ${pageNo} 加载完成(使用缓存)`);
671
- return cachedPdf;
672
- }
673
-
674
- // 获取stream数据
675
- const streamData = await fetchStreamData(pageNo);
676
-
677
- // 使用fileParser解析数据
678
- const parseResult: ParseResult = await parseFile(streamData, {
679
- fileName: fileName || 'Stream文档',
680
- fileType: 'pdf',
681
- token: authorization,
682
- });
683
-
684
- if (parseResult.error) {
685
- throw new Error(parseResult.error);
686
- }
687
-
688
- if (parseResult.type !== 'pdf' || !parseResult.content?.document) {
689
- throw new Error('解析结果不是有效的PDF文档');
690
- }
691
-
692
- const pdf = parseResult.content.document;
693
- console.log('设置PDF文档:', pdf);
694
- console.log('PDF文档类型:', typeof pdf);
695
- console.log(
696
- 'PDF文档方法:',
697
- pdf ? Object.getOwnPropertyNames(Object.getPrototypeOf(pdf)) : '无文档'
698
- );
699
- console.log('PDF文档页数:', pdf ? pdf.numPages : '无页数');
700
- console.log('当前请求的页面:', pageNo);
701
- console.log('PDF文档包含的页面范围:', pdf ? `1-${pdf.numPages}` : '无页数');
702
- setPdfDocument(pdf);
703
-
704
- // 缓存解析后的PDF文档
705
- const chunkKey = getChunkKey(pageNo, pageSize);
706
- if (chunkCache.current[chunkKey]) {
707
- chunkCache.current[chunkKey].pdfDocument = pdf;
708
- console.log(`缓存PDF文档到chunk: ${chunkKey}`);
709
- }
710
-
711
- // 设置总页数 - 优先使用用户传入的总页数,如果没有传入则使用PDF文档的实际页数
712
- if (userTotalPages) {
713
- console.log(`使用用户传入的总页数: ${userTotalPages}`);
714
- setTotalPages(userTotalPages);
715
- } else if (pdf && pdf.numPages) {
716
- const actualTotalPages = pdf.numPages;
717
- console.log(`用户未传入总页数,从PDF文档获取实际总页数: ${actualTotalPages}`);
718
- setTotalPages(actualTotalPages);
719
- }
720
-
721
- setIsLoading(false);
722
- setLoadingStatus('');
723
-
724
- console.log(`页面 ${pageNo} 加载完成`);
725
- return pdf;
726
- } catch (error: any) {
727
- console.error('PDF加载失败:', error);
728
- setError(error.message || 'PDF加载失败,请稍后重试');
729
- setIsLoading(false);
730
- setLoadingStatus('');
731
- throw error;
732
- }
733
- },
734
- [
735
- fetchStreamData,
736
- fileName,
737
- authorization,
738
- totalPages,
739
- getCachedPage,
740
- getChunkKey,
741
- pageSize,
742
- fileType,
743
- ]
744
- );
745
-
746
- /**
747
- * 检查页面是否在缓存中(用于调试)
748
- */
749
- const isPageInCache = useCallback(
750
- (pageNo: number): boolean => {
751
- // 根据文件类型决定处理方式
752
- const isPDF = fileType === 'pdf' || fileType === 'pdf_slides';
753
-
754
- if (!isPDF) {
755
- return false;
756
- }
757
-
758
- // 先检查单个页面缓存
759
- const pageCached = pageCache.current[pageNo];
760
- if (pageCached && Date.now() - pageCached.timestamp < CACHE_EXPIRY_TIME) {
761
- return !!pageCached.pdfDocument;
762
- }
763
-
764
- // 检查chunk缓存
765
- const chunkKey = getChunkKey(pageNo, pageSize);
766
- const chunkCached = chunkCache.current[chunkKey];
767
- if (chunkCached && Date.now() - chunkCached.timestamp < CACHE_EXPIRY_TIME) {
768
- return chunkCached.pages.includes(pageNo) && !!chunkCached.pdfDocument;
769
- }
770
-
771
- return false;
772
- },
773
- [pageSize, getChunkKey, fileType]
774
- );
775
-
776
- // ========== Markdown相关工具函数 ==========
777
-
778
- /**
779
- * 检查markdown内容是否在缓存中
780
- * @returns 缓存的内容或null
781
- */
782
- const getCachedMarkdownContent = useCallback((): string | null => {
783
- console.log('检查markdown内容是否在缓存中');
784
-
785
- const cached = markdownContentCache.current;
786
- if (cached && Date.now() - cached.timestamp < CACHE_EXPIRY_TIME) {
787
- console.log('使用markdown内容缓存');
788
- return cached.data;
789
- }
790
-
791
- console.log('markdown内容不在缓存中,需要重新请求');
792
- return null;
793
- }, []);
794
-
795
- /**
796
- * 获取完整markdown数据
797
- * @returns Promise<string>
798
- */
799
- const fetchMarkdownData = useCallback(async (): Promise<string> => {
800
- try {
801
- console.log('请求完整markdown数据');
802
-
803
- const headers: Record<string, string> = {
804
- 'Content-Type': 'application/json',
805
- };
806
-
807
- if (authorization) {
808
- headers['Authorization'] = authorization;
809
- }
810
-
811
- if (csrfToken) {
812
- headers['X-CSRF-TOKEN-IN'] = csrfToken;
813
- }
814
-
815
- const requestData = {
816
- convertedFilePath,
817
- // 不传pageNo和pageSize,获取完整文章
818
- };
819
-
820
- console.log('发送markdown请求:', requestData);
821
-
822
- const response = await axios.post(streamApiUrl, requestData, {
823
- headers,
824
- responseType: 'text', // markdown返回文本
825
- });
826
-
827
- // 获取响应头中的CSRF Token并触发事件
828
- const responseCsrfToken =
829
- response.headers['x-csrf-token-out'] || response.headers['X-CSRF-TOKEN-OUT'];
830
- if (responseCsrfToken) {
831
- console.log('获取到响应头中的CSRF Token:', responseCsrfToken);
832
- eventsEmit('request_finish', responseCsrfToken);
833
- }
834
-
835
- console.log('markdown响应状态:', response.status);
836
- console.log('markdown响应数据长度:', response.data?.length || 0);
837
-
838
- return response.data;
839
- } catch (error: any) {
840
- console.error('获取markdown数据失败:', error);
841
- throw new Error(`获取markdown数据失败: ${error.message}`);
842
- }
843
- }, [convertedFilePath, authorization, streamApiUrl, eventsEmit]);
844
-
845
- /**
846
- * 加载完整markdown文档
847
- * @returns Promise<string>
848
- */
849
- const loadMarkdownDocument = useCallback(async () => {
850
- try {
851
- setIsLoading(true);
852
- setLoadingStatus('正在加载markdown文档...');
853
- setError(null);
854
-
855
- console.log('开始加载完整markdown文档');
856
-
857
- // 先检查缓存
858
- const cachedContent = getCachedMarkdownContent();
859
- if (cachedContent) {
860
- console.log('使用缓存的markdown内容');
861
- setMarkdownContent(cachedContent);
862
- setIsLoading(false);
863
- setLoadingStatus('');
864
- return cachedContent;
865
- }
866
-
867
- // 获取完整数据
868
- const streamData = await fetchMarkdownData();
869
-
870
- // 缓存markdown内容
871
- markdownContentCache.current = {
872
- data: streamData,
873
- timestamp: Date.now(),
874
- };
875
-
876
- setMarkdownContent(streamData);
877
- setIsLoading(false);
878
- setLoadingStatus('');
879
- console.log('完整markdown文档加载完成');
880
- return streamData;
881
- } catch (error: any) {
882
- console.error('markdown加载失败:', error);
883
- setError(error.message || 'markdown加载失败,请稍后重试');
884
- setIsLoading(false);
885
- setLoadingStatus('');
886
- throw error;
887
- }
888
- }, [fetchMarkdownData, getCachedMarkdownContent]);
889
-
890
- /**
891
- * 获取完整图片数据(以与PDF/Markdown一致的请求方式)
892
- */
893
- const fetchImageData = useCallback(async (): Promise<ArrayBuffer> => {
894
- try {
895
- const headers: Record<string, string> = {
896
- 'Content-Type': 'application/json',
897
- };
898
-
899
- if (authorization) {
900
- headers['Authorization'] = authorization;
901
- }
902
-
903
- if (csrfToken) {
904
- headers['X-CSRF-TOKEN-IN'] = csrfToken;
905
- }
906
-
907
- const requestData = {
908
- convertedFilePath,
909
- // 不传 pageNo/pageSize,获取完整图片二进制
910
- };
911
-
912
- const response = await axios.post<ArrayBuffer>(streamApiUrl, requestData, {
913
- headers,
914
- responseType: 'arraybuffer',
915
- });
916
-
917
- // 获取响应头中的CSRF Token并触发事件
918
- const responseCsrfToken =
919
- response.headers['x-csrf-token-out'] || response.headers['X-CSRF-TOKEN-OUT'];
920
- if (responseCsrfToken) {
921
- console.log('获取到响应头中的CSRF Token:', responseCsrfToken);
922
- eventsEmit('request_finish', responseCsrfToken);
923
- }
924
-
925
- return response.data;
926
- } catch (error: any) {
927
- console.error('获取图片数据失败:', error);
928
- throw new Error(`获取图片数据失败: ${error.message}`);
929
- }
930
- }, [convertedFilePath, authorization, streamApiUrl, eventsEmit]);
931
-
932
- /**
933
- * 加载图片文档
934
- */
935
- const loadImageDocument = useCallback(async () => {
936
- try {
937
- setIsLoading(true);
938
- setLoadingStatus('正在加载图片...');
939
- setError(null);
940
-
941
- const imgBuffer = await fetchImageData();
942
-
943
- const parseResult: ParseResult = await parseFile(imgBuffer, {
944
- fileName: fileName || '图片',
945
- fileType: 'image',
946
- token: authorization,
947
- });
948
-
949
- if (parseResult.error) {
950
- throw new Error(parseResult.error);
951
- }
952
-
953
- if (parseResult.type !== 'image' || !parseResult.content) {
954
- throw new Error('解析结果不是有效的图片');
955
- }
956
-
957
- setImageContent(parseResult.content); // { type: 'image', url }
958
- setIsLoading(false);
959
- setLoadingStatus('');
960
- return parseResult.content;
961
- } catch (error: any) {
962
- console.error('图片加载失败:', error);
963
- setError(error.message || '图片加载失败,请稍后重试');
964
- setIsLoading(false);
965
- setLoadingStatus('');
966
- throw error;
967
- }
968
- }, [authorization, fileName, fetchImageData]);
969
-
970
- /**
971
- * 获取通用文件数据(用于html、text、unknown等文件类型)
972
- * 所有文件类型都使用同样的接口,只是非PDF类型不传分页参数
973
- * @returns Promise<ArrayBuffer>
974
- */
975
- const fetchGenericData = useCallback(async (): Promise<ArrayBuffer> => {
976
- try {
977
- console.log(`请求通用文件数据,文件类型: ${fileType}`);
978
-
979
- const headers: Record<string, string> = {
980
- 'Content-Type': 'application/json',
981
- };
982
-
983
- if (authorization) {
984
- headers['Authorization'] = authorization;
985
- }
986
-
987
- if (csrfToken) {
988
- headers['X-CSRF-TOKEN-IN'] = csrfToken;
989
- }
990
-
991
- const requestData = {
992
- convertedFilePath,
993
- // 非PDF文件类型不传pageNo和pageSize,获取完整文件内容
994
- };
995
-
996
- console.log('发送通用文件请求:', requestData);
997
-
998
- const response = await axios.post<ArrayBuffer>(streamApiUrl, requestData, {
999
- headers,
1000
- responseType: 'arraybuffer',
1001
- });
1002
-
1003
- // 获取响应头中的CSRF Token并触发事件
1004
- const responseCsrfToken =
1005
- response.headers['x-csrf-token-out'] || response.headers['X-CSRF-TOKEN-OUT'];
1006
- if (responseCsrfToken) {
1007
- console.log('获取到响应头中的CSRF Token:', responseCsrfToken);
1008
- eventsEmit('request_finish', responseCsrfToken);
1009
- }
1010
-
1011
- console.log('通用文件响应状态:', response.status);
1012
- console.log('通用文件响应数据长度:', response.data?.byteLength || 0);
1013
-
1014
- return response.data;
1015
- } catch (error: any) {
1016
- console.error('获取通用文件数据失败:', error);
1017
- throw new Error(`获取通用文件数据失败: ${error.message}`);
1018
- }
1019
- }, [convertedFilePath, authorization, streamApiUrl, eventsEmit]);
1020
-
1021
- /**
1022
- * 加载通用文件文档(用于html、text、unknown等文件类型)
1023
- */
1024
- const loadGenericDocument = useCallback(async () => {
1025
- try {
1026
- console.log(`=== loadGenericDocument 被调用 ===`);
1027
- console.log(`调用栈:`, new Error().stack);
1028
- console.log(`当前时间:`, new Date().toISOString());
1029
-
1030
- // 防抖检查 - 如果正在加载中,直接返回
1031
- if (isGenericLoadingRef.current) {
1032
- console.log(`通用文档正在加载中,忽略重复请求,文件类型: ${fileType}`);
1033
- return;
1034
- }
1035
-
1036
- // 如果已经加载过,直接返回
1037
- if (hasLoadedGenericRef.current) {
1038
- console.log(`通用文档已经加载过,忽略重复请求,文件类型: ${fileType}`);
1039
- return;
1040
- }
1041
-
1042
- // 检查缓存
1043
- const cacheKey = `${fileType}_${convertedFilePath}`;
1044
- const cached = genericContentCache[cacheKey];
1045
- console.log(
1046
- `检查通用文档缓存,key: ${cacheKey}, 缓存存在: ${!!cached}, 缓存时间: ${cached ? Date.now() - cached.timestamp : 'N/A'}ms`
1047
- );
1048
-
1049
- if (cached && Date.now() - cached.timestamp < CACHE_EXPIRY_TIME) {
1050
- console.log(`使用缓存的通用文档内容,文件类型: ${fileType}`);
1051
-
1052
- // 根据文件类型设置相应的状态
1053
- if (fileType === 'text' && cached.content) {
1054
- setTextContent(cached.content);
1055
- } else if (fileType === 'html' && cached.content) {
1056
- setHtmlContent(cached.content);
1057
- }
1058
-
1059
- setCurrentPage(1);
1060
- // 优先使用用户传入的总页数,如果没有则设为1
1061
- setTotalPages(userTotalPages || 1);
1062
- setIsLoading(false);
1063
- setLoadingStatus('');
1064
- return cached.content;
1065
- }
1066
-
1067
- // 设置防抖状态
1068
- isGenericLoadingRef.current = true;
1069
- setIsLoading(true);
1070
- setLoadingStatus(`正在加载${fileType}文档...`);
1071
- setError(null);
1072
-
1073
- console.log(`开始加载通用文档,文件类型: ${fileType}`);
1074
-
1075
- // 获取通用文件数据
1076
- const fileData = await fetchGenericData();
1077
-
1078
- // 显式传入 text 时不再调用 parseFile,避免 fviewer 根据 fileName 误判为 PDF 导致 Invalid PDF structure
1079
- if (fileType === 'text') {
1080
- const textContent = decodeArrayBufferAsText(fileData);
1081
- const finalContent = { type: 'text' as const, content: textContent };
1082
- setTextContent(finalContent);
1083
- const cacheKeyForText = `text_${convertedFilePath}`;
1084
- setGenericContentCache((prev) => ({
1085
- ...prev,
1086
- [cacheKeyForText]: { content: finalContent, timestamp: Date.now() },
1087
- }));
1088
- setIsLoading(false);
1089
- setLoadingStatus('');
1090
- isGenericLoadingRef.current = false;
1091
- hasLoadedGenericRef.current = true;
1092
- console.log(`通用文档加载完成(text 直解),文件类型: ${fileType}`);
1093
- return finalContent;
1094
- }
1095
-
1096
- // 使用 fileParser 解析 html / unknown 等
1097
- const parseResult: ParseResult = await parseFile(fileData, {
1098
- fileName: fileName || `${fileType}文档`,
1099
- fileType: fileType as any,
1100
- token: authorization,
1101
- });
1102
-
1103
- if (parseResult.error) {
1104
- throw new Error(parseResult.error);
1105
- }
1106
-
1107
- // 根据解析结果设置相应的状态
1108
- let finalContent = null;
1109
- if (parseResult.type === 'text' && parseResult.content) {
1110
- setTextContent(parseResult.content);
1111
- finalContent = parseResult.content;
1112
- } else if (parseResult.type === 'html' && parseResult.content) {
1113
- setHtmlContent(parseResult.content);
1114
- finalContent = parseResult.content;
1115
- } else if (parseResult.type === 'image' && parseResult.content) {
1116
- setImageContent(parseResult.content);
1117
- finalContent = parseResult.content;
1118
- } else {
1119
- // 如果解析失败,尝试作为文本处理(带编码回退,避免中文乱码)
1120
- const textContent = decodeArrayBufferAsText(fileData);
1121
- setTextContent({ type: 'text', content: textContent });
1122
- finalContent = { type: 'text', content: textContent };
1123
- }
1124
-
1125
- // 保存到缓存
1126
- if (finalContent) {
1127
- const cacheKey = `${fileType}_${convertedFilePath}`;
1128
- const newCache = {
1129
- ...genericContentCache,
1130
- [cacheKey]: {
1131
- content: finalContent,
1132
- timestamp: Date.now(),
1133
- },
1134
- };
1135
- setGenericContentCache(newCache);
1136
- console.log(`通用文档内容已缓存,文件类型: ${fileType}, 缓存键: ${cacheKey}`);
1137
- console.log(`当前缓存状态:`, newCache);
1138
- }
1139
-
1140
- setIsLoading(false);
1141
- setLoadingStatus('');
1142
- isGenericLoadingRef.current = false; // 清除防抖状态
1143
- hasLoadedGenericRef.current = true; // 标记已加载
1144
- console.log(`通用文档加载完成,文件类型: ${fileType}`);
1145
- return parseResult;
1146
- } catch (error: any) {
1147
- console.error('通用文档加载失败:', error);
1148
- setError(error.message || '通用文档加载失败,请稍后重试');
1149
- setIsLoading(false);
1150
- setLoadingStatus('');
1151
- isGenericLoadingRef.current = false; // 清除防抖状态
1152
- hasLoadedGenericRef.current = true; // 标记已加载(即使失败也标记,避免无限重试)
1153
- throw error;
1154
- }
1155
- }, [fetchGenericData, fileName, authorization, fileType, convertedFilePath, genericContentCache, userTotalPages]);
1156
-
1157
- // 移除markdown滚动事件处理,不再支持分块加载
1158
-
1159
- /**
1160
- * 处理页面变化(仅用于PDF文件类型)
1161
- */
1162
- const handlePageChange = useCallback(
1163
- async (pageNumber: number) => {
1164
- if (pageNumber === currentPageRef.current) return;
1165
- if (isLoading) {
1166
- console.log('页面正在加载中,忽略翻页请求');
1167
- return;
1168
- }
1169
-
1170
- // 根据文件类型决定处理方式
1171
- const isPDF = fileType === 'pdf' || fileType === 'pdf_slides';
1172
-
1173
- if (!isPDF) {
1174
- console.log(`文件类型 ${fileType} 不支持翻页,忽略翻页请求`);
1175
- return; // 直接返回,不进行任何操作
1176
- }
1177
-
1178
- console.log('PDF页面变化:', pageNumber, '当前页:', currentPageRef.current);
1179
- console.log(`页面 ${pageNumber} 是否在缓存中:`, isPageInCache(pageNumber));
1180
-
1181
- // 更新ref和state
1182
- currentPageRef.current = pageNumber;
1183
- setCurrentPage(pageNumber);
1184
-
1185
- try {
1186
- await loadPDFDocument(pageNumber, false); // 非初始加载
1187
- // 优先使用用户传入的总页数
1188
- const finalTotalPages = userTotalPages || totalPages;
1189
- eventsEmit('pageChange', { pageNumber, totalPages: finalTotalPages });
1190
- } catch (error) {
1191
- console.error('PDF页面加载失败:', error);
1192
- // 加载失败时恢复当前页
1193
- const originalPage = currentPageRef.current;
1194
- setCurrentPage(originalPage);
1195
- }
1196
- },
1197
- [loadPDFDocument, totalPages, eventsEmit, isPageInCache, isLoading, fileType]
1198
- );
1199
-
1200
- // 添加useEffect来监听currentPage变化,确保状态同步
1201
- useEffect(() => {
1202
- currentPageRef.current = currentPage;
1203
- console.log('当前页状态更新:', currentPage);
1204
- }, [currentPage]);
1205
-
1206
- /**
1207
- * 处理缩放变化
1208
- */
1209
- const handleZoomChange = useCallback(
1210
- (newScale: number) => {
1211
- setScale(newScale);
1212
- eventsEmit('zoomChange', { scale: newScale });
1213
- },
1214
- [eventsEmit]
1215
- );
1216
-
1217
- /**
1218
- * 处理关闭
1219
- */
1220
- const handleClose = useCallback(() => {
1221
- eventsEmit('viewer:close');
1222
- }, [eventsEmit]);
1223
-
1224
- /**
1225
- * 处理放大
1226
- */
1227
- const handleZoomIn = useCallback(() => {
1228
- const newScale = Math.min(3, scale + 0.1);
1229
- handleZoomChange(newScale);
1230
- }, [scale, handleZoomChange]);
1231
-
1232
- /**
1233
- * 处理缩小
1234
- */
1235
- const handleZoomOut = useCallback(() => {
1236
- const newScale = Math.max(0.3, scale - 0.1);
1237
- handleZoomChange(newScale);
1238
- }, [scale, handleZoomChange]);
1239
-
1240
- /**
1241
- * 处理左旋转(仅图片)
1242
- */
1243
- const handleRotateLeft = useCallback(() => {
1244
- const newRotation = (rotation - 90 + 360) % 360;
1245
- setRotation(newRotation);
1246
- eventsEmit('rotateChange', { rotation: newRotation });
1247
- }, [rotation, eventsEmit]);
1248
-
1249
- /**
1250
- * 处理右旋转(仅图片)
1251
- */
1252
- const handleRotateRight = useCallback(() => {
1253
- const newRotation = (rotation + 90) % 360;
1254
- setRotation(newRotation);
1255
- eventsEmit('rotateChange', { rotation: newRotation });
1256
- }, [rotation, eventsEmit]);
1257
-
1258
- /**
1259
- * 处理上一页(仅用于PDF文件类型)
1260
- */
1261
- const handlePrevPage = useCallback(() => {
1262
- // 根据文件类型决定处理方式
1263
- const isPDF = fileType === 'pdf' || fileType === 'pdf_slides';
1264
-
1265
- if (!isPDF) {
1266
- console.log(`文件类型 ${fileType} 不支持翻页,忽略翻页请求`);
1267
- return; // 直接返回,不进行任何操作
1268
- }
1269
-
1270
- const prevPage = currentPageRef.current - 1;
1271
- if (prevPage >= 1) {
1272
- handlePageChange(prevPage);
1273
- }
1274
- }, [handlePageChange, fileType]);
1275
-
1276
- /**
1277
- * 处理下一页(仅用于PDF文件类型)
1278
- */
1279
- const handleNextPage = useCallback(() => {
1280
- // 根据文件类型决定处理方式
1281
- const isPDF = fileType === 'pdf' || fileType === 'pdf_slides';
1282
-
1283
- if (!isPDF) {
1284
- console.log(`文件类型 ${fileType} 不支持翻页,忽略翻页请求`);
1285
- return; // 直接返回,不进行任何操作
1286
- }
1287
-
1288
- const nextPage = currentPageRef.current + 1;
1289
- // 优先使用用户传入的总页数
1290
- const finalTotalPages = userTotalPages || totalPages;
1291
- if (finalTotalPages && nextPage <= finalTotalPages) {
1292
- handlePageChange(nextPage);
1293
- }
1294
- }, [totalPages, handlePageChange, fileType]);
1295
-
1296
- /**
1297
- * 清理过期缓存
1298
- */
1299
- const cleanupExpiredCache = useCallback(() => {
1300
- const now = Date.now();
1301
-
1302
- // 清理单个页面缓存
1303
- Object.keys(pageCache.current).forEach(pageNo => {
1304
- const page = pageCache.current[parseInt(pageNo)];
1305
- if (now - page.timestamp > CACHE_EXPIRY_TIME) {
1306
- delete pageCache.current[parseInt(pageNo)];
1307
- console.log(`清理过期页面缓存: ${pageNo}`);
1308
- }
1309
- });
1310
-
1311
- // 清理chunk缓存
1312
- Object.keys(chunkCache.current).forEach(chunkKey => {
1313
- const chunk = chunkCache.current[chunkKey];
1314
- if (now - chunk.timestamp > CACHE_EXPIRY_TIME) {
1315
- delete chunkCache.current[chunkKey];
1316
- console.log(`清理过期chunk缓存: ${chunkKey}`);
1317
- }
1318
- });
1319
-
1320
- // 清理markdown内容缓存
1321
- if (
1322
- markdownContentCache.current &&
1323
- now - markdownContentCache.current.timestamp > CACHE_EXPIRY_TIME
1324
- ) {
1325
- markdownContentCache.current = null;
1326
- console.log('清理过期markdown内容缓存');
1327
- }
1328
-
1329
- // 清理通用文件缓存
1330
- setGenericContentCache(prev => {
1331
- const newCache = { ...prev };
1332
- Object.keys(newCache).forEach(key => {
1333
- if (now - newCache[key].timestamp > CACHE_EXPIRY_TIME) {
1334
- delete newCache[key];
1335
- console.log(`清理过期通用文件缓存: ${key}`);
1336
- }
1337
- });
1338
- return newCache;
1339
- });
1340
- }, []);
1341
-
1342
- /**
1343
- * 获取文件名
1344
- */
1345
- const getFileName = useCallback(() => {
1346
- if (fileName) return fileName;
1347
- try {
1348
- const urlObj = new URL(convertedFilePath);
1349
- const fileNameFromUrl = decodeURIComponent(urlObj.pathname.split('/').pop() || '');
1350
- return fileNameFromUrl || 'Stream文档';
1351
- } catch {
1352
- const pathParts = convertedFilePath.split('/');
1353
- return decodeURIComponent(pathParts[pathParts.length - 1]) || 'Stream文档';
1354
- }
1355
- }, [convertedFilePath, fileName]);
1356
-
1357
- // 定期清理过期缓存
1358
- useEffect(() => {
1359
- const cleanupInterval = setInterval(cleanupExpiredCache, CACHE_EXPIRY_TIME);
1360
- return () => clearInterval(cleanupInterval);
1361
- }, [cleanupExpiredCache]);
1362
-
1363
- // 组件卸载时清理缓存
1364
- useEffect(() => {
1365
- return () => {
1366
- pageCache.current = {};
1367
- chunkCache.current = {};
1368
- markdownContentCache.current = null;
1369
- setGenericContentCache({});
1370
- console.log('组件卸载,清理所有缓存');
1371
- };
1372
- }, []);
1373
-
1374
- // 初始加载
1375
- useEffect(() => {
1376
- console.log(`=== useEffect 被触发 ===`);
1377
- console.log(`触发时间:`, new Date().toISOString());
1378
- console.log(`触发原因:`, { initialPage, fileType });
1379
-
1380
- const loadInitialPage = async () => {
1381
- try {
1382
- // 根据文件类型决定是否使用翻页参数
1383
- const isPDF = fileType === 'pdf' || fileType === 'pdf_slides';
1384
- const effectivePage = isPDF ? initialPage || 1 : 1;
1385
- console.log(
1386
- '开始初始加载,文件类型:',
1387
- fileType,
1388
- '有效页码:',
1389
- effectivePage,
1390
- '是否PDF:',
1391
- isPDF
1392
- );
1393
-
1394
- if (fileType === 'markdown' || fileType === 'markdown_table') {
1395
- // Markdown文件加载完整内容,忽略翻页参数
1396
- await loadMarkdownDocument();
1397
- setCurrentPage(1);
1398
- // 优先使用用户传入的总页数,如果没有则设为1
1399
- setTotalPages(userTotalPages || 1);
1400
- eventsEmit('pageChange', { pageNumber: 1, totalPages: userTotalPages || 1 });
1401
- } else if (fileType === 'image') {
1402
- // 图片文件加载,忽略翻页参数
1403
- await loadImageDocument();
1404
- setCurrentPage(1);
1405
- // 优先使用用户传入的总页数,如果没有则设为1
1406
- setTotalPages(userTotalPages || 1);
1407
- setRotation(0);
1408
- eventsEmit('pageChange', { pageNumber: 1, totalPages: userTotalPages || 1 });
1409
- } else if (isPDF) {
1410
- // 只有PDF文件使用页面加载和翻页参数
1411
- await loadPDFDocument(effectivePage, true);
1412
- setCurrentPage(effectivePage);
1413
- // 等待 totalPages 更新后再触发事件,优先使用用户传入的值
1414
- setTimeout(() => {
1415
- const finalTotalPages = userTotalPages || totalPages;
1416
- eventsEmit('pageChange', { pageNumber: effectivePage, totalPages: finalTotalPages });
1417
- }, 0);
1418
- } else {
1419
- // 其他文件类型(text, html, unknown等)使用通用加载函数,忽略翻页参数
1420
- console.log('=== 初始加载:使用通用加载函数处理文件类型 ===', fileType);
1421
- await loadGenericDocument();
1422
- setCurrentPage(1);
1423
- // 优先使用用户传入的总页数,如果没有则设为1
1424
- setTotalPages(userTotalPages || 1);
1425
- eventsEmit('pageChange', { pageNumber: 1, totalPages: userTotalPages || 1 });
1426
- }
1427
- } catch (error: any) {
1428
- console.error('初始加载失败:', error);
1429
- // 确保错误状态被正确设置,避免组件状态不一致
1430
- setError(error?.message || '文件加载失败,请稍后重试');
1431
- setIsLoading(false);
1432
- setLoadingStatus('');
1433
- }
1434
- };
1435
-
1436
- loadInitialPage();
1437
- }, [initialPage, fileType, convertedFilePath]);
1438
-
1439
- // 所有 hooks 必须在条件返回之前调用
1440
- const pdfStartPage = useMemo(() => {
1441
- return Math.floor((currentPage - 1) / pageSize) * pageSize + 1;
1442
- }, [currentPage, pageSize]);
1443
-
1444
- if (error) {
1445
- return (
1446
- <ReaderContainer $theme={mergedTheme} className={className}>
1447
- {customComponents?.ErrorComponent ? (
1448
- <customComponents.ErrorComponent error={error} theme={mergedTheme} />
1449
- ) : (
1450
- <ErrorContainer $theme={mergedTheme}>
1451
- <div>加载失败</div>
1452
- <div style={{ fontSize: '12px', marginTop: '8px' }}>{error}</div>
1453
- </ErrorContainer>
1454
- )}
1455
- </ReaderContainer>
1456
- );
1457
- }
1458
-
1459
- // 渲染加载状态
1460
- if (isLoading) {
1461
- return (
1462
- <ReaderContainer $theme={mergedTheme} className={className}>
1463
- {/* 头部工具栏 - 始终显示 */}
1464
- <Header
1465
- fileName={getFileName()}
1466
- currentPage={currentPage}
1467
- totalPage={totalPages}
1468
- scale={scale}
1469
- isAnnotating={false}
1470
- tools={tools}
1471
- styles={styles}
1472
- onPrevPage={() => {}}
1473
- onNextPage={() => {}}
1474
- onZoomIn={() => {}}
1475
- onZoomOut={() => {}}
1476
- onAnnotationToggle={() => {}}
1477
- onDownload={() => {}}
1478
- onClose={handleClose}
1479
- className={headerClass}
1480
- />
1481
-
1482
- {/* 内容区域 - 显示加载状态 */}
1483
- {customComponents?.LoadingComponent ? (
1484
- <customComponents.LoadingComponent status={loadingStatus} theme={mergedTheme} />
1485
- ) : (
1486
- <DefaultLoadingComponent status={loadingStatus} theme={mergedTheme} />
1487
- )}
1488
- </ReaderContainer>
1489
- );
1490
- }
1491
-
1492
- return (
1493
- <ReaderContainer $theme={mergedTheme} className={className}>
1494
- {/* Header组件 */}
1495
- <Header
1496
- fileName={getFileName()}
1497
- currentPage={currentPage}
1498
- totalPage={totalPages}
1499
- scale={scale}
1500
- isAnnotating={false}
1501
- tools={{
1502
- ...tools,
1503
- // 仅PDF和PDF幻灯片显示导航
1504
- navigation: fileType === 'pdf' || fileType === 'pdf_slides' ? tools.navigation : false,
1505
- // 仅图片显示旋转
1506
- rotate: fileType === 'image',
1507
- }}
1508
- styles={styles}
1509
- onPrevPage={handlePrevPage}
1510
- onNextPage={handleNextPage}
1511
- onZoomIn={handleZoomIn}
1512
- onZoomOut={handleZoomOut}
1513
- onRotateLeft={fileType === 'image' ? handleRotateLeft : undefined}
1514
- onRotateRight={fileType === 'image' ? handleRotateRight : undefined}
1515
- onAnnotationToggle={() => {}}
1516
- onDownload={() => {}}
1517
- onClose={handleClose}
1518
- className={headerClass}
1519
- />
1520
-
1521
- {fileType === 'markdown' || fileType === 'markdown_table' ? (
1522
- // Markdown内容渲染 - 使用Fviewer的markdown渲染逻辑
1523
- <div
1524
- ref={scrollContainerRef}
1525
- style={{
1526
- flex: 1,
1527
- overflow: 'auto', // 改为auto,允许滚动条显示
1528
- position: 'relative',
1529
- }}
1530
- className={contentClass}
1531
- >
1532
- <Fviewer
1533
- data={{
1534
- content: markdownContent, // 直接传递markdown内容字符串
1535
- ...(getFileName() && { fileName: getFileName() }),
1536
- ...(fileType && { fileType }),
1537
- ...(totalPages && { totalPages }),
1538
- }}
1539
- annotationData={annotations}
1540
- totalPage={totalPages}
1541
- currentPage={currentPage}
1542
- scale={scale}
1543
- eventsEmit={(name, data) => {
1544
- console.log('Fviewer事件:', name, data);
1545
- // 处理markdown标注事件
1546
- if (name === 'md_annotation_add') {
1547
- eventsEmit('md_annotation_add', data);
1548
- } else if (name === 'table_annotation_add') {
1549
- eventsEmit('table_annotation_add', data);
1550
- } else {
1551
- // 传递其他事件
1552
- eventsEmit(name, data);
1553
- }
1554
- }}
1555
- styles={styles}
1556
- tools={tools}
1557
- customComponents={customComponents}
1558
- contentClass={contentClass}
1559
- />
1560
- {(() => {
1561
- console.log('=== 传递给Fviewer的markdown内容 ===');
1562
- console.log('markdownContent:', markdownContent);
1563
- console.log('markdownContent长度:', markdownContent.length);
1564
- console.log('markdownContent前100字符:', markdownContent.substring(0, 100));
1565
- console.log(
1566
- 'markdownContent后100字符:',
1567
- markdownContent.substring(markdownContent.length - 100)
1568
- );
1569
- return null;
1570
- })()}
1571
-
1572
- {/* 移除加载更多指示器,不再支持分块加载 */}
1573
- </div>
1574
- ) : fileType === 'image' ? (
1575
- // 图片内容渲染
1576
- <Fviewer
1577
- data={{
1578
- content: imageContent, // { type: 'image', url }
1579
- ...(getFileName() && { fileName: getFileName() }),
1580
- ...(fileType && { fileType }),
1581
- }}
1582
- annotationData={annotations}
1583
- totalPage={1}
1584
- currentPage={1}
1585
- scale={scale}
1586
- rotation={rotation}
1587
- eventsEmit={eventsEmit}
1588
- styles={styles}
1589
- tools={{
1590
- ...tools,
1591
- navigation: false,
1592
- rotate: true,
1593
- }}
1594
- customComponents={customComponents}
1595
- contentClass={contentClass}
1596
- />
1597
- ) : fileType === 'pdf' || fileType === 'pdf_slides' ? (
1598
- // PDF内容渲染
1599
- <Fviewer
1600
- data={{
1601
- content: { document: pdfDocument }, // 修复:包装成期望的数据结构
1602
- ...(getFileName() && { fileName: getFileName() }),
1603
- ...(fileType && { fileType }),
1604
- ...(totalPages && { totalPages }),
1605
- // 添加PDF起始页信息,用于分页PDF的页码映射
1606
- pdfStartPage,
1607
- }}
1608
- annotationData={annotations}
1609
- totalPage={totalPages}
1610
- currentPage={currentPage}
1611
- scale={scale}
1612
- initialZoom={initialZoom}
1613
- eventsEmit={(name, data) => {
1614
- console.log('Fviewer事件:', name, data);
1615
- // 处理缩放变化事件
1616
- if (name === 'scaleChange') {
1617
- console.log('收到缩放变化事件:', data);
1618
- // 这里需要更新scale状态,但是我们需要一个回调来更新scale
1619
- // 暂时先传递事件
1620
- eventsEmit(name, data);
1621
- } else {
1622
- // 传递其他事件
1623
- eventsEmit(name, data);
1624
- }
1625
- }}
1626
- styles={styles}
1627
- tools={tools}
1628
- customComponents={customComponents}
1629
- contentClass={contentClass}
1630
- setScale={setScale}
1631
- />
1632
- ) : (
1633
- // 通用文件类型渲染(html、text、unknown等)
1634
- <Fviewer
1635
- data={{
1636
- content: textContent || htmlContent || { type: 'text', content: '文件内容加载中...' },
1637
- ...(getFileName() && { fileName: getFileName() }),
1638
- ...(fileType && { fileType }),
1639
- }}
1640
- annotationData={annotations}
1641
- totalPage={1}
1642
- currentPage={1}
1643
- scale={scale}
1644
- eventsEmit={eventsEmit}
1645
- styles={styles}
1646
- tools={{
1647
- ...tools,
1648
- navigation: false, // 通用文件类型不支持翻页
1649
- }}
1650
- customComponents={customComponents}
1651
- contentClass={contentClass}
1652
- />
1653
- )}
1654
- </ReaderContainer>
1655
- );
1656
- };
1657
-
1658
- export default GientechStreamReader;