askbot-dragon 1.6.76-beta → 1.6.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/README.md +27 -27
  2. package/babel.config.js +6 -6
  3. package/dragon.iml +7 -7
  4. package/package.json +58 -55
  5. package/public/index.html +75 -72
  6. package/public/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  7. package/public/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  8. package/public/pdfjs/cmaps/78-H.bcmap +0 -0
  9. package/public/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  10. package/public/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  11. package/public/pdfjs/cmaps/78-V.bcmap +0 -0
  12. package/public/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  13. package/public/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  14. package/public/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  15. package/public/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  16. package/public/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  17. package/public/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  18. package/public/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  19. package/public/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  20. package/public/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  21. package/public/pdfjs/cmaps/Add-H.bcmap +0 -0
  22. package/public/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  23. package/public/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  24. package/public/pdfjs/cmaps/Add-V.bcmap +0 -0
  25. package/public/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  26. package/public/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  27. package/public/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  28. package/public/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  29. package/public/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  30. package/public/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  31. package/public/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  32. package/public/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  33. package/public/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  34. package/public/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  35. package/public/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  36. package/public/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  37. package/public/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  38. package/public/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  39. package/public/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  40. package/public/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  41. package/public/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  42. package/public/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  43. package/public/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  44. package/public/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  45. package/public/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  46. package/public/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  47. package/public/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  48. package/public/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  49. package/public/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  50. package/public/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  51. package/public/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  52. package/public/pdfjs/cmaps/B5-H.bcmap +0 -0
  53. package/public/pdfjs/cmaps/B5-V.bcmap +0 -0
  54. package/public/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  55. package/public/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  56. package/public/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  57. package/public/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  58. package/public/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  59. package/public/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  60. package/public/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  61. package/public/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  62. package/public/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  63. package/public/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  64. package/public/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  65. package/public/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  66. package/public/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  67. package/public/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  68. package/public/pdfjs/cmaps/EUC-H.bcmap +0 -0
  69. package/public/pdfjs/cmaps/EUC-V.bcmap +0 -0
  70. package/public/pdfjs/cmaps/Ext-H.bcmap +0 -0
  71. package/public/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  72. package/public/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  73. package/public/pdfjs/cmaps/Ext-V.bcmap +0 -0
  74. package/public/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  75. package/public/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  76. package/public/pdfjs/cmaps/GB-H.bcmap +4 -0
  77. package/public/pdfjs/cmaps/GB-V.bcmap +0 -0
  78. package/public/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  79. package/public/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  80. package/public/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  81. package/public/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  82. package/public/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  83. package/public/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  84. package/public/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  85. package/public/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  86. package/public/pdfjs/cmaps/GBT-H.bcmap +0 -0
  87. package/public/pdfjs/cmaps/GBT-V.bcmap +0 -0
  88. package/public/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  89. package/public/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  90. package/public/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  91. package/public/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  92. package/public/pdfjs/cmaps/H.bcmap +0 -0
  93. package/public/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  94. package/public/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  95. package/public/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  96. package/public/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  97. package/public/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  98. package/public/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  99. package/public/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  100. package/public/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  101. package/public/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  102. package/public/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  103. package/public/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  104. package/public/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  105. package/public/pdfjs/cmaps/Hankaku.bcmap +0 -0
  106. package/public/pdfjs/cmaps/Hiragana.bcmap +0 -0
  107. package/public/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  108. package/public/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  109. package/public/pdfjs/cmaps/KSC-H.bcmap +0 -0
  110. package/public/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  111. package/public/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  112. package/public/pdfjs/cmaps/KSC-V.bcmap +0 -0
  113. package/public/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  114. package/public/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  115. package/public/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  116. package/public/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  117. package/public/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  118. package/public/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  119. package/public/pdfjs/cmaps/Katakana.bcmap +0 -0
  120. package/public/pdfjs/cmaps/LICENSE +36 -0
  121. package/public/pdfjs/cmaps/NWP-H.bcmap +0 -0
  122. package/public/pdfjs/cmaps/NWP-V.bcmap +0 -0
  123. package/public/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  124. package/public/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  125. package/public/pdfjs/cmaps/Roman.bcmap +0 -0
  126. package/public/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  127. package/public/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  128. package/public/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  129. package/public/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  130. package/public/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  131. package/public/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  132. package/public/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  133. package/public/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  134. package/public/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  135. package/public/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  136. package/public/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  137. package/public/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  138. package/public/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  139. package/public/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  140. package/public/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  141. package/public/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  142. package/public/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  143. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  144. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  145. package/public/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  146. package/public/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  147. package/public/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  148. package/public/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  149. package/public/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  150. package/public/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  151. package/public/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  152. package/public/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  153. package/public/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  154. package/public/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  155. package/public/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  156. package/public/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  157. package/public/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  158. package/public/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  159. package/public/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  160. package/public/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  161. package/public/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  162. package/public/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  163. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  164. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  165. package/public/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  166. package/public/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  167. package/public/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  168. package/public/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  169. package/public/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  170. package/public/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  171. package/public/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  172. package/public/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  173. package/public/pdfjs/cmaps/V.bcmap +0 -0
  174. package/public/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  175. package/public/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  176. package/public/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  177. package/public/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  178. package/public/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  179. package/public/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  180. package/public/pdfjs/standard_fonts/FoxitSans.pfb +0 -0
  181. package/public/pdfjs/standard_fonts/FoxitSansBold.pfb +0 -0
  182. package/public/pdfjs/standard_fonts/FoxitSansBoldItalic.pfb +0 -0
  183. package/public/pdfjs/standard_fonts/FoxitSansItalic.pfb +0 -0
  184. package/public/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  185. package/public/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  186. package/public/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  187. package/public/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  188. package/public/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  189. package/public/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  190. package/public/pdfjs/standard_fonts/LICENSE_LIBERATION +102 -0
  191. package/public/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  192. package/public/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  193. package/public/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  194. package/public/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  195. package/src/App.vue +31 -31
  196. package/src/api/index.js +1 -1
  197. package/src/api/mock.http +2 -2
  198. package/src/api/requestUrl.js +185 -185
  199. package/src/assets/image/default_avt_ui.png +0 -0
  200. package/src/assets/image/filtType/audio.png +0 -0
  201. package/src/assets/image/filtType/excel1.png +0 -0
  202. package/src/assets/image/filtType/general.png +0 -0
  203. package/src/assets/image/filtType/html.png +0 -0
  204. package/src/assets/image/filtType/image1.png +0 -0
  205. package/src/assets/image/filtType/link.png +0 -0
  206. package/src/assets/image/filtType/md2.png +0 -0
  207. package/src/assets/image/filtType/mode.png +0 -0
  208. package/src/assets/image/filtType/news.png +0 -0
  209. package/src/assets/image/filtType/pdf1.png +0 -0
  210. package/src/assets/image/filtType/ppt1.png +0 -0
  211. package/src/assets/image/filtType/selfadd1.png +0 -0
  212. package/src/assets/image/filtType/txt1.png +0 -0
  213. package/src/assets/image/filtType/video.png +0 -0
  214. package/src/assets/image/filtType/wechat.png +0 -0
  215. package/src/assets/image/filtType/word1.png +0 -0
  216. package/src/assets/image/loading.gif +0 -0
  217. package/src/assets/js/AliyunlssUtil.js +117 -92
  218. package/src/assets/js/Base64Util.js +22 -22
  219. package/src/assets/js/common.js +287 -252
  220. package/src/assets/js/hammer.js +89 -100
  221. package/src/assets/js/script.js +36 -36
  222. package/src/assets/less/common.css +6773 -6773
  223. package/src/assets/less/converSationContainer/common.less +192 -199
  224. package/src/assets/less/converSationContainer/converSatonContainer.less +486 -493
  225. package/src/assets/less/iconfont.css +37 -37
  226. package/src/assets/less/ticketMessage.less +294 -294
  227. package/src/assets/less/variables.less +122 -0
  228. package/src/components/ActionAlertIframe.vue +155 -177
  229. package/src/components/AiGuide.vue +473 -466
  230. package/src/components/AnswerDocknowledge.vue +1207 -1059
  231. package/src/components/AnswerVoice.vue +286 -285
  232. package/src/components/AskIFrame.vue +15 -15
  233. package/src/components/ConversationContainer.vue +10880 -4934
  234. package/src/components/FileType.vue +86 -86
  235. package/src/components/Message.vue +27 -27
  236. package/src/components/MyEditor.vue +343 -351
  237. package/src/components/QwFeedback.vue +304 -0
  238. package/src/components/actionSatisfaction.vue +109 -107
  239. package/src/components/actionSendToBot.vue +64 -62
  240. package/src/components/answerDissatisfaction.vue +64 -62
  241. package/src/components/answerRadio.vue +261 -186
  242. package/src/components/ask-components/DissatisfactionOptions.vue +58 -57
  243. package/src/components/ask-components/Msgloading.vue +38 -37
  244. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  245. package/src/components/askVideo.vue +214 -162
  246. package/src/components/assetDetails.vue +379 -378
  247. package/src/components/assetMessage.vue +231 -228
  248. package/src/components/associationIntention.vue +414 -355
  249. package/src/components/attachmentPreview.vue +92 -90
  250. package/src/components/botActionSatisfactor.vue +70 -68
  251. package/src/components/chatContent.vue +514 -513
  252. package/src/components/feedBack.vue +138 -136
  253. package/src/components/fielListView.vue +352 -351
  254. package/src/components/file/AliyunOssComponents.vue +108 -108
  255. package/src/components/formTemplate.vue +3517 -3572
  256. package/src/components/imgView.vue +32 -0
  257. package/src/components/intelligentSummary.vue +232 -227
  258. package/src/components/interruptComponents/imageSelectionAnswer.vue +203 -0
  259. package/src/components/interruptComponents/multipleChoiceAnswer.vue +134 -0
  260. package/src/components/interruptComponents/singleChoiceAnswer.vue +82 -0
  261. package/src/components/kkview.vue +1130 -1138
  262. package/src/components/loadingProcess.vue +164 -164
  263. package/src/components/markDownText.vue +961 -0
  264. package/src/components/message/ActionAlertIframe.vue +112 -112
  265. package/src/components/message/ShopMessage.vue +164 -164
  266. package/src/components/message/TextMessage.vue +926 -924
  267. package/src/components/message/TicketMessage.vue +201 -201
  268. package/src/components/message/swiper/index.js +4 -4
  269. package/src/components/message/swiper/ticketSwiper.vue +503 -503
  270. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  271. package/src/components/msgLoading.vue +231 -231
  272. package/src/components/myPopup.vue +75 -70
  273. package/src/components/outputComponents/outputCom.vue +149 -0
  274. package/src/components/pagination.vue +130 -0
  275. package/src/components/pdfPosition.vue +1337 -1506
  276. package/src/components/popup.vue +230 -227
  277. package/src/components/preview/docView.vue +263 -0
  278. package/src/components/preview/excelView.vue +260 -0
  279. package/src/components/preview/markDownView.vue +70 -0
  280. package/src/components/preview/newPositionPreview.vue +601 -0
  281. package/src/components/preview/pdfView.vue +973 -0
  282. package/src/components/previewDoc.vue +253 -247
  283. package/src/components/previewPdf.vue +1106 -757
  284. package/src/components/previewWisdom.vue +252 -0
  285. package/src/components/receiverMessagePlatform.vue +71 -65
  286. package/src/components/recommend.vue +82 -80
  287. package/src/components/selector/hOption.vue +20 -20
  288. package/src/components/selector/hSelector.vue +199 -199
  289. package/src/components/selector/hWrapper.vue +216 -216
  290. package/src/components/senderMessagePlatform.vue +60 -50
  291. package/src/components/source/BotMessage.vue +24 -24
  292. package/src/components/source/CustomMessage.vue +24 -24
  293. package/src/components/test.vue +260 -260
  294. package/src/components/tree.vue +310 -295
  295. package/src/components/utils/AliyunIssUtil.js +103 -81
  296. package/src/components/utils/ckeditor.js +185 -174
  297. package/src/components/utils/format_date.js +25 -25
  298. package/src/components/utils/index.js +6 -6
  299. package/src/components/utils/math_utils.js +29 -29
  300. package/src/components/voiceComponent.vue +122 -119
  301. package/src/components/welcomeKnowledgeFile.vue +346 -340
  302. package/src/components/welcomeLlmCard.vue +142 -140
  303. package/src/components/welcomeSuggest.vue +99 -97
  304. package/src/locales/cn.json +100 -0
  305. package/src/locales/en.json +99 -0
  306. package/src/main.js +76 -57
  307. package/vue.config.js +54 -54
  308. package/src/components/newPdfPosition.vue +0 -878
@@ -1,878 +0,0 @@
1
- <template>
2
- <div class="pdf-touch-box"
3
- ref="pdfView"
4
- @scroll="pdfScroll"
5
- >
6
- <div :style="{ width:btnWidth + 'px' }">
7
- <button @click="scaleEvent(3.5)">3.5</button>
8
- <button @click="scaleEvent(2.5)">2.5</button>
9
- <button @click="scaleEvent(1.8)">1.8</button>
10
- <button @click="scaleEvent(1.4)">1.4</button>
11
- <button @click="scaleEvent(1)">1</button>
12
- <button @click="scaleEvent(0.5)">0.5</button>
13
- </div>
14
-
15
- <div
16
- v-show="!loading"
17
- class="pdf-canvas-wrap"
18
- id="pdf-canvas-wrap"
19
- :style="{
20
- top: viewTop + 'px',
21
- left: viewLeft + 'px',
22
- width:viewWidth + 'px',
23
- height: viewHeight + 'px'
24
- }"
25
- ></div>
26
- <p v-show="loading">正在加载...</p>
27
- </div>
28
- </template>
29
-
30
-
31
-
32
- <script>
33
- // import * as PDFJS from 'pdfjs-dist'
34
- // console.log(PDFJS)
35
- //
36
- // import { TextLayerBuilder, EventBus } from 'pdfjs-dist/web/pdf_viewer'
37
- import _ from "lodash";
38
-
39
- const pdfjsLib = window['pdfjsLib']
40
- if(pdfjsLib) {
41
- pdfjsLib.GlobalWorkerOptions.workerSrc = window['pdfjs-dist/build/pdf.worker']
42
- // 'pdfjs-dist/build/pdf.worker';
43
- }
44
- const { TextLayerBuilder,EventBus } = window['pdfjs-dist/web/pdf_viewer']
45
- // import 'pdfjs-dist/web/pdf_viewer.css'
46
- console.log(TextLayerBuilder)
47
-
48
- // 本地
49
- // window.pdfjsWorker = require("pdfjs-dist/build/pdf.worker.js");
50
-
51
- // cdn 2.8.335 2.6.347 2.5.207
52
- pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.6.347/build/pdf.worker.min.js'
53
-
54
- // https://github.com/mozilla/pdf.js/blob/master/examples/node/getinfo.js
55
- // Requires single file built version of PDF.js -- please run
56
- // `gulp singlefile` before running the example.
57
- // const pdfjsLib = require("pdfjs-dist/legacy/build/pdf.js");
58
-
59
- const CSS_UNITS = 96.0 / 72.0
60
- // const PRINT_UNITS = 150 / 72.0;
61
-
62
- let userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) || ''
63
- let platform = (typeof navigator !== 'undefined' && navigator.platform) || ''
64
- let maxTouchPoints = (typeof navigator !== 'undefined' && navigator.maxTouchPoints) || 1
65
-
66
- let maxCanvasPixels = 16777216
67
- // PDF之外占据的宽度 -18 padding -18减去滚动条宽度(不确定)
68
- let autoWidth = 36
69
- let textLayerTop = 3
70
- let scaleInterval = 0.05
71
-
72
- let isAndroid = /Android/.test(userAgent)
73
- let isIOS = /(iPad|iPhone|iPod)(?=;)/.test(userAgent) || (platform === 'MacIntel' && maxTouchPoints > 1)
74
- ;(function checkCanvasSizeLimitation() {
75
- if (isIOS || isAndroid) {
76
- maxCanvasPixels = 5242880
77
- autoWidth -= 18
78
- textLayerTop -= 1
79
- // 手机上面缩放对清晰度影响更小
80
- scaleInterval = 0.4
81
- }
82
- })()
83
- import AlloyFinger from 'alloyfinger'
84
- //包装一下 不然 eslint 报警告
85
- class FingerTouch {
86
- constructor(element, options) {
87
- Object.assign(this, AlloyFinger.prototype)
88
- AlloyFinger.call(this, element, options)
89
- }
90
- }
91
- export default {
92
- name: "newPdfPosition",
93
- data() {
94
- return {
95
- src: '../assets/js/test.pdf',
96
- loading: true,
97
- pdfDoc: null,
98
- boxEl: null,
99
- wrapEl: null,
100
- areaWidth: 0,
101
- btnWidth: 0,
102
- viewWidth: 0,
103
- viewHeight: 0,
104
- pixelRatio: 2,
105
- isFirstTimeRender: true,
106
- viewport: null,
107
- canvasEles: [],
108
- canvasCtxs: [],
109
- totallPage: 0,
110
- pageScale: 1, // pdf 适应窗口产生的 scale
111
- curCanvasCSSWh: null,
112
- transform: null,
113
- pageRenderedNum: 0,
114
- scaleTimer: null,
115
- lastStyleScale: 1,
116
- lastRerenderScale: 1,
117
- alloyFinger: null,
118
- viewTop: 0,
119
- viewLeft: 9,
120
- textEls: [],
121
- url: '',
122
- pages: [],
123
- pageLoadStatus: {
124
- WAIT: 0,
125
- LOADED: 1,
126
- },
127
- scale: 1,
128
- rotation: 0,
129
- pageSize: {},
130
- PAGE_INTVERVAL: 15,
131
- SLICE_COUNT: 5,
132
- contentView: null,
133
- fisrtLoad: true,
134
- TextLayerBuilder: null,
135
- totalPageCount: 0,
136
- identifyTextPostion: {
137
- top: 0,
138
- left: 0,
139
- width: 100,
140
- height: 0,
141
- page: 1,
142
- pageHeight: 0,
143
- pageWidth: 0,
144
- extractInfo: {},
145
- currentPageAllLine: []
146
- },
147
- currentPageAllLine: [],
148
- pdfUrl: '',
149
- cachePdf: [],
150
- newViewer: null,
151
- currentPage: 0,
152
- changetoolbar: false,
153
- allTr:[],
154
- preViewType: 'pdf',
155
- displacement:{
156
- pageX: 0,
157
- pageY: 0,
158
- moveable: false,
159
- pageX2: 0,
160
- pageY2: 0,
161
- originScale: 1,
162
- },
163
- isTouchMoved: false,
164
- transformSalce: null,
165
- isPC: false,
166
- handScale: 'auto',
167
- scaleList:[
168
- {
169
- label:'自动缩放',
170
- value:'auto'
171
- },
172
- {
173
- label:'实际比例',
174
- value:'reality'
175
- },
176
- {
177
- label:'100%',
178
- value: 1
179
- },
180
- {
181
- label:'120%',
182
- value: 1.2
183
- },
184
- {
185
- label:'150%',
186
- value: 1.5
187
- },
188
- {
189
- label:'170%',
190
- value: 1.7
191
- }
192
- ,
193
- {
194
- label:'200%',
195
- value: 2
196
- }
197
- ],
198
- scrollTop:0,
199
- scrollLeft:0,
200
- }
201
- },
202
- props:["tagIds"],
203
- mounted() {
204
- // this.init()
205
- },
206
- methods: {
207
- async init(loadPage) {
208
- //禁止下拉刷新
209
- document.addEventListener(
210
- 'touchmove',
211
- function () {
212
- // ev.preventDefault()
213
- },
214
- { passive: false }
215
- )
216
- this.boxEl = document.querySelector('.pdf-touch-box')
217
- this.wrapEl = document.getElementsByClassName('pdf-canvas-wrap')[0]
218
- this.btnWidth = this.areaWidth = this.boxEl.clientWidth
219
- await this.initPages(loadPage.total);
220
- const loadingState = await this.getPDF(loadPage.page)
221
- if (loadingState === 'success') {
222
- this.initRenderOneByOne(loadPage.page)
223
- this.initTouch()
224
- } else this.boxEl.innerText = loadingState
225
- },
226
- initTouch() {
227
- this.alloyFinger = new FingerTouch(this.wrapEl, {})
228
- this.alloyFinger.on('pinch', e => {
229
- let zoom = e.zoom
230
- let curScale = this.lastStyleScale * zoom
231
- if (curScale <= 1 || curScale >= 5) return
232
- this.scaleEvent(curScale)
233
- })
234
-
235
- this.alloyFinger.on('pressMove', e => {
236
- this.viewTop += e.deltaY
237
- this.viewLeft += e.deltaX
238
- })
239
- },
240
- scaleEvent(scale) {
241
- // 渲染中 不让缩放 也不让重绘
242
- if (this.pageRenderedNum != this.totallPage || this.totallPage === 0) return
243
-
244
- // 没在渲染中 随意缩放
245
- this.scaleCanvas(scale)
246
-
247
- // 说明是第一次事件 或重绘完成 开始计时
248
- if (this.scaleTimer === null) {
249
- this.scaleTimer = this.renderDelayer(666)
250
- }
251
- //时间间隔内再次触发缩放 重新计时
252
- clearTimeout(this.scaleTimer)
253
- this.scaleTimer = this.renderDelayer(666)
254
- },
255
- renderDelayer(interval) {
256
- return setTimeout(() => {
257
- this.scaleRenderAll()
258
- this.scaleTimer = null
259
- }, interval)
260
- },
261
- scaleTopLeft(width, height) {
262
- if (Math.abs(this.viewTop) > height / 2) this.viewTop *= 1 / 2
263
- if (Math.abs(this.viewLeft) > width / 2) this.viewLeft *= 1 / 2
264
- },
265
- scaleCanvas(scale) {
266
- this.lastStyleScale = scale
267
- console.log(scale)
268
- // 改变 viewport 大小
269
- this.viewport = this.viewport.clone({
270
- scale: (this.pageScale * CSS_UNITS * scale).toFixed(3)
271
- })
272
-
273
- const { styleWidth, styleHeight } = this.getCanvasCSSWH()
274
-
275
- // 计算一下 top left 不然可能会显示到 窗口外面 看不到了
276
- this.scaleTopLeft(styleWidth, styleHeight)
277
-
278
- // 改变CSS canvas 会变模糊
279
- this.canvasEles.forEach(canvas => {
280
- // 不修改 width height 不然会重置 canvas 变空白
281
- canvas.style.width = styleWidth + 'px'
282
- canvas.style.height = styleHeight + 'px'
283
- })
284
- },
285
- // 使用新渲染的 canvas 替换 缩放过后不清晰的 canvas
286
- scaleRenderAll() {
287
- let curInterval = Math.abs(this.lastStyleScale - this.lastRerenderScale)
288
- let curScaleInterval = scaleInterval
289
- let isNarrow = this.lastStyleScale < this.lastRerenderScale
290
- // 如果是变小 变化不大时 清晰度影响更小
291
- if (isNarrow) curScaleInterval = scaleInterval * 2
292
-
293
- console.log('scaleRenderAll', curScaleInterval, curInterval)
294
- // 变化很小的时候就不计时重新渲染了 清晰度影响不大 1.1 - 1 = 0.10000000000000009
295
- if (curInterval <= curScaleInterval) return
296
-
297
- this.lastRerenderScale = this.lastStyleScale
298
-
299
- this.pageRenderedNum = 0
300
- const len = this.canvasEles.length
301
- for (let pageNum = 1; pageNum <= len; pageNum++) {
302
- let newCanvas = document.createElement('canvas')
303
- let newCtx = newCanvas.getContext('2d', {
304
- alpha: false
305
- })
306
- newCanvas.setAttribute('id', `pdf-canvas${pageNum}`)
307
-
308
- this.canvasCtxs[pageNum - 1] = newCtx
309
-
310
- let that = this
311
- console.debug('pdfDoc',this.pdfDoc)
312
- this.pdfDoc.getPage(pageNum).then(function (page) {
313
- that.setCanvasCSSWh.call(that, newCanvas)
314
-
315
- let renderTask = that.pageRender.call(that, page, newCtx)
316
-
317
- renderTask.promise
318
- .then(function () {
319
- let oldCanvas = that.canvasEles[pageNum - 1]
320
- oldCanvas.parentElement.replaceChild(newCanvas, oldCanvas)
321
- that.canvasEles[pageNum - 1] = newCanvas
322
- that.pageRenderedNum++
323
-
324
- return page.getTextContent()
325
- })
326
- .then(textContent => that.textRerender.call(that, pageNum, textContent))
327
- .catch(e => console.log(e))
328
- })
329
- }
330
- },
331
- initPages (totalPage) {
332
- this.totalPageCount = totalPage;
333
- // this.totallPage = totalPage;
334
- for (let i = 0; i < totalPage; i += 1) {
335
- this.pages.push({
336
- pageNo: i + 1,
337
- loadStatus: false,
338
- pdfPage: null,
339
- dom: null
340
- });
341
- }
342
- },
343
- async getPDF (loadPage) {
344
- let that = this;
345
- if(that.pages[loadPage - 1] && ((that.pages[loadPage - 1].dom && that.pages[loadPage - 1].dom.children.length > 0) || that.pages[loadPage - 1].loadStatus)) {
346
- return
347
- } else {
348
- if (that.changetoolbar) {
349
- that.$nextTick(() => {
350
- that.renderHighlights()
351
- })
352
- that.changetoolbar = false
353
- }
354
- }
355
- // 记录开始缓存的状态
356
- // pdfjsLib.GlobalWorkerOptions.workerSrc = require("pdfjs-dist/legacy/build/pdf.worker.entry.js");
357
- // 拿到第一个分片
358
- const { url } = await that.fetchPdfFragment(loadPage);
359
- let loadingTask = pdfjsLib.getDocument(url);
360
- return new Promise(reslove => {
361
- loadingTask.promise.then((pdfDoc_) => {
362
- that.pdfDoc = pdfDoc_
363
- that.totallPage += 1
364
- console.debug('totallPage',that.totallPage)
365
- // that.totallPage = pdfDoc_.numPages;
366
- that.loading = false
367
- reslove('success')
368
- })
369
- })
370
- },
371
- async fetchPdfFragment (pageIndex) {
372
- // 置换加签后的文件地址。
373
- let obj = {}
374
- await this.$http.post(
375
- '/knowledge-api/temporary-certificate/or-origin?expired=30',
376
- this.pdfUrl + pageIndex + '.pdf',
377
- {
378
- headers: {
379
- "Content-Type": "application/json",
380
- },
381
- }).then(async res => {
382
- if(res.bodyText) {
383
- // 最后返回一个 包含这4个参数的对象
384
- obj = await {
385
- "startPage": pageIndex, // 分片的开始页码
386
- "endPage": pageIndex + 5, // 分片结束页码
387
- "totalPage": this.totalPageCount, // pdf 总页数
388
- "url": res.bodyText // 分片内容下载地址
389
- }
390
- }
391
- if (res.data) {
392
- // 最后返回一个 包含这4个参数的对象
393
- obj = await {
394
- "startPage": pageIndex, // 分片的开始页码
395
- "endPage": pageIndex + 5, // 分片结束页码
396
- "totalPage": this.totalPageCount, // pdf 总页数
397
- "url": res.data // 分片内容下载地址
398
- }
399
- }
400
- })
401
- return obj
402
- },
403
- // 渲染需要展示的页面,不需展示的页码将其清除
404
- renderPages (pageIndex) {
405
- const pagesToRender = this.getRenderScope(pageIndex);
406
- for (const i of this.pages) {
407
- if(pagesToRender.some(p =>{ return p.pageNo == i.pageNo })) {
408
- if(i.loadStatus === true) {
409
- console.debug('pagesToRender',i)
410
- this.initRenderOneByOne(i.pageNo)
411
- } else {
412
- // this.renderPageLoading(i, i.pageNo)
413
- }
414
- } else {
415
- // this.clearPage(i);
416
- }
417
- }
418
-
419
- },
420
- // 根据当前的可视范围内的页码,我们前后只保留 8 页
421
- getRenderScope (pageIndex) {
422
- const pagesToRender = [];
423
- let i = pageIndex - 1;
424
- let j = pageIndex + 1;
425
- // pageIndex - 1 表示当前页码数 对应的下标位置
426
- pagesToRender.push(this.pages[pageIndex - 1]);
427
- while (pagesToRender.length < 8 && pagesToRender.length < this.pages.length) {
428
- if (i > 0) {
429
- pagesToRender.push(this.pages[i - 1]);
430
- i -= 1;
431
- }
432
- if (pagesToRender.length >= 8) {
433
- break;
434
- }
435
- if (j <= this.pages.length) {
436
- pagesToRender.push(this.pages[j - 1]);
437
- j += 1;
438
- }
439
- }
440
- // for (let index = 0; index < array.length; index++) {
441
- // const element = array[index];
442
-
443
- // }
444
- return pagesToRender;
445
- },
446
- initRenderOneByOne(pageIndex) {
447
- console.debug('pageIndex',pageIndex,this.totallPage)
448
- // for (let pageNum = pageIndex; pageNum <= this.totallPage; pageNum++) {
449
- //
450
- // }
451
- let canvas = document.createElement('canvas')
452
- canvas.setAttribute('id', `pdf-canvas${pageIndex}`)
453
- canvas.setAttribute('class', `pdfcanvas`)
454
- // alpha 设定 canvas 背景总是不透明,可以加快浏览器绘制透明的内容和图片 初始化出来 canvas 为黑色背景
455
- // 实际上 导致 重新渲染的时候 闪黑屏
456
- // let ctx = canvas.getContext("2d", {
457
- // alpha: false,
458
- // });
459
- let ctx = canvas.getContext('2d')
460
- this.canvasCtxs.push(ctx)
461
- this.canvasEles.push(canvas)
462
- // this.wrapEl.appendChild(canvas);
463
-
464
- let pageDiv = document.createElement('div')
465
- pageDiv.setAttribute('id', 'page-' + pageIndex)
466
- pageDiv.setAttribute('style', 'position: relative;')
467
- this.wrapEl.appendChild(pageDiv)
468
- pageDiv.appendChild(canvas)
469
- this.renderSinglePage(canvas, pageIndex)
470
- // this.renderSinglePage(this.canvasEles[0], 1)
471
- },
472
-
473
- renderSinglePage(canvas, pageNum) {
474
- let ctx = this.canvasCtxs[pageNum - 1]
475
- let that = this
476
- that.pdfDoc.getPage(1).then(async function (page) {
477
- that.pages[pageNum - 1].loadStatus = true
478
- that.pages[pageNum - 1].pdfPage = page;
479
- if (that.isFirstTimeRender) that.initView(page, ctx)
480
-
481
- if (pageNum === 1) await that.getCanvasCSSWH()
482
- await that.setCanvasCSSWh.call(that, canvas)
483
- let renderTask = that.pageRender.call(that, page, ctx)
484
-
485
- renderTask.promise
486
- .then(function () {
487
- // if (that.totallPage > pageNum) {
488
- // that.renderSinglePage(that.canvasEles[pageNum], pageNum + 1)
489
- // }
490
- // const html = canvas.toDataURL();
491
- // let image = document.createElement('img');
492
- // image.setAttribute('src',html)
493
-
494
- that.pageRenderedNum++
495
- return page.getTextContent()
496
- })
497
- .then(textContent => that.textRender.call(that, canvas, pageNum, textContent))
498
- })
499
- },
500
- textRerender(pageIndex, textContent) {
501
- const oldDiv = this.textEls[pageIndex - 1]
502
-
503
- const newDiv = document.createElement('div')
504
- newDiv.setAttribute('class', 'textLayer')
505
- newDiv.setAttribute('style', `top: ${textLayerTop}px`)
506
-
507
- oldDiv.parentElement.replaceChild(newDiv, oldDiv)
508
- this.textEls[pageIndex - 1] = newDiv
509
- console.debug('textContent',textContent)
510
- this.renderTextLayer(newDiv, pageIndex, textContent)
511
- },
512
- textRender(canvas, pageIndex, textContent) {
513
- const textLayerDiv = document.createElement('div')
514
- textLayerDiv.setAttribute('class', 'textLayer')
515
- textLayerDiv.setAttribute('style', `top: ${textLayerTop}px`)
516
- canvas.parentElement.appendChild(textLayerDiv)
517
- this.textEls[pageIndex - 1] = textLayerDiv
518
- this.renderTextLayer(textLayerDiv, pageIndex, textContent)
519
- },
520
- renderTextLayer(el, index, content) {
521
- var textLayer = new TextLayerBuilder({
522
- eventBus: new EventBus(),
523
- textLayerDiv: el,
524
- pageIndex: index,
525
- viewport: this.viewport
526
- })
527
-
528
- textLayer.setTextContent(content)
529
- textLayer.render()
530
- this.fisrtLoad = false;
531
- },
532
- setCanvasCSSWh(canvas) {
533
- let that = this
534
- canvas.width = that.curCanvasCSSWh.width
535
- canvas.height = that.curCanvasCSSWh.height
536
- canvas.style.width = that.curCanvasCSSWh.styleWidth + 'px'
537
- canvas.style.height = that.curCanvasCSSWh.styleHeight + 'px'
538
- // canvas.style['border'] = '#d6d6d6 solid 1px'
539
- canvas.style.margin = '0 0 9px 0'
540
- },
541
- pageRender(page, ctx) {
542
- return page.render({
543
- canvasContext: ctx,
544
- transform: this.transform,
545
- viewport: this.viewport,
546
- enableWebGL: false,
547
- renderInteractiveForms: false
548
- })
549
- },
550
-
551
- drawBorder(canvas, ctx) {
552
- ctx.save()
553
- ctx.fillStyle = 'rgb(255, 255, 255)'
554
- ctx.strokeRect(0, 0, canvas.width, canvas.height)
555
- ctx.restore()
556
- },
557
- getCanvasCSSWH() {
558
- let outputScale = {
559
- sx: this.pixelRatio,
560
- sy: this.pixelRatio,
561
- scaled: this.pixelRatio !== 1
562
- }
563
-
564
- let pixelsInViewport = this.viewport.width * this.viewport.height
565
- let maxScale = Math.sqrt(maxCanvasPixels / pixelsInViewport)
566
-
567
- if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
568
- // 这里触发会出错
569
- // outputScale.sx = maxScale;
570
- // outputScale.sy = maxScale;
571
- // outputScale.scaled = true;
572
- }
573
-
574
- let sfx = (0, this.approximateFraction)(outputScale.sx)
575
- let sfy = (0, this.approximateFraction)(outputScale.sy)
576
- const width = (0, this.roundToDivide)(this.viewport.width * outputScale.sx, sfx[0])
577
- const height = (0, this.roundToDivide)(this.viewport.height * outputScale.sy, sfy[0])
578
- const styleWidth = (0, this.roundToDivide)(this.viewport.width, sfx[1])
579
- const styleHeight = (0, this.roundToDivide)(this.viewport.height, sfy[1])
580
-
581
- if (this.pixelRatio !== 1) this.transform = [this.pixelRatio, 0, 0, this.pixelRatio, 0, 0]
582
-
583
- this.viewWidth = styleWidth + 2
584
- // 12 加上 canvas border margin 误差?2 + 9 + 1
585
- // this.viewHeight = this.totallPage * (this.viewport.height + 12) + 9
586
- console.debug('totalPageCount',this.totalPageCount)
587
- this.viewHeight = `${(this.totalPageCount * (this.viewport.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}`
588
- console.debug('viewHeight',this.viewHeight,this.totallPage)
589
- this.curCanvasCSSWh = { width, height, styleWidth, styleHeight }
590
- return this.curCanvasCSSWh
591
- },
592
- approximateFraction(x) {
593
- if (Math.floor(x) === x) {
594
- return [x, 1]
595
- }
596
-
597
- var xinv = 1 / x
598
- var limit = 8
599
-
600
- if (xinv > limit) {
601
- return [1, limit]
602
- } else if (Math.floor(xinv) === xinv) {
603
- return [1, xinv]
604
- }
605
-
606
- var x_ = x > 1 ? xinv : x
607
- var a = 0,
608
- b = 1,
609
- c = 1,
610
- d = 1
611
- // eslint-disable-next-line
612
- while (true) {
613
- var p = a + c,
614
- q = b + d
615
-
616
- if (q > limit) {
617
- break
618
- }
619
-
620
- if (x_ <= p / q) {
621
- c = p
622
- d = q
623
- } else {
624
- a = p
625
- b = q
626
- }
627
- }
628
-
629
- var result
630
-
631
- if (x_ - a / b < c / d - x_) {
632
- result = x_ === x ? [a, b] : [b, a]
633
- } else {
634
- result = x_ === x ? [c, d] : [d, c]
635
- }
636
-
637
- return result
638
- },
639
- roundToDivide(x, div) {
640
- var r = x % div
641
- return r === 0 ? x : Math.round(x - r + div)
642
- },
643
-
644
- initView(page, ctx) {
645
- let devicePixelRatio = window.devicePixelRatio || 1
646
- let backingStoreRatio =
647
- ctx.webkitBackingStorePixelRatio ||
648
- ctx.mozBackingStorePixelRatio ||
649
- ctx.msBackingStorePixelRatio ||
650
- ctx.oBackingStorePixelRatio ||
651
- ctx.backingStorePixelRatio ||
652
- 1
653
- this.pixelRatio = devicePixelRatio / backingStoreRatio
654
-
655
- this.viewport = page.getViewport({
656
- scale: CSS_UNITS
657
- })
658
-
659
- this.pageScale = (this.areaWidth - autoWidth) / this.viewport.width
660
- let curViewport = page.getViewport({
661
- scale: this.pageScale * CSS_UNITS
662
- })
663
- this.viewport = curViewport
664
-
665
- this.isFirstTimeRender = false
666
- },
667
- pdfScroll (e) {
668
- if(this.preViewType !== 'pdf' || this.isTouchMoved) {
669
- return
670
- }
671
- if(this.scrollTop != e.target.scrollTop) {
672
- this.scrollTop = e.target.scrollTop
673
- this.debounceScrollPdf(e, this)
674
- }
675
- },
676
- // 这里加了防抖保证不会一次产生过多请求
677
- debounceScrollPdf: _.debounce(async function (e, that) {
678
- if (that.fisrtLoad) {
679
- that.fisrtLoad = false
680
- return
681
- }
682
- const scrollTop = e.target.scrollTop;
683
- const height = e.target.clientHeight;
684
- let startNum = 0;
685
- let endNum = 0;
686
- // if (scrollTop + height == scrollHeight){
687
- // console.debug('=====',that.pages)
688
- // for (let i = 0 ;i< that.pages.length; i++){
689
- // if (!that.pages[i].loadStatus){
690
- // console.debug('loadStatus',that.pages[i])
691
- // const loadingState = await that.getPDF(that.pages[i].pageNo);
692
- // if (loadingState === 'success'){
693
- // that.initRenderOneByOne(that.pages[i].pageNo)
694
- // }
695
- // // that.renderPages(that.pages[i].pageNo)
696
- // break
697
- // }
698
- // }
699
- // }
700
- startNum = Math.ceil(scrollTop / (that.viewport.height + that.PAGE_INTVERVAL))
701
- endNum = startNum + Math.ceil(height / (that.viewport.height + that.PAGE_INTVERVAL))
702
- console.debug('scrollTop',scrollTop,that.viewport.height,startNum,endNum)
703
- if (startNum > 1){
704
- // for (let pageIndex = startNum; pageIndex < endNum; pageIndex++) {
705
- // if(pageIndex > 0 && pageIndex <= that.pages.length) {
706
- // console.debug('startNum',scrollTop,startNum,endNum,height,that.curCanvasCSSWh)
707
- // const loadingState = await that.getPDF(pageIndex);
708
- // if (loadingState === 'success') {
709
- // // that.renderPages(pageIndex + 1)
710
- // that.initRenderOneByOne(pageIndex)
711
- // // this.initTouch()
712
- // } else that.boxEl.innerText = loadingState
713
- // }
714
- // }
715
- }
716
- }, 200),
717
- renderHighlights(){
718
- let lineHeightDom = Array.from(document.getElementsByClassName('rectdom'))
719
- if (lineHeightDom) {
720
- lineHeightDom.forEach((d) => {
721
- for (let i = 0; i < d.children.length; i++) {
722
- if (d.getAttribute('react-count') == this.currentPage) {
723
- d.children[i].style.backgroundColor = 'rgba(255, 136, 0, 0.3)'
724
- d.children[i].classList.add('animation')
725
- setTimeout(() =>{
726
- d.children[i].classList.remove('animation')
727
- }, 4000)
728
- } else {
729
- d.children[i].style.backgroundColor = 'rgba(54, 106, 255, 0.3)'
730
- d.children[i].classList.remove('animation')
731
- }
732
- }
733
- })
734
- }
735
- }
736
- },
737
- watch:{
738
- tagIds: {
739
- handler(value) {
740
- console.debug('tagIds',value)
741
- if(value && value.length) {
742
- // 在 pdf_view 下创建 所有canvs的容器
743
- this.contentView = document.createElement('div')
744
- this.contentView.style.transformOrigin = '0px 0px 0px'
745
- this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res =>{
746
- if (res.data.code == 0) {
747
- // tagIds 会按照gpt识别的生成有序的数组,前端直接按照下标的顺序取就可以了
748
- // 缓存拿到的所有数据
749
- this.cachePdf = res.data.data
750
- console.debug('res',res.data.data[0])
751
- let publicPageFileUrl = res.data.data[0].publicPageFileUrl
752
- this.currentPage = 0;
753
- this.pdfUrl = res.data.data[0].publicPageFileUrl.substring(0, res.data.data[0].publicPageFileUrl.lastIndexOf('/') + 1)
754
- if (publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')) === '.pdf') {
755
- this.preViewType = 'pdf'
756
- // this.setPageAllLine(this.cachePdf)
757
- this.init(res.data.data[0])
758
- } else {
759
- this.preViewType = 'excal'
760
- this.$http.post(
761
- '/knowledge-api/temporary-certificate/or-origin?expired=30',
762
- publicPageFileUrl,
763
- {
764
- headers: {
765
- "Content-Type": "application/json",
766
- },
767
- }).then(res => {
768
- // 使用原声请求方式 axios会带有不需要的请求头
769
- let xhr = new XMLHttpRequest();
770
- xhr.open('GET', res.data || res.bodyText , true);
771
- // 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
772
- xhr.onload = ({ currentTarget }) => {
773
- // 请求完成
774
- if (currentTarget.status === 200) { // 返回200
775
- this.contentView.innerHTML = currentTarget.response
776
- this.contentView.style.padding = '10px'
777
- // this.contentView.style.position = 'relative'
778
- this.$refs.pdfView.style.backgroundColor = '#FFFFFF'
779
- this.$refs.pdfView.appendChild(this.contentView)
780
- let allTr = Array.from(this.$refs.pdfView.getElementsByTagName('tr'))
781
- this.allTr = []
782
- for (let index = 0; index < allTr.length; index++) {
783
- if(value.includes(allTr[index].getAttribute('tag-id'))) {
784
- this.allTr.push(allTr[index])
785
- }
786
- }
787
- this.currentChange(1)
788
-
789
- }
790
- }
791
- xhr.send();
792
- })
793
- }
794
- } else {
795
- let div = document.createElement('div')
796
- div.innerText = '文件加载异常'
797
- this.contentView.appendChild(div)
798
- this.$refs.pdfView.appendChild(this.contentView)
799
- }
800
- })
801
- }
802
- },
803
- deep:true,
804
- immediate:true
805
- }
806
- }
807
- }
808
- </script>
809
-
810
- <style scoped>
811
- .pdf-touch-box {
812
- padding: 9px;
813
- width: calc(100% - 18px);
814
- height: calc(100% - 18px);
815
- position: relative;
816
- overflow: auto;
817
- }
818
- .scale-btn-box {
819
- position: fixed;
820
- top: 0;
821
- left: 0;
822
- height: 44px;
823
- display: flex;
824
- justify-content: space-around;
825
- z-index: 99;
826
- }
827
- .scale-btn-box::after {
828
- content: '';
829
- width: 100%;
830
- height: 100%;
831
- position: absolute;
832
- background: #fff;
833
- top: 0;
834
- left: 0;
835
- filter: blur(18px);
836
- opacity: 0.8;
837
- }
838
- .scale-btn {
839
- position: relative;
840
- z-index: 2;
841
- width: 25%;
842
- height: 100%;
843
- display: inline-block;
844
- line-height: 1;
845
- white-space: nowrap;
846
- cursor: pointer;
847
- background: #fff;
848
- border: 1px solid #dcdfe6;
849
- color: #606266;
850
- -webkit-appearance: none;
851
- text-align: center;
852
- box-sizing: border-box;
853
- outline: none;
854
- margin: 0;
855
- transition: 0.1s;
856
- font-weight: 500;
857
- -moz-user-select: none;
858
- -webkit-user-select: none;
859
- -ms-user-select: none;
860
- padding: 12px 20px;
861
- font-size: 14px;
862
- border-radius: 4px;
863
- }
864
- .pdf-canvas-wrap {
865
- display: flex;
866
- flex-direction: column;
867
- align-items: center;
868
- overflow: hidden;
869
- /*margin-top: 44px;*/
870
- padding-top: 9px;
871
- /*height: 100%;*/
872
- /*overflow-y: scroll;*/
873
- /*position: absolute;*/
874
- }
875
- .pdf-canvas-tips {
876
- margin-top: 44px;
877
- }
878
- </style>