@spacecorexdev/core 0.0.2 → 0.0.5

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 (345) hide show
  1. package/package.json +20 -38
  2. package/public/cmaps/78-EUC-H.bcmap +0 -0
  3. package/public/cmaps/78-EUC-V.bcmap +0 -0
  4. package/public/cmaps/78-H.bcmap +0 -0
  5. package/public/cmaps/78-RKSJ-H.bcmap +0 -0
  6. package/public/cmaps/78-RKSJ-V.bcmap +0 -0
  7. package/public/cmaps/78-V.bcmap +0 -0
  8. package/public/cmaps/78ms-RKSJ-H.bcmap +0 -0
  9. package/public/cmaps/78ms-RKSJ-V.bcmap +0 -0
  10. package/public/cmaps/83pv-RKSJ-H.bcmap +0 -0
  11. package/public/cmaps/90ms-RKSJ-H.bcmap +0 -0
  12. package/public/cmaps/90ms-RKSJ-V.bcmap +0 -0
  13. package/public/cmaps/90msp-RKSJ-H.bcmap +0 -0
  14. package/public/cmaps/90msp-RKSJ-V.bcmap +0 -0
  15. package/public/cmaps/90pv-RKSJ-H.bcmap +0 -0
  16. package/public/cmaps/90pv-RKSJ-V.bcmap +0 -0
  17. package/public/cmaps/Add-H.bcmap +0 -0
  18. package/public/cmaps/Add-RKSJ-H.bcmap +0 -0
  19. package/public/cmaps/Add-RKSJ-V.bcmap +0 -0
  20. package/public/cmaps/Add-V.bcmap +0 -0
  21. package/public/cmaps/Adobe-CNS1-0.bcmap +0 -0
  22. package/public/cmaps/Adobe-CNS1-1.bcmap +0 -0
  23. package/public/cmaps/Adobe-CNS1-2.bcmap +0 -0
  24. package/public/cmaps/Adobe-CNS1-3.bcmap +0 -0
  25. package/public/cmaps/Adobe-CNS1-4.bcmap +0 -0
  26. package/public/cmaps/Adobe-CNS1-5.bcmap +0 -0
  27. package/public/cmaps/Adobe-CNS1-6.bcmap +0 -0
  28. package/public/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  29. package/public/cmaps/Adobe-GB1-0.bcmap +0 -0
  30. package/public/cmaps/Adobe-GB1-1.bcmap +0 -0
  31. package/public/cmaps/Adobe-GB1-2.bcmap +0 -0
  32. package/public/cmaps/Adobe-GB1-3.bcmap +0 -0
  33. package/public/cmaps/Adobe-GB1-4.bcmap +0 -0
  34. package/public/cmaps/Adobe-GB1-5.bcmap +0 -0
  35. package/public/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  36. package/public/cmaps/Adobe-Japan1-0.bcmap +0 -0
  37. package/public/cmaps/Adobe-Japan1-1.bcmap +0 -0
  38. package/public/cmaps/Adobe-Japan1-2.bcmap +0 -0
  39. package/public/cmaps/Adobe-Japan1-3.bcmap +0 -0
  40. package/public/cmaps/Adobe-Japan1-4.bcmap +0 -0
  41. package/public/cmaps/Adobe-Japan1-5.bcmap +0 -0
  42. package/public/cmaps/Adobe-Japan1-6.bcmap +0 -0
  43. package/public/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  44. package/public/cmaps/Adobe-Korea1-0.bcmap +0 -0
  45. package/public/cmaps/Adobe-Korea1-1.bcmap +0 -0
  46. package/public/cmaps/Adobe-Korea1-2.bcmap +0 -0
  47. package/public/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  48. package/public/cmaps/B5-H.bcmap +0 -0
  49. package/public/cmaps/B5-V.bcmap +0 -0
  50. package/public/cmaps/B5pc-H.bcmap +0 -0
  51. package/public/cmaps/B5pc-V.bcmap +0 -0
  52. package/public/cmaps/CNS-EUC-H.bcmap +0 -0
  53. package/public/cmaps/CNS-EUC-V.bcmap +0 -0
  54. package/public/cmaps/CNS1-H.bcmap +0 -0
  55. package/public/cmaps/CNS1-V.bcmap +0 -0
  56. package/public/cmaps/CNS2-H.bcmap +0 -0
  57. package/public/cmaps/CNS2-V.bcmap +3 -0
  58. package/public/cmaps/ETHK-B5-H.bcmap +0 -0
  59. package/public/cmaps/ETHK-B5-V.bcmap +0 -0
  60. package/public/cmaps/ETen-B5-H.bcmap +0 -0
  61. package/public/cmaps/ETen-B5-V.bcmap +0 -0
  62. package/public/cmaps/ETenms-B5-H.bcmap +3 -0
  63. package/public/cmaps/ETenms-B5-V.bcmap +0 -0
  64. package/public/cmaps/EUC-H.bcmap +0 -0
  65. package/public/cmaps/EUC-V.bcmap +0 -0
  66. package/public/cmaps/Ext-H.bcmap +0 -0
  67. package/public/cmaps/Ext-RKSJ-H.bcmap +0 -0
  68. package/public/cmaps/Ext-RKSJ-V.bcmap +0 -0
  69. package/public/cmaps/Ext-V.bcmap +0 -0
  70. package/public/cmaps/GB-EUC-H.bcmap +0 -0
  71. package/public/cmaps/GB-EUC-V.bcmap +0 -0
  72. package/public/cmaps/GB-H.bcmap +4 -0
  73. package/public/cmaps/GB-V.bcmap +0 -0
  74. package/public/cmaps/GBK-EUC-H.bcmap +0 -0
  75. package/public/cmaps/GBK-EUC-V.bcmap +0 -0
  76. package/public/cmaps/GBK2K-H.bcmap +0 -0
  77. package/public/cmaps/GBK2K-V.bcmap +0 -0
  78. package/public/cmaps/GBKp-EUC-H.bcmap +0 -0
  79. package/public/cmaps/GBKp-EUC-V.bcmap +0 -0
  80. package/public/cmaps/GBT-EUC-H.bcmap +0 -0
  81. package/public/cmaps/GBT-EUC-V.bcmap +0 -0
  82. package/public/cmaps/GBT-H.bcmap +0 -0
  83. package/public/cmaps/GBT-V.bcmap +0 -0
  84. package/public/cmaps/GBTpc-EUC-H.bcmap +0 -0
  85. package/public/cmaps/GBTpc-EUC-V.bcmap +0 -0
  86. package/public/cmaps/GBpc-EUC-H.bcmap +0 -0
  87. package/public/cmaps/GBpc-EUC-V.bcmap +0 -0
  88. package/public/cmaps/H.bcmap +0 -0
  89. package/public/cmaps/HKdla-B5-H.bcmap +0 -0
  90. package/public/cmaps/HKdla-B5-V.bcmap +0 -0
  91. package/public/cmaps/HKdlb-B5-H.bcmap +0 -0
  92. package/public/cmaps/HKdlb-B5-V.bcmap +0 -0
  93. package/public/cmaps/HKgccs-B5-H.bcmap +0 -0
  94. package/public/cmaps/HKgccs-B5-V.bcmap +0 -0
  95. package/public/cmaps/HKm314-B5-H.bcmap +0 -0
  96. package/public/cmaps/HKm314-B5-V.bcmap +0 -0
  97. package/public/cmaps/HKm471-B5-H.bcmap +0 -0
  98. package/public/cmaps/HKm471-B5-V.bcmap +0 -0
  99. package/public/cmaps/HKscs-B5-H.bcmap +0 -0
  100. package/public/cmaps/HKscs-B5-V.bcmap +0 -0
  101. package/public/cmaps/Hankaku.bcmap +0 -0
  102. package/public/cmaps/Hiragana.bcmap +0 -0
  103. package/public/cmaps/KSC-EUC-H.bcmap +0 -0
  104. package/public/cmaps/KSC-EUC-V.bcmap +0 -0
  105. package/public/cmaps/KSC-H.bcmap +0 -0
  106. package/public/cmaps/KSC-Johab-H.bcmap +0 -0
  107. package/public/cmaps/KSC-Johab-V.bcmap +0 -0
  108. package/public/cmaps/KSC-V.bcmap +0 -0
  109. package/public/cmaps/KSCms-UHC-H.bcmap +0 -0
  110. package/public/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  111. package/public/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  112. package/public/cmaps/KSCms-UHC-V.bcmap +0 -0
  113. package/public/cmaps/KSCpc-EUC-H.bcmap +0 -0
  114. package/public/cmaps/KSCpc-EUC-V.bcmap +0 -0
  115. package/public/cmaps/Katakana.bcmap +0 -0
  116. package/public/cmaps/LICENSE +36 -0
  117. package/public/cmaps/NWP-H.bcmap +0 -0
  118. package/public/cmaps/NWP-V.bcmap +0 -0
  119. package/public/cmaps/RKSJ-H.bcmap +0 -0
  120. package/public/cmaps/RKSJ-V.bcmap +0 -0
  121. package/public/cmaps/Roman.bcmap +0 -0
  122. package/public/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  123. package/public/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  124. package/public/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  125. package/public/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  126. package/public/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  127. package/public/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  128. package/public/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  129. package/public/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  130. package/public/cmaps/UniGB-UCS2-H.bcmap +0 -0
  131. package/public/cmaps/UniGB-UCS2-V.bcmap +0 -0
  132. package/public/cmaps/UniGB-UTF16-H.bcmap +0 -0
  133. package/public/cmaps/UniGB-UTF16-V.bcmap +0 -0
  134. package/public/cmaps/UniGB-UTF32-H.bcmap +0 -0
  135. package/public/cmaps/UniGB-UTF32-V.bcmap +0 -0
  136. package/public/cmaps/UniGB-UTF8-H.bcmap +0 -0
  137. package/public/cmaps/UniGB-UTF8-V.bcmap +0 -0
  138. package/public/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  139. package/public/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  140. package/public/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  141. package/public/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  142. package/public/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  143. package/public/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  144. package/public/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  145. package/public/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  146. package/public/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  147. package/public/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  148. package/public/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  149. package/public/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  150. package/public/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  151. package/public/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  152. package/public/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  153. package/public/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  154. package/public/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  155. package/public/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  156. package/public/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  157. package/public/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  158. package/public/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  159. package/public/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  160. package/public/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  161. package/public/cmaps/UniKS-UCS2-H.bcmap +0 -0
  162. package/public/cmaps/UniKS-UCS2-V.bcmap +0 -0
  163. package/public/cmaps/UniKS-UTF16-H.bcmap +0 -0
  164. package/public/cmaps/UniKS-UTF16-V.bcmap +0 -0
  165. package/public/cmaps/UniKS-UTF32-H.bcmap +0 -0
  166. package/public/cmaps/UniKS-UTF32-V.bcmap +0 -0
  167. package/public/cmaps/UniKS-UTF8-H.bcmap +0 -0
  168. package/public/cmaps/UniKS-UTF8-V.bcmap +0 -0
  169. package/public/cmaps/V.bcmap +0 -0
  170. package/public/cmaps/WP-Symbol.bcmap +0 -0
  171. package/public/polyfills/polyfills.js +802 -0
  172. package/public/vendor/docx/docx.worker.js +5 -0
  173. package/public/vendor/docx/jszip.min.js +13 -0
  174. package/public/vendor/libarchive/libarchive.wasm +0 -0
  175. package/public/vendor/libarchive/worker-bundle.js +6 -0
  176. package/public/vendor/pptx/pptx.worker.js +26 -0
  177. package/public/wasm/cad/0.8.2/dwfv-render.wasm +0 -0
  178. package/public/wasm/cad/0.8.2/dwg-worker.js +24 -0
  179. package/public/wasm/cad/0.8.2/dwg-worker.js.map +1 -0
  180. package/public/wasm/cad/0.8.2/libredwg-web.js +2 -0
  181. package/public/wasm/cad/0.8.2/libredwg-web.wasm +0 -0
  182. package/public/wasm/cad/dwfv-render.wasm +0 -0
  183. package/public/wasm/cad/dwg-worker.js +24 -0
  184. package/public/wasm/cad/dwg-worker.js.map +1 -0
  185. package/public/wasm/cad/libredwg-web.js +2 -0
  186. package/public/wasm/cad/libredwg-web.wasm +0 -0
  187. package/public/wasm/data/sql-wasm.wasm +0 -0
  188. package/public/wasm/hdiff.wasm +0 -0
  189. package/public/wasm/model/LICENSE.occt-import-js.txt +504 -0
  190. package/public/wasm/model/LICENSE.occt.txt +502 -0
  191. package/public/wasm/model/occt-import-js.js +19 -0
  192. package/public/wasm/model/occt-import-js.wasm +0 -0
  193. package/public/wasm/model/occt-worker.js +83 -0
  194. package/public/wasm/typst/fonts/DejaVuSansMono-Bold.ttf +0 -0
  195. package/public/wasm/typst/fonts/DejaVuSansMono-BoldOblique.ttf +0 -0
  196. package/public/wasm/typst/fonts/DejaVuSansMono-Oblique.ttf +0 -0
  197. package/public/wasm/typst/fonts/DejaVuSansMono.ttf +0 -0
  198. package/public/wasm/typst/fonts/LibertinusSerif-Bold.otf +0 -0
  199. package/public/wasm/typst/fonts/LibertinusSerif-BoldItalic.otf +0 -0
  200. package/public/wasm/typst/fonts/LibertinusSerif-Italic.otf +0 -0
  201. package/public/wasm/typst/fonts/LibertinusSerif-Regular.otf +0 -0
  202. package/public/wasm/typst/fonts/LibertinusSerif-Semibold.otf +0 -0
  203. package/public/wasm/typst/fonts/LibertinusSerif-SemiboldItalic.otf +0 -0
  204. package/public/wasm/typst/fonts/NewCM10-Bold.otf +0 -0
  205. package/public/wasm/typst/fonts/NewCM10-BoldItalic.otf +0 -0
  206. package/public/wasm/typst/fonts/NewCM10-Italic.otf +0 -0
  207. package/public/wasm/typst/fonts/NewCM10-Regular.otf +0 -0
  208. package/public/wasm/typst/fonts/NewCMMath-Bold.otf +0 -0
  209. package/public/wasm/typst/fonts/NewCMMath-Book.otf +0 -0
  210. package/public/wasm/typst/fonts/NewCMMath-Regular.otf +0 -0
  211. package/public/wasm/typst/fonts/README.md +7 -0
  212. package/public/wasm/typst/typst_ts_renderer_bg.wasm +0 -0
  213. package/public/wasm/typst/typst_ts_web_compiler_bg.wasm +0 -0
  214. package/scripts/patch-docx-grid.cjs +412 -0
  215. package/src/api/_base.ts +243 -0
  216. package/src/api/index.ts +17 -0
  217. package/src/api/project.ts +1345 -0
  218. package/src/api/user.ts +1174 -0
  219. package/src/contract.ts +50 -0
  220. package/src/hooks/index.ts +2 -0
  221. package/{dist/hooks/index.js → src/hooks/useLongPress.ts} +53 -49
  222. package/src/hooks/useOnlineStatus.ts +22 -0
  223. package/src/index.ts +14 -0
  224. package/src/types/id.ts +2 -0
  225. package/src/types/index.ts +5 -0
  226. package/src/types/project/base.ts +63 -0
  227. package/src/types/project/contract.ts +79 -0
  228. package/src/types/project/contractStatus.tsx +15 -0
  229. package/src/types/project/index.ts +5 -0
  230. package/src/types/project/member.ts +46 -0
  231. package/src/types/project/progress.ts +43 -0
  232. package/src/types/projectRole.ts +17 -0
  233. package/src/types/theme.ts +1 -0
  234. package/src/types/user/index.ts +1 -0
  235. package/src/types/user/role.ts +7 -0
  236. package/src/ui/CommentTimeline/index.tsx +330 -0
  237. package/src/ui/FileManager/FileContextMenu.tsx +628 -0
  238. package/src/ui/FileManager/FileGridView.tsx +529 -0
  239. package/src/ui/FileManager/FileTableView.tsx +405 -0
  240. package/src/ui/FileManager/FileToolbar.tsx +119 -0
  241. package/src/ui/FileManager/FileVersionHistoryModal.tsx +175 -0
  242. package/src/ui/FileManager/MoveCopyToProjectModal.tsx +119 -0
  243. package/src/ui/FileManager/ShareToWechatModal.tsx +419 -0
  244. package/src/ui/FileManager/hooks/useFileManagerActions.ts +2532 -0
  245. package/src/ui/FileManager/hooks/useFileManagerState.ts +419 -0
  246. package/src/ui/FileManager/index.tsx +580 -0
  247. package/src/ui/FileManager/projectFileManagerApi.ts +57 -0
  248. package/src/ui/FileManager/types.ts +184 -0
  249. package/src/ui/FileManager/utils/fileDeltaWorker.ts +193 -0
  250. package/src/ui/FileManager/utils/fileTree.ts +178 -0
  251. package/src/ui/FileManager/utils/fileUpload.ts +714 -0
  252. package/src/ui/FileManager/utils/fileUtils.ts +65 -0
  253. package/src/ui/InvoiceRecordsList/index.tsx +813 -0
  254. package/src/ui/MyFileSelectorModal.tsx +261 -0
  255. package/src/ui/ProjectSelector/index.tsx +472 -0
  256. package/src/ui/ProjectSelector/projectCache.ts +40 -0
  257. package/src/ui/RoleSelector/index.tsx +473 -0
  258. package/src/ui/RoleSelector/roleCache.ts +40 -0
  259. package/src/ui/UIAlert.tsx +399 -0
  260. package/src/ui/UIAlertExample.tsx +129 -0
  261. package/src/ui/UIConfirm.tsx +335 -0
  262. package/src/ui/UIConfirmExample.tsx +165 -0
  263. package/src/ui/UIDatePicker.tsx +146 -0
  264. package/src/ui/UIDateRangePicker.tsx +38 -0
  265. package/src/ui/UIFilePreview/ExcelEditor/index.tsx +617 -0
  266. package/src/ui/UIFilePreview/ExcelEditor/types.ts +24 -0
  267. package/src/ui/UIFilePreview/ExportDropdown.css +85 -0
  268. package/src/ui/UIFilePreview/ExportDropdown.tsx +109 -0
  269. package/src/ui/UIFilePreview/IndexedDBUtils.ts +564 -0
  270. package/src/ui/UIFilePreview/MarkdownEditor/exportMarkdownPdf.ts +576 -0
  271. package/src/ui/UIFilePreview/MarkdownEditor/index.tsx +677 -0
  272. package/src/ui/UIFilePreview/MarkdownEditor/markdownEditor.css +1005 -0
  273. package/src/ui/UIFilePreview/MarkdownEditor/types.ts +15 -0
  274. package/src/ui/UIFilePreview/PPTXEditor/index.tsx +602 -0
  275. package/src/ui/UIFilePreview/RichDocEditor/exportRDocMarkdown.ts +77 -0
  276. package/src/ui/UIFilePreview/RichDocEditor/exportRDocPdf.ts +374 -0
  277. package/src/ui/UIFilePreview/RichDocEditor/index.tsx +730 -0
  278. package/src/ui/UIFilePreview/RichDocEditor/richdoc-editor.css +59 -0
  279. package/src/ui/UIFilePreview/UIFilePreview.tsx +611 -0
  280. package/src/ui/UIFilePreview/WordEditor/index.tsx +3933 -0
  281. package/src/ui/UIFilePreview/WordEditor/style.ts +1213 -0
  282. package/src/ui/UIFilePreview/WordEditor/word-editor.css +999 -0
  283. package/src/ui/UIFilePreview/filePreview.css +193 -0
  284. package/src/ui/UIFilePreview/filetypes/archive.tsx +66 -0
  285. package/src/ui/UIFilePreview/filetypes/cad.tsx +287 -0
  286. package/src/ui/UIFilePreview/filetypes/excel.tsx +355 -0
  287. package/src/ui/UIFilePreview/filetypes/image.tsx +20 -0
  288. package/src/ui/UIFilePreview/filetypes/imageLoader.ts +63 -0
  289. package/src/ui/UIFilePreview/filetypes/pdf.tsx +156 -0
  290. package/src/ui/UIFilePreview/filetypes/ppt.tsx +535 -0
  291. package/src/ui/UIFilePreview/filetypes/pptExportPdf.ts +523 -0
  292. package/src/ui/UIFilePreview/filetypes/video.tsx +482 -0
  293. package/src/ui/UIFilePreview/filetypes/word.tsx +245 -0
  294. package/src/ui/UIFilePreview/filetypes/wordExportMarkdown.ts +86 -0
  295. package/src/ui/UIFilePreview/filetypes/wordExportPdf.tsx +427 -0
  296. package/src/ui/UIFilePreview/index.ts +35 -0
  297. package/src/ui/UIFilePreview/pdfPagination.ts +143 -0
  298. package/src/ui/UIFilePreview/previewUtils.tsx +531 -0
  299. package/src/ui/UIFileUpload.tsx +382 -0
  300. package/src/ui/UIImageUpload.tsx +195 -0
  301. package/src/ui/UILoading.tsx +255 -0
  302. package/src/ui/UILoadingExample.tsx +139 -0
  303. package/src/ui/UISelect.tsx +105 -0
  304. package/src/ui/UIToast.tsx +381 -0
  305. package/src/ui/UIToastExample.tsx +69 -0
  306. package/src/ui/UIToastSingle.tsx +279 -0
  307. package/src/ui/UIViewToggle.tsx +64 -0
  308. package/src/ui/UserSelector/index.tsx +583 -0
  309. package/src/ui/index.ts +84 -0
  310. package/src/ui/upload/image.ts +135 -0
  311. package/src/ui/upload/index.ts +73 -0
  312. package/src/ui/upload/submitFile.ts +106 -0
  313. package/src/ui/upload/submitForm.ts +124 -0
  314. package/src/ui/upload/upload.err.ts +15 -0
  315. package/src/ui/upload/upload.ts +250 -0
  316. package/src/utils/CacheDepartmentInfo.ts +372 -0
  317. package/src/utils/CacheFileContent.ts +315 -0
  318. package/src/utils/CachePermissionInfo.ts +235 -0
  319. package/src/utils/CacheRoleInfo.ts +303 -0
  320. package/src/utils/CacheUserInfo.ts +818 -0
  321. package/src/utils/CacheViewToggleInfo.ts +182 -0
  322. package/src/utils/MessageContentUtils.ts +268 -0
  323. package/src/utils/clipboard.ts +70 -0
  324. package/src/utils/companyEmail.ts +19 -0
  325. package/src/utils/forbidDebugger.ts +59 -0
  326. package/src/utils/formatters.ts +94 -0
  327. package/src/utils/htmlUtils.tsx +59 -0
  328. package/src/utils/index.ts +18 -0
  329. package/src/utils/keyboard.ts +114 -0
  330. package/src/utils/mammothApi.ts +16 -0
  331. package/src/utils/polyfills.ts +928 -0
  332. package/src/utils/regex.ts +14 -0
  333. package/src/utils/storage.ts +95 -0
  334. package/src/utils/workerBootstrap.ts +87 -0
  335. package/dist/api/index.js +0 -1553
  336. package/dist/contract.js +0 -5
  337. package/dist/index.js +0 -4492
  338. package/dist/types/index.js +0 -49
  339. package/dist/ui/index.css +0 -1876
  340. package/dist/ui/index.js +0 -22245
  341. package/dist/utils/index.js +0 -4296
  342. /package/{dist → src}/styles/ant-modal.css +0 -0
  343. /package/{dist → src}/styles/ant-spin.css +0 -0
  344. /package/{dist → src}/styles/ant-table.css +0 -0
  345. /package/{dist → src}/styles/index.css +0 -0
@@ -1,4296 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
3
- var __export = (target, all) => {
4
- for (var name in all)
5
- __defProp(target, name, { get: all[name], enumerable: true });
6
- };
7
- var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
8
-
9
- // src/utils/CacheDepartmentInfo.ts
10
- import Dexie from "dexie";
11
-
12
- // src/api/_base.ts
13
- var base_exports = {};
14
- __export(base_exports, {
15
- AuthorizationHandler: () => AuthorizationHandler,
16
- HttpRequest: () => HttpRequest,
17
- ResponseCode: () => ResponseCode
18
- });
19
- import axios, { AxiosError } from "axios";
20
-
21
- // src/ui/UIToast.tsx
22
- import { useEffect, useState, useRef } from "react";
23
- import { notification } from "antd";
24
- import { CheckCircleOutlined, CloseCircleOutlined, InfoCircleOutlined, WarningOutlined } from "@ant-design/icons";
25
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
26
- var iconMap = {
27
- success: /* @__PURE__ */ jsx(CheckCircleOutlined, { style: { color: "#52c41a" } }),
28
- error: /* @__PURE__ */ jsx(CloseCircleOutlined, { style: { color: "#ff4d4f" } }),
29
- info: /* @__PURE__ */ jsx(InfoCircleOutlined, { style: { color: "#1677ff" } }),
30
- warning: /* @__PURE__ */ jsx(WarningOutlined, { style: { color: "#faad14" } })
31
- };
32
- notification.config({
33
- placement: "topRight",
34
- duration: 3,
35
- // 确保 toast 显示在全屏 Modal(z-index 1000+)之上,避免被弹窗遮挡
36
- ...{ zIndex: 1e4 }
37
- });
38
- var _SingletonToastManager = class _SingletonToastManager {
39
- constructor() {
40
- __publicField(this, "currentToast", null);
41
- __publicField(this, "api", null);
42
- __publicField(this, "isInitialized", false);
43
- __publicField(this, "pendingToast", null);
44
- }
45
- static getInstance() {
46
- if (!_SingletonToastManager.instance) {
47
- _SingletonToastManager.instance = new _SingletonToastManager();
48
- }
49
- return _SingletonToastManager.instance;
50
- }
51
- // 初始化 API
52
- init(api2) {
53
- this.api = api2;
54
- this.isInitialized = true;
55
- if (this.pendingToast) {
56
- const config = this.pendingToast;
57
- this.pendingToast = null;
58
- this.show(config);
59
- }
60
- }
61
- // 显示全局唯一Toast
62
- show(config) {
63
- const { key: key2, type, message: message2, descs, duration, placement, onClose } = config;
64
- if (!this.isInitialized || !this.api) {
65
- this.pendingToast = config;
66
- return;
67
- }
68
- if (this.currentToast?.timer) {
69
- clearTimeout(this.currentToast.timer);
70
- }
71
- if (this.currentToast && this.currentToast.key === key2) {
72
- notification.destroy(key2);
73
- this.createNotification({ key: key2, type, message: message2, descs, duration, placement, onClose });
74
- } else {
75
- if (this.currentToast) {
76
- notification.destroy(this.currentToast.key);
77
- }
78
- this.createNotification({ key: key2, type, message: message2, descs, duration, placement, onClose });
79
- }
80
- }
81
- // 创建通知
82
- createNotification(config) {
83
- if (!this.api) return;
84
- const { key: key2, type, message: message2, descs, duration, placement, onClose } = config;
85
- const notificationMethod = {
86
- success: this.api.success.bind(this.api),
87
- error: this.api.error.bind(this.api),
88
- info: this.api.info.bind(this.api),
89
- warning: this.api.warning.bind(this.api)
90
- }[type];
91
- notificationMethod({
92
- key: key2,
93
- message: message2,
94
- description: descs,
95
- duration,
96
- placement: placement || "topRight",
97
- icon: iconMap[type],
98
- onClose: () => {
99
- if (this.currentToast?.key === key2) {
100
- if (this.currentToast.timer) {
101
- clearTimeout(this.currentToast.timer);
102
- }
103
- this.currentToast = null;
104
- }
105
- onClose?.();
106
- }
107
- });
108
- this.currentToast = {
109
- key: key2,
110
- type,
111
- message: message2,
112
- descs,
113
- duration,
114
- placement,
115
- timer: null
116
- };
117
- }
118
- // 关闭当前 toast
119
- close() {
120
- if (this.currentToast) {
121
- if (this.currentToast.timer) {
122
- clearTimeout(this.currentToast.timer);
123
- }
124
- notification.destroy(this.currentToast.key);
125
- this.currentToast = null;
126
- }
127
- }
128
- // 销毁所有 toast
129
- destroy() {
130
- this.close();
131
- notification.destroy();
132
- }
133
- };
134
- __publicField(_SingletonToastManager, "instance");
135
- var SingletonToastManager = _SingletonToastManager;
136
- var singletonManager = SingletonToastManager.getInstance();
137
- function parseToastOptions(options) {
138
- if (typeof options === "string") {
139
- return { message: options, duration: 3 };
140
- }
141
- return options;
142
- }
143
- function getIcon(type) {
144
- return iconMap[type];
145
- }
146
- var uiToast = {
147
- success: (options) => {
148
- if (!options) return;
149
- const config = parseToastOptions(options);
150
- notification.success({
151
- message: config.message,
152
- description: config.descs,
153
- duration: config.duration,
154
- placement: config.placement,
155
- icon: getIcon("success"),
156
- onClose: config.onClose
157
- });
158
- },
159
- error: (options) => {
160
- if (!options) return;
161
- const config = parseToastOptions(options);
162
- notification.error({
163
- message: config.message,
164
- description: config.descs,
165
- duration: config.duration,
166
- placement: config.placement,
167
- icon: getIcon("error"),
168
- onClose: config.onClose
169
- });
170
- },
171
- info: (options) => {
172
- if (!options) return;
173
- const config = parseToastOptions(options);
174
- notification.info({
175
- message: config.message,
176
- description: config.descs,
177
- duration: config.duration,
178
- placement: config.placement,
179
- icon: getIcon("info"),
180
- onClose: config.onClose
181
- });
182
- },
183
- warning: (options) => {
184
- if (!options) return;
185
- const config = parseToastOptions(options);
186
- notification.warning({
187
- message: config.message,
188
- description: config.descs,
189
- duration: config.duration,
190
- placement: config.placement,
191
- icon: getIcon("warning"),
192
- onClose: config.onClose
193
- });
194
- },
195
- // 自定义类型的toast
196
- custom: (type, options) => {
197
- const { message: message2, descs, duration, placement, onClose } = options;
198
- notification[type]({
199
- message: message2,
200
- description: descs,
201
- duration,
202
- placement,
203
- icon: getIcon(type),
204
- onClose
205
- });
206
- }
207
- };
208
- var UIToast_default = uiToast;
209
-
210
- // src/ui/UILoading.tsx
211
- import { Spin } from "antd";
212
- import { LoadingOutlined } from "@ant-design/icons";
213
- import { createRoot } from "react-dom/client";
214
- import { jsx as jsx2 } from "react/jsx-runtime";
215
- var loadingSymbol = /* @__PURE__ */ Symbol("loading");
216
- function getLoadingGlobalProps() {
217
- let props = window[loadingSymbol];
218
- if (!props) {
219
- props = { count: 0, timeoutId: 0, inTimeout: false };
220
- window[loadingSymbol] = props;
221
- }
222
- return props;
223
- }
224
- var defaultOptions = {
225
- tip: "",
226
- fullscreen: true,
227
- delay: 0,
228
- mask: true,
229
- iconSize: 40,
230
- wrapperClassName: "ui-loading-wrapper"
231
- };
232
- var UILoading = (props) => {
233
- const options = { ...defaultOptions, ...props };
234
- const {
235
- tip,
236
- fullscreen,
237
- mask,
238
- maskStyle,
239
- iconSize,
240
- iconStyle,
241
- containerStyle,
242
- wrapperClassName
243
- } = options;
244
- const loadingIcon = /* @__PURE__ */ jsx2(
245
- LoadingOutlined,
246
- {
247
- style: {
248
- fontSize: iconSize,
249
- color: "#1677ff",
250
- ...iconStyle
251
- },
252
- spin: true
253
- }
254
- );
255
- const fullscreenStyle = fullscreen ? {
256
- position: "fixed",
257
- top: 0,
258
- left: 0,
259
- right: 0,
260
- bottom: 0,
261
- zIndex: 9999,
262
- display: "flex",
263
- justifyContent: "center",
264
- alignItems: "center",
265
- backgroundColor: mask ? "rgba(0, 0, 0, 0.45)" : "transparent",
266
- ...maskStyle
267
- } : {};
268
- const containerStyles = {
269
- display: "flex",
270
- flexDirection: "column",
271
- alignItems: "center",
272
- justifyContent: "center",
273
- ...containerStyle
274
- };
275
- return /* @__PURE__ */ jsx2("div", { style: fullscreenStyle, className: wrapperClassName, children: /* @__PURE__ */ jsx2("div", { style: containerStyles, children: /* @__PURE__ */ jsx2(Spin, { indicator: loadingIcon, children: tip }) }) });
276
- };
277
- var loadingInstance = null;
278
- var rootInstance = null;
279
- var createLoadingInstance = (options = {}) => {
280
- if (loadingInstance && rootInstance) {
281
- rootInstance.unmount();
282
- document.body.removeChild(loadingInstance);
283
- loadingInstance = null;
284
- rootInstance = null;
285
- }
286
- loadingInstance = document.createElement("div");
287
- document.body.appendChild(loadingInstance);
288
- rootInstance = createRoot(loadingInstance);
289
- rootInstance.render(/* @__PURE__ */ jsx2(UILoading, { ...options }));
290
- return loadingInstance;
291
- };
292
- var uiLoading = {
293
- // 显示加载
294
- show: (options = {}) => {
295
- let props = getLoadingGlobalProps();
296
- props.count++;
297
- const mergedOptions = { ...defaultOptions, ...options };
298
- if (mergedOptions.delay && mergedOptions.delay > 0) {
299
- if (props.timeoutId != 0) {
300
- window.clearTimeout(props.timeoutId);
301
- props.timeoutId = 0;
302
- }
303
- props.timeoutId = window.setTimeout(() => {
304
- props.timeoutId = 0;
305
- createLoadingInstance(mergedOptions);
306
- }, mergedOptions.delay);
307
- return;
308
- } else {
309
- createLoadingInstance(mergedOptions);
310
- }
311
- },
312
- // 隐藏加载
313
- hide: () => {
314
- let props = getLoadingGlobalProps();
315
- if (props.count <= 0) {
316
- console.warn("Loading count is less than 0");
317
- return;
318
- }
319
- props.count--;
320
- if (props.timeoutId != 0) {
321
- window.clearTimeout(props.timeoutId);
322
- props.timeoutId = 0;
323
- }
324
- if (props.count == 0 && loadingInstance && rootInstance) {
325
- rootInstance.unmount();
326
- document.body.removeChild(loadingInstance);
327
- loadingInstance = null;
328
- rootInstance = null;
329
- }
330
- },
331
- // 服务方法 - 自动在Promise完成后隐藏
332
- service: (promise, options = {}) => {
333
- uiLoading.show(options);
334
- return promise.then((res) => {
335
- uiLoading.hide();
336
- return res;
337
- }).catch((err) => {
338
- uiLoading.hide();
339
- throw err;
340
- });
341
- }
342
- };
343
- var UILoading_default = uiLoading;
344
-
345
- // src/api/_base.ts
346
- import * as febs2 from "febs-browser";
347
-
348
- // src/utils/storage.ts
349
- import * as febs from "febs-browser";
350
- import store from "store2";
351
- var Store = class {
352
- constructor(s) {
353
- __publicField(this, "s");
354
- this.s = s;
355
- }
356
- /**
357
- * @descs: 数据条数.
358
- */
359
- get length() {
360
- return this.s.size();
361
- }
362
- /**
363
- * @descs: 所有的key.
364
- */
365
- keys() {
366
- return this.s.keys();
367
- }
368
- /**
369
- * @descs: 设置信息.
370
- */
371
- set(key2, data) {
372
- if (!data) {
373
- return this.remove(key2);
374
- }
375
- data = JSON.stringify(data);
376
- data = febs.crypt.base64_encode(data);
377
- this.s.set(key2, data, true);
378
- return this;
379
- }
380
- /**
381
- * @descs: 获取信息.
382
- * @param alt: 如果获取不到信息, 使用此数据返回.
383
- */
384
- get(key2, alt = null) {
385
- if (!this.s.has(key2)) {
386
- return alt;
387
- }
388
- let r = this.s.get(key2);
389
- if (r) {
390
- r = febs.crypt.base64_decode(r);
391
- r = febs.string.bytesToUtf8(r || []);
392
- try {
393
- return JSON.parse(r);
394
- } catch (e) {
395
- this.remove(key2);
396
- return null;
397
- }
398
- }
399
- return r;
400
- }
401
- /**
402
- * @descs: 移除信息.
403
- */
404
- remove(key2) {
405
- this.s.remove(key2);
406
- return this;
407
- }
408
- /**
409
- * @descs: 清空.
410
- */
411
- clear() {
412
- this.s.clearAll();
413
- return this;
414
- }
415
- };
416
- var storage = {
417
- /**
418
- * @descs: 通用命名空间获取一个新的store.
419
- */
420
- namespace: function(nm) {
421
- return new Store(store.namespace(nm || "default"));
422
- },
423
- /**
424
- * @descs: 使用session方式存储.
425
- */
426
- namespace_session: function(nm) {
427
- return new Store(store.session.namespace(nm || "default"));
428
- }
429
- };
430
-
431
- // src/api/_base.ts
432
- var ResponseCode = /* @__PURE__ */ ((ResponseCode4) => {
433
- ResponseCode4[ResponseCode4["SUCCESS"] = 200] = "SUCCESS";
434
- ResponseCode4[ResponseCode4["OPERATOR_ERROR"] = 400] = "OPERATOR_ERROR";
435
- ResponseCode4[ResponseCode4["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
436
- ResponseCode4[ResponseCode4["UNPERMISSION"] = 402] = "UNPERMISSION";
437
- ResponseCode4[ResponseCode4["NOT_FOUND"] = 404] = "NOT_FOUND";
438
- ResponseCode4[ResponseCode4["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
439
- ResponseCode4[ResponseCode4["PARAM_ERROR"] = 601] = "PARAM_ERROR";
440
- ResponseCode4[ResponseCode4["REQUEST_LIMIT"] = 602] = "REQUEST_LIMIT";
441
- return ResponseCode4;
442
- })(ResponseCode || {});
443
- function getResponseCodeMsg(code) {
444
- switch (code) {
445
- case 404 /* NOT_FOUND */:
446
- return "\u8D44\u6E90\u4E0D\u5B58\u5728";
447
- case 400 /* OPERATOR_ERROR */:
448
- return "\u7CFB\u7EDF\u64CD\u4F5C\u9519\u8BEF";
449
- case 601 /* PARAM_ERROR */:
450
- return "\u53C2\u6570\u9519\u8BEF";
451
- case 602 /* REQUEST_LIMIT */:
452
- return "\u8FBE\u5230\u8BBF\u95EE\u9650\u5236";
453
- case 503 /* SERVICE_UNAVAILABLE */:
454
- return "\u670D\u52A1\u4E0D\u53EF\u7528";
455
- case 401 /* UNAUTHORIZED */:
456
- return "\u672A\u767B\u5F55";
457
- case 402 /* UNPERMISSION */:
458
- return "\u65E0\u6743\u9650";
459
- default:
460
- return "\u672A\u77E5\u9519\u8BEF";
461
- }
462
- }
463
- var api = axios.create({
464
- baseURL: import.meta.env.VITE_API_BASE,
465
- timeout: Number(import.meta.env.VITE_API_TIMEOUT) || 5e3,
466
- headers: {
467
- "Content-Type": "application/json;charset=UTF-8"
468
- },
469
- withCredentials: true
470
- });
471
- var _AuthorizationHandler = class _AuthorizationHandler {
472
- static clearStoreToken() {
473
- this.setStoreToken(null, 0);
474
- }
475
- static getStoreToken() {
476
- let token = storage.namespace("bp.ss").get("ss");
477
- if (token) {
478
- let exp = storage.namespace("bp.ss").get("exp");
479
- return {
480
- token: JSON.parse(token),
481
- exp: exp ? JSON.parse(exp) : 0
482
- };
483
- }
484
- return null;
485
- }
486
- static getValidStoreToken() {
487
- const token = _AuthorizationHandler.getStoreToken();
488
- if (token && token.exp > Date.now() - _AuthorizationHandler.TOKEN_EXP) {
489
- return token.token;
490
- }
491
- return null;
492
- }
493
- static setStoreToken(token, exp) {
494
- if (!token) {
495
- storage.namespace("bp.ss").clear();
496
- } else {
497
- storage.namespace("bp.ss").set("ss", JSON.stringify(token));
498
- storage.namespace("bp.ss").set("exp", JSON.stringify(exp));
499
- }
500
- }
501
- static requestHandleSid(ctx) {
502
- let token = _AuthorizationHandler.getStoreToken();
503
- if (token) {
504
- if (token.exp > Date.now() - _AuthorizationHandler.TOKEN_EXP) {
505
- ctx.headers.set(
506
- _AuthorizationHandler.HEADER_NAME,
507
- _AuthorizationHandler.HEADER_PREFIX + token.token
508
- );
509
- }
510
- }
511
- }
512
- static responseHandleSid(ctx) {
513
- let token = ctx.headers.get(_AuthorizationHandler.HEADER_NAME);
514
- if (token && token.startsWith(_AuthorizationHandler.HEADER_PREFIX.trim())) {
515
- token = token.replace(_AuthorizationHandler.HEADER_PREFIX, "");
516
- let oldToken = token;
517
- token = token.split(".")[1];
518
- if (token) {
519
- token = febs2.string.bytesToUtf8(febs2.crypt.base64_decode(token));
520
- if (token) {
521
- let tokenObj = JSON.parse(token);
522
- if (tokenObj.exp < Date.now() - _AuthorizationHandler.TOKEN_EXP) {
523
- _AuthorizationHandler.clearStoreToken();
524
- return false;
525
- } else {
526
- _AuthorizationHandler.setStoreToken(oldToken, tokenObj.exp);
527
- return true;
528
- }
529
- }
530
- }
531
- _AuthorizationHandler.clearStoreToken();
532
- if (typeof navigator !== "undefined" && navigator.onLine) {
533
- window.location.href = "/";
534
- }
535
- }
536
- return false;
537
- }
538
- };
539
- __publicField(_AuthorizationHandler, "HEADER_NAME", "Authorization");
540
- __publicField(_AuthorizationHandler, "HEADER_PREFIX", "SPBearer ");
541
- __publicField(_AuthorizationHandler, "TOKEN_EXP", 20 * 1e3);
542
- var AuthorizationHandler = _AuthorizationHandler;
543
- api.interceptors.request.use(
544
- (config) => {
545
- UILoading_default.show({
546
- delay: 5e3
547
- });
548
- AuthorizationHandler.requestHandleSid(config);
549
- return config;
550
- },
551
- (error) => {
552
- UILoading_default.hide();
553
- console.log("Request Error ==========");
554
- return Promise.reject(error);
555
- }
556
- );
557
- api.interceptors.response.use(
558
- (res) => {
559
- UILoading_default.hide();
560
- if (res.data.code !== 200 /* SUCCESS */) {
561
- UIToast_default.warning(res.data.message || getResponseCodeMsg(res.data.code));
562
- }
563
- AuthorizationHandler.responseHandleSid(res);
564
- return res.data;
565
- },
566
- (error) => {
567
- UILoading_default.hide();
568
- if (error instanceof AxiosError) {
569
- if (error.code === "ERR_NETWORK" || error.code === "ECONNABORTED") {
570
- UIToast_default.error("\u7F51\u7EDC\u9519\u8BEF");
571
- } else if (error.code === "ERR_BAD_RESPONSE") {
572
- UIToast_default.error("\u670D\u52A1\u5668\u65E0\u54CD\u5E94");
573
- }
574
- }
575
- console.log("Response Error ==========");
576
- return Promise.reject(error);
577
- }
578
- );
579
- var HttpRequest = {
580
- get(url, params, data) {
581
- const config = {
582
- method: "get",
583
- url,
584
- params,
585
- data
586
- };
587
- return api(config);
588
- },
589
- post(url, params, data) {
590
- const config = {
591
- method: "post",
592
- url,
593
- params,
594
- data
595
- };
596
- return api(config);
597
- },
598
- put(url, params, data) {
599
- const config = {
600
- method: "put",
601
- url,
602
- params,
603
- data
604
- };
605
- return api(config);
606
- },
607
- delete(url, params, data) {
608
- const config = {
609
- method: "delete",
610
- url,
611
- params,
612
- data
613
- };
614
- return api(config);
615
- }
616
- };
617
-
618
- // src/api/user.ts
619
- var user_exports = {};
620
- __export(user_exports, {
621
- admin: () => admin,
622
- gateway: () => gateway,
623
- message: () => message,
624
- role: () => role,
625
- user: () => user
626
- });
627
- var admin = {
628
- /*
629
- * 注册管理员
630
- * 注册管理员
631
- */
632
- registerAdmin: (data) => {
633
- return HttpRequest.post("/api/admin/registerAdmin", null, { phone: data.phone, email: data.email, displayModules: data.displayModules, username: data.username, nickname: data.nickname, pwd: data.pwd, smsCode: data.smsCode }).then((res) => {
634
- return res;
635
- });
636
- },
637
- /*
638
- * 注册普通用户
639
- * 注册普通用户
640
- */
641
- registerUser: (data) => {
642
- return HttpRequest.post("/api/admin/registerUser", null, { phone: data.phone, email: data.email, displayModules: data.displayModules, username: data.username, nickname: data.nickname, pwd: data.pwd, smsCode: data.smsCode, manager_id: data.manager_id }).then((res) => {
643
- return res;
644
- });
645
- },
646
- /*
647
- * 更新其他用户信息: 用户名与手机号
648
- * 更新其他用户信息: 用户名与手机号
649
- */
650
- updateInfoByAdmin: (data) => {
651
- return HttpRequest.post("/api/admin/updateByAdmin", null, { id: data.id, is_forbidden: data.is_forbidden, title: data.title, phone: data.phone, email: data.email, displayModules: data.displayModules, username: data.username, nickname: data.nickname, pwd: data.pwd, smsCode: data.smsCode, manager_id: data.manager_id, created_at: data.created_at, tick_avatar_self: data.tick_avatar_self, role_ids: data.role_ids, isAdmin: data.isAdmin, thirdPlatformInfo: data.thirdPlatformInfo, unreadMessageCount: data.unreadMessageCount }).then((res) => {
652
- return res;
653
- });
654
- },
655
- /*
656
- * 获取管理员列表
657
- * 获取管理员列表
658
- */
659
- list: (params) => {
660
- return HttpRequest.get("/api/admin/list", { pageNum: params.pageNum, pageSize: params.pageSize }, null).then((res) => {
661
- return res;
662
- });
663
- }
664
- };
665
- var gateway = {
666
- /*
667
- * 注册用户
668
- * 注册用户
669
- */
670
- register: (data) => {
671
- return HttpRequest.post("/api/register", null, { phone: data.phone, email: data.email, displayModules: data.displayModules, username: data.username, nickname: data.nickname, pwd: data.pwd, smsCode: data.smsCode, manager_id: data.manager_id }).then((res) => {
672
- return res;
673
- });
674
- },
675
- /*
676
- * 发送短信
677
- * 发送短信
678
- */
679
- sendSms: (params) => {
680
- return HttpRequest.post("/api/sendSms", { phone: params.phone, imageCode: params.imageCode }, null).then((res) => {
681
- return res;
682
- });
683
- },
684
- /*
685
- * 判断是否登录
686
- * 判断是否登录
687
- */
688
- isLogin: () => {
689
- return HttpRequest.get("/api/isLogin", null, null).then((res) => {
690
- return res;
691
- });
692
- },
693
- /*
694
- * 登录
695
- * 登录
696
- */
697
- login: (data) => {
698
- return HttpRequest.post("/api/login", null, { phone: data.phone, pwd: data.pwd, pwdSN: data.pwdSN, smsCode: data.smsCode }).then((res) => {
699
- return res;
700
- });
701
- },
702
- /*
703
- * 校验当前登录用户的登录密码摘要,用于需要二次确认的业务入口。
704
- * 校验当前登录用户的登录密码摘要,用于需要二次确认的业务入口。
705
- */
706
- verifyPasswordHash: (data) => {
707
- return HttpRequest.post("/api/verifyPasswordHash", null, { passwordHash: data.passwordHash, passwordSalt: data.passwordSalt }).then((res) => {
708
- return res;
709
- });
710
- },
711
- /*
712
- * 退出登录
713
- * 退出登录
714
- */
715
- logout: () => {
716
- return HttpRequest.get("/api/logout", null, null).then((res) => {
717
- return res;
718
- });
719
- },
720
- /*
721
- * 列出所有权限
722
- * 列出所有权限
723
- */
724
- listPermissions: () => {
725
- return HttpRequest.get("/api/listPermissions", null, null).then((res) => {
726
- return res;
727
- });
728
- },
729
- /*
730
- * 列出角色权限
731
- * 列出角色权限
732
- */
733
- listRolePermissions: (params) => {
734
- return HttpRequest.get("/api/listRolePermissions", { id: params.id }, null).then((res) => {
735
- return res;
736
- });
737
- }
738
- };
739
- var message = {
740
- /*
741
- * /api/user/message/list
742
- */
743
- list: (params) => {
744
- return HttpRequest.get("/api/user/message/list", { pageNum: params.pageNum, pageSize: params.pageSize, unread_only: params.unread_only }, null).then((res) => {
745
- return res;
746
- });
747
- },
748
- /*
749
- * /api/user/message/unread/count
750
- */
751
- countUnread: () => {
752
- return HttpRequest.get("/api/user/message/unread/count", null, null).then((res) => {
753
- return res;
754
- });
755
- },
756
- /*
757
- * /api/user/message/read
758
- */
759
- markRead: (data) => {
760
- return HttpRequest.post("/api/user/message/read", null, { messageIds: data.messageIds }).then((res) => {
761
- return res;
762
- });
763
- },
764
- /*
765
- * 清除已读消息
766
- * 清除已读消息
767
- */
768
- clearReaded: (data) => {
769
- return HttpRequest.delete("/api/user/message/clearReaded", null, { messageIds: data.messageIds }).then((res) => {
770
- return res;
771
- });
772
- }
773
- };
774
- var role = {
775
- /*
776
- * 列出所有角色
777
- * 列出所有角色
778
- */
779
- listRoles: () => {
780
- return HttpRequest.get("/api/role/listRoles", null, null).then((res) => {
781
- return res;
782
- });
783
- },
784
- /*
785
- * 创建新角色
786
- * 创建新角色
787
- */
788
- createRole: (params) => {
789
- return HttpRequest.post("/api/role/createRole", { name: params.name, descs: params.descs, admin_id: params.admin_id, parent_id: params.parent_id }, null).then((res) => {
790
- return res;
791
- });
792
- },
793
- /*
794
- * 更新角色
795
- * 更新角色
796
- */
797
- updateRole: (params) => {
798
- return HttpRequest.post("/api/role/updateRole", { id: params.id, name: params.name, descs: params.descs, admin_id: params.admin_id, parent_id: params.parent_id }, null).then((res) => {
799
- return res;
800
- });
801
- },
802
- /*
803
- * 为角色分配权限
804
- * 为角色分配权限
805
- */
806
- assignPermissionsToRole: (data) => {
807
- return HttpRequest.post("/api/role/assignPermissionsToRole", null, { role_id: data.role_id, permissions: data.permissions }).then((res) => {
808
- return res;
809
- });
810
- },
811
- /*
812
- * 为用户分配角色
813
- * 为用户分配角色
814
- */
815
- assignRoleToUserPermission: () => {
816
- return HttpRequest.post("/api/role/assignRoleToUserPermission", null, null).then((res) => {
817
- return res;
818
- });
819
- },
820
- /*
821
- * 为用户分配角色
822
- * 为用户分配角色
823
- */
824
- assignRoleToUser: (data) => {
825
- return HttpRequest.post("/api/role/assignRoleToUser", null, { user_id: data.user_id, role_ids: data.role_ids }).then((res) => {
826
- return res;
827
- });
828
- },
829
- /*
830
- * 获取用户拥有的所有角色
831
- * 获取用户拥有的所有角色
832
- */
833
- listUserRoles: (params) => {
834
- return HttpRequest.get("/api/role/listUserRoles", { user_id: params.user_id }, null).then((res) => {
835
- return res;
836
- });
837
- },
838
- /*
839
- * 获取用户拥有的所有权限
840
- * 获取用户拥有的所有权限
841
- */
842
- listUserPermissions: (params) => {
843
- return HttpRequest.get("/api/role/listUserPermissions", { user_id: params.user_id }, null).then((res) => {
844
- return res;
845
- });
846
- },
847
- /*
848
- * 列出所有部门
849
- * 列出所有部门
850
- */
851
- listCompanies: () => {
852
- return HttpRequest.get("/api/role/listCompanies", null, null).then((res) => {
853
- return res;
854
- });
855
- },
856
- /*
857
- * 创建新公司
858
- * 创建新公司
859
- */
860
- createCompany: (params) => {
861
- return HttpRequest.post("/api/role/createCompany", { name: params.name, descs: params.descs, admin_id: params.admin_id, parent_id: params.parent_id, is_spv_company: params.is_spv_company }, null).then((res) => {
862
- return res;
863
- });
864
- },
865
- /*
866
- * 更新公司
867
- * 更新公司
868
- */
869
- updateCompany: (params) => {
870
- return HttpRequest.post("/api/role/updateCompany", { id: params.id, name: params.name, descs: params.descs, admin_id: params.admin_id, parent_id: params.parent_id, is_spv_company: params.is_spv_company }, null).then((res) => {
871
- return res;
872
- });
873
- },
874
- /*
875
- * 列出所有部门
876
- * 列出所有部门
877
- */
878
- listDepartments: () => {
879
- return HttpRequest.get("/api/role/listDepartments", null, null).then((res) => {
880
- return res;
881
- });
882
- },
883
- /*
884
- * 创建新部门
885
- * 创建新部门
886
- */
887
- createDepartment: (params) => {
888
- return HttpRequest.post("/api/role/createDepartment", { name: params.name, descs: params.descs, admin_id: params.admin_id, company_id: params.company_id, parent_id: params.parent_id }, null).then((res) => {
889
- return res;
890
- });
891
- },
892
- /*
893
- * 更新部门
894
- * 更新部门
895
- */
896
- updateDepartment: (params) => {
897
- return HttpRequest.post("/api/role/updateDepartment", { id: params.id, name: params.name, descs: params.descs, admin_id: params.admin_id, company_id: params.company_id, parent_id: params.parent_id }, null).then((res) => {
898
- return res;
899
- });
900
- },
901
- /*
902
- * 为用户分配部门
903
- * 为用户分配部门
904
- */
905
- assignUserToDepartment: (params) => {
906
- return HttpRequest.post("/api/role/assignUserToDepartment", { user_id: params.user_id, department_id: params.department_id, position: params.position }, null).then((res) => {
907
- return res;
908
- });
909
- },
910
- /*
911
- * 为用户移除部门
912
- * 为用户移除部门
913
- */
914
- removeUserFromDepartment: (params) => {
915
- return HttpRequest.post("/api/role/removeUserFromDepartment", { user_id: params.user_id, department_id: params.department_id }, null).then((res) => {
916
- return res;
917
- });
918
- },
919
- /*
920
- * 获取公司拥有的所有部门
921
- * 获取公司拥有的所有部门
922
- */
923
- listCompanyDepartments: (params) => {
924
- return HttpRequest.get("/api/role/listCompanyDepartments", { company_id: params.company_id }, null).then((res) => {
925
- return res;
926
- });
927
- },
928
- /*
929
- * 获取用户拥有的所有部门
930
- * 获取用户拥有的所有部门
931
- */
932
- listUserDepartments: (params) => {
933
- return HttpRequest.get("/api/role/listUserDepartments", { user_id: params.user_id }, null).then((res) => {
934
- return res;
935
- });
936
- },
937
- /*
938
- * 获取用户拥有的所有部门
939
- * 获取用户拥有的所有部门
940
- */
941
- listDepartmentUsers: (params) => {
942
- return HttpRequest.get("/api/role/listDepartmentUsers", { department_id: params.department_id }, null).then((res) => {
943
- return res;
944
- });
945
- }
946
- };
947
- var user = {
948
- /*
949
- * 获取用户信息; (也可以获取管理员信息)
950
- * 获取用户信息; (也可以获取管理员信息)
951
- */
952
- getInfoByUsername: (params) => {
953
- return HttpRequest.get("/api/user/infoByUsername", { username: params.username }, null).then((res) => {
954
- return res;
955
- });
956
- },
957
- /*
958
- * 获取用户信息; (也可以获取管理员信息)
959
- * 获取用户信息; (也可以获取管理员信息)
960
- */
961
- getInfo: (params) => {
962
- return HttpRequest.get("/api/user/info", { id: params.id }, null).then((res) => {
963
- return res;
964
- });
965
- },
966
- /*
967
- * 获取用户头像信息; (也可以获取管理员信息)
968
- * 获取用户头像信息; (也可以获取管理员信息)
969
- */
970
- getAvatar: (params) => {
971
- return HttpRequest.get("/api/user/avatar", { id: params.id, tick: params.tick }, null).then((res) => {
972
- return res;
973
- });
974
- },
975
- /*
976
- * 获取用户头像列表信息; (也可以获取管理员信息)
977
- * 获取用户头像列表信息; (也可以获取管理员信息)
978
- */
979
- getAvatarList: (params) => {
980
- return HttpRequest.get("/api/user/avatar_list", { ids: params.ids }, null).then((res) => {
981
- return res;
982
- });
983
- },
984
- /*
985
- * 更新用户头像
986
- * 更新用户头像
987
- */
988
- updateAvatar: (data) => {
989
- return HttpRequest.post("/api/user/updateAvatar", null, { id: data.id, avatar: data.avatar, avatar_small: data.avatar_small, tick_self: data.tick_self }).then((res) => {
990
- return res;
991
- });
992
- },
993
- /*
994
- * 更新直接领导
995
- * 更新直接领导
996
- */
997
- updateManager: (params) => {
998
- return HttpRequest.post("/api/user/updateManager", { id: params.id, managerid: params.managerid }, null).then((res) => {
999
- return res;
1000
- });
1001
- },
1002
- /*
1003
- * 更新用户信息
1004
- * 更新用户信息
1005
- */
1006
- updateInfo: (data) => {
1007
- return HttpRequest.post("/api/user/update", null, { id: data.id, is_forbidden: data.is_forbidden, title: data.title, phone: data.phone, email: data.email, displayModules: data.displayModules, username: data.username, nickname: data.nickname, pwd: data.pwd, smsCode: data.smsCode, manager_id: data.manager_id, created_at: data.created_at, tick_avatar_self: data.tick_avatar_self, role_ids: data.role_ids, isAdmin: data.isAdmin, thirdPlatformInfo: data.thirdPlatformInfo, unreadMessageCount: data.unreadMessageCount }).then((res) => {
1008
- return res;
1009
- });
1010
- },
1011
- /*
1012
- * 更新用户密码
1013
- * 更新用户密码
1014
- */
1015
- updatePassword: (data) => {
1016
- return HttpRequest.post("/api/user/updatePassword", null, { old_password: data.old_password, old_password_sn: data.old_password_sn, new_password: data.new_password }).then((res) => {
1017
- return res;
1018
- });
1019
- },
1020
- /*
1021
- * 删除用户
1022
- * 删除用户
1023
- */
1024
- deleteUser: (params) => {
1025
- return HttpRequest.post("/api/user/delete", { id: params.id }, null).then((res) => {
1026
- return res;
1027
- });
1028
- },
1029
- /*
1030
- * 获取用户列表
1031
- * 获取用户列表
1032
- */
1033
- list: (params) => {
1034
- return HttpRequest.get("/api/user/list", { pageNum: params.pageNum, pageSize: params.pageSize }, null).then((res) => {
1035
- return res;
1036
- });
1037
- },
1038
- /*
1039
- * 通过用户ids,获取用户列表(可以包含管理员)
1040
- * 通过用户ids,获取用户列表(可以包含管理员)
1041
- */
1042
- listByIds: (params) => {
1043
- return HttpRequest.get("/api/user/list_by_ids", { ids: params.ids }, null).then((res) => {
1044
- return res;
1045
- });
1046
- },
1047
- /*
1048
- * 搜索用户列表
1049
- * 搜索用户列表
1050
- */
1051
- search: (params) => {
1052
- return HttpRequest.get("/api/user/search", { keyword: params.keyword, pageNum: params.pageNum, pageSize: params.pageSize }, null).then((res) => {
1053
- return res;
1054
- });
1055
- },
1056
- /*
1057
- * 禁用用户
1058
- * 禁用用户
1059
- */
1060
- forbid: (params) => {
1061
- return HttpRequest.post("/api/user/forbid", { id: params.id, forbid: params.forbid }, null).then((res) => {
1062
- return res;
1063
- });
1064
- }
1065
- };
1066
-
1067
- // src/api/project.ts
1068
- var project_exports = {};
1069
- __export(project_exports, {
1070
- contract: () => contract,
1071
- file: () => file,
1072
- fileversion: () => fileversion,
1073
- project: () => project,
1074
- projectprogress: () => projectprogress
1075
- });
1076
- var contract = {
1077
- /*
1078
- * /api/project/contract/create
1079
- */
1080
- createContract: (data) => {
1081
- return HttpRequest.post("/api/project/contract/create", null, { projectId: data.projectId, name: data.name, tag: data.tag, code: data.code, partyA: data.partyA, partyB: data.partyB, amount: data.amount, startDate: data.startDate, endDate: data.endDate, descs: data.descs }).then((res) => {
1082
- return res;
1083
- });
1084
- },
1085
- /*
1086
- * /api/project/contract/delete
1087
- */
1088
- deleteContract: (params) => {
1089
- return HttpRequest.delete("/api/project/contract/delete", { id: params.id }, null).then((res) => {
1090
- return res;
1091
- });
1092
- },
1093
- /*
1094
- * /api/project/contract/update
1095
- */
1096
- updateContract: (data) => {
1097
- return HttpRequest.post("/api/project/contract/update", null, { id: data.id, name: data.name, code: data.code, tag: data.tag, partyA: data.partyA, partyB: data.partyB, amount: data.amount, startDate: data.startDate, endDate: data.endDate, descs: data.descs, markdown: data.markdown }).then((res) => {
1098
- return res;
1099
- });
1100
- },
1101
- /*
1102
- * /api/project/contract/detail
1103
- */
1104
- getContractDetail: (params) => {
1105
- return HttpRequest.get("/api/project/contract/detail", { id: params.id }, null).then((res) => {
1106
- return res;
1107
- });
1108
- },
1109
- /*
1110
- * /api/project/contract/list
1111
- */
1112
- getContractList: (params) => {
1113
- return HttpRequest.get("/api/project/contract/list", { projectId: params.projectId, pageNum: params.pageNum, pageSize: params.pageSize }, null).then((res) => {
1114
- return res;
1115
- });
1116
- },
1117
- /*
1118
- * 提交合同版本进行用印审批(提交后将变为PENDING状态).
1119
- * 提交合同版本进行用印审批(提交后将变为PENDING状态).
1120
- */
1121
- submitApproval: (params) => {
1122
- return HttpRequest.post("/api/project/contract/submit", { id: params.id, sealType: params.sealType }, null).then((res) => {
1123
- return res;
1124
- });
1125
- },
1126
- /*
1127
- * 撤销合同版本审批.
1128
- * 撤销合同版本审批.
1129
- */
1130
- cancelApproval: (params) => {
1131
- return HttpRequest.post("/api/project/contract/cancelApproval", { id: params.id }, null).then((res) => {
1132
- return res;
1133
- });
1134
- },
1135
- /*
1136
- * /api/project/contract/version/upload
1137
- */
1138
- uploadVersion: (data) => {
1139
- return HttpRequest.post("/api/project/contract/version/upload", null, { contractId: data.contractId, fileName: data.fileName, fileType: data.fileType, fileSize: data.fileSize, changeLog: data.changeLog }).then((res) => {
1140
- return res;
1141
- });
1142
- },
1143
- /*
1144
- * /api/project/contract/version/list
1145
- */
1146
- getVersionList: (params) => {
1147
- return HttpRequest.get("/api/project/contract/version/list", { contractId: params.contractId }, null).then((res) => {
1148
- return res;
1149
- });
1150
- },
1151
- /*
1152
- * 删除合同版本(仅草稿状态合同允许删除).
1153
- * /api/project/contract/version/delete
1154
- */
1155
- deleteVersion: (params) => {
1156
- return HttpRequest.delete("/api/project/contract/version/delete", { id: params.id }, null).then((res) => {
1157
- return res;
1158
- });
1159
- },
1160
- /*
1161
- * /api/project/contract/version/detail
1162
- */
1163
- getVersionDetail: (params) => {
1164
- return HttpRequest.get("/api/project/contract/version/detail", { id: params.id }, null).then((res) => {
1165
- return res;
1166
- });
1167
- },
1168
- /*
1169
- * /api/project/contract/version/layerOpinion
1170
- */
1171
- setVersionLayerOpinion: (data) => {
1172
- return HttpRequest.post("/api/project/contract/version/layerOpinion", null, { contractId: data.contractId, version: data.version, opinion: data.opinion }).then((res) => {
1173
- return res;
1174
- });
1175
- },
1176
- /*
1177
- * 获取新的合同编号.
1178
- * 获取新的合同编号.
1179
- */
1180
- getNewContractCode: (params) => {
1181
- return HttpRequest.get("/api/project/contract/newCode", { contractCode: params.contractCode, sequenceLength: params.sequenceLength }, null).then((res) => {
1182
- return res;
1183
- });
1184
- },
1185
- /*
1186
- * 获取合同历史参与方.
1187
- * 获取合同历史参与方.
1188
- */
1189
- getContractHistoryParties: () => {
1190
- return HttpRequest.get("/api/project/contract/historyParties", null, null).then((res) => {
1191
- return res;
1192
- });
1193
- }
1194
- };
1195
- var file = {
1196
- /*
1197
- * /api/project/files/detail
1198
- */
1199
- getDetail: (params) => {
1200
- return HttpRequest.get("/api/project/files/detail", { fileId: params.fileId }, null).then((res) => {
1201
- return res;
1202
- });
1203
- },
1204
- /*
1205
- * /api/project/files/list
1206
- */
1207
- listFiles: (params) => {
1208
- return HttpRequest.get("/api/project/files/list", { projectId: params.projectId }, null).then((res) => {
1209
- return res;
1210
- });
1211
- },
1212
- /*
1213
- * 跨项目搜索当前用户有权限查看的项目文件.
1214
- * 跨项目搜索当前用户有权限查看的项目文件.
1215
- */
1216
- searchFiles: (params) => {
1217
- return HttpRequest.get("/api/project/files/search", { keyword: params.keyword, pageNum: params.pageNum, pageSize: params.pageSize }, null).then((res) => {
1218
- return res;
1219
- });
1220
- },
1221
- /*
1222
- * /api/project/files/add
1223
- */
1224
- addFile: (params, data) => {
1225
- return HttpRequest.post("/api/project/files/add", { projectId: params.projectId }, { fileName: data.fileName, filePath: data.filePath, isSecure: data.isSecure, descs: data.descs, fileType: data.fileType, fileSize: data.fileSize, crc32: data.crc32, fileResourcePath: data.fileResourcePath }).then((res) => {
1226
- return res;
1227
- });
1228
- },
1229
- /*
1230
- * /api/project/files/remove
1231
- */
1232
- removeFile: (params) => {
1233
- return HttpRequest.post("/api/project/files/remove", { fileId: params.fileId }, null).then((res) => {
1234
- return res;
1235
- });
1236
- },
1237
- /*
1238
- * /api/project/files/move
1239
- */
1240
- moveFile: (params, data) => {
1241
- return HttpRequest.post("/api/project/files/move", { projectId: params.projectId }, { oldFileName: data.oldFileName, oldFilePath: data.oldFilePath, newFileName: data.newFileName, newFilePath: data.newFilePath }).then((res) => {
1242
- return res;
1243
- });
1244
- },
1245
- /*
1246
- * /api/project/files/updateDescs
1247
- */
1248
- updateFileDescs: (data) => {
1249
- return HttpRequest.post("/api/project/files/updateDescs", null, { fileId: data.fileId, descs: data.descs }).then((res) => {
1250
- return res;
1251
- });
1252
- },
1253
- /*
1254
- * /api/project/files/copyToProject
1255
- */
1256
- copyFileToProject: (params) => {
1257
- return HttpRequest.post("/api/project/files/copyToProject", { projectId: params.projectId, fileId: params.fileId }, null).then((res) => {
1258
- return res;
1259
- });
1260
- },
1261
- /*
1262
- * /api/project/files/moveToProject
1263
- */
1264
- moveFileToProject: (params) => {
1265
- return HttpRequest.post("/api/project/files/moveToProject", { projectId: params.projectId, fileId: params.fileId }, null).then((res) => {
1266
- return res;
1267
- });
1268
- },
1269
- /*
1270
- * 增量更新文件 通过上传差异数据(BSDiff补丁)来更新文件,减少上传数据量
1271
- * 增量更新文件 通过上传差异数据(BSDiff补丁)来更新文件,减少上传数据量
1272
- */
1273
- updateFileDelta: (data) => {
1274
- return HttpRequest.post("/api/project/files/updateDelta", null, { fileId: data.fileId, deltaData: data.deltaData, deltaSize: data.deltaSize, newFileSize: data.newFileSize, crc32: data.crc32, recordVersion: data.recordVersion, rotateResourcePath: data.rotateResourcePath }).then((res) => {
1275
- return res;
1276
- });
1277
- },
1278
- /*
1279
- * 全量文件更新 通过上传完整文件数据来更新文件
1280
- * 全量文件更新 通过上传完整文件数据来更新文件
1281
- */
1282
- updateFile: (data) => {
1283
- return HttpRequest.post("/api/project/files/updateData", null, { fileId: data.fileId, fileSize: data.fileSize, crc32: data.crc32, fileName: data.fileName, fileResourcePath: data.fileResourcePath, recordVersion: data.recordVersion, rotateResourcePath: data.rotateResourcePath }).then((res) => {
1284
- return res;
1285
- });
1286
- },
1287
- /*
1288
- * 生成临时访问令牌 用于文件下载或上传
1289
- * 生成临时访问令牌 用于文件下载或上传
1290
- */
1291
- generateTempAccessToken: (params) => {
1292
- return HttpRequest.post("/api/project/files/generateTempAccessToken", { fileId: params.fileId, expireSeconds: params.expireSeconds }, null).then((res) => {
1293
- return res;
1294
- });
1295
- },
1296
- /*
1297
- * 发起文件夹异步打包下载(仅项目负责人/管理员)
1298
- */
1299
- folderDownload: (params, data) => {
1300
- return HttpRequest.post("/api/project/files/folderDownload", { projectId: params.projectId }, { folderPath: data.folderPath, folderName: data.folderName }).then((res) => {
1301
- return res;
1302
- });
1303
- },
1304
- /*
1305
- * 查询文件夹打包下载任务状态
1306
- */
1307
- folderDownloadStatus: (params) => {
1308
- return HttpRequest.get("/api/project/files/folderDownloadStatus", { jobId: params.jobId }, null).then((res) => {
1309
- return res;
1310
- });
1311
- },
1312
- /*
1313
- * /api/project/files/listByTempAccessToken
1314
- */
1315
- listFilesByTempAccessToken: (params) => {
1316
- return HttpRequest.get("/api/project/files/listByTempAccessToken", { tempToken: params.tempToken }, null).then((res) => {
1317
- return res;
1318
- });
1319
- }
1320
- };
1321
- var fileversion = {
1322
- /*
1323
- * 获取文件版本列表
1324
- * 获取文件版本列表
1325
- */
1326
- listVersions: (params) => {
1327
- return HttpRequest.get("/api/project/files/version/list", { fileId: params.fileId }, null).then((res) => {
1328
- return res;
1329
- });
1330
- },
1331
- /*
1332
- * 获取版本详情
1333
- * 获取版本详情
1334
- */
1335
- getVersionDetail: (params) => {
1336
- return HttpRequest.get("/api/project/files/version/detail", { versionId: params.versionId }, null).then((res) => {
1337
- return res;
1338
- });
1339
- }
1340
- };
1341
- var project = {
1342
- /*
1343
- * /api/project/enablePrivateProject
1344
- */
1345
- enableUserPrivateProject: () => {
1346
- return HttpRequest.post("/api/project/enablePrivateProject", null, null).then((res) => {
1347
- return res;
1348
- });
1349
- },
1350
- /*
1351
- * /api/project/create
1352
- */
1353
- createProject: (data) => {
1354
- return HttpRequest.post("/api/project/create", null, { name: data.name, descs: data.descs, companyId: data.companyId, markdown: data.markdown, startTime: data.startTime, plannedEndTime: data.plannedEndTime, endTime: data.endTime, leaderId: data.leaderId, customerId: data.customerId, order: data.order, isUserPrivate: data.isUserPrivate }).then((res) => {
1355
- return res;
1356
- });
1357
- },
1358
- /*
1359
- * /api/project/update
1360
- */
1361
- updateProject: (data) => {
1362
- return HttpRequest.post("/api/project/update", null, { id: data.id, name: data.name, descs: data.descs, companyId: data.companyId, markdown: data.markdown, status: data.status, startTime: data.startTime, plannedEndTime: data.plannedEndTime, endTime: data.endTime, leaderId: data.leaderId, customerId: data.customerId, order: data.order, isUserPrivate: data.isUserPrivate, createTime: data.createTime, updateTime: data.updateTime, createBy: data.createBy, updateBy: data.updateBy }).then((res) => {
1363
- return res;
1364
- });
1365
- },
1366
- /*
1367
- * /api/project/updateUserdataOrder
1368
- */
1369
- updateUserdataOrder: (data) => {
1370
- return HttpRequest.post("/api/project/updateUserdataOrder", null, { projectIds: data.projectIds }).then((res) => {
1371
- return res;
1372
- });
1373
- },
1374
- /*
1375
- * 获取用户的项目排序数据. [{pid,order}]
1376
- * 获取用户的项目排序数据. [{pid,order}]
1377
- */
1378
- getUserdataOrder: () => {
1379
- return HttpRequest.get("/api/project/userdataOrder", null, null).then((res) => {
1380
- return res;
1381
- });
1382
- },
1383
- /*
1384
- * /api/project/detail
1385
- */
1386
- getProjectDetail: (params) => {
1387
- return HttpRequest.get("/api/project/detail", { id: params.id }, null).then((res) => {
1388
- return res;
1389
- });
1390
- },
1391
- /*
1392
- * 获取项目名称.
1393
- * 获取项目名称.
1394
- */
1395
- getProjectName: (params) => {
1396
- return HttpRequest.get("/api/project/name", { projectId: params.projectId }, null).then((res) => {
1397
- return res;
1398
- });
1399
- },
1400
- /*
1401
- * 仅查看当前用户参与的项目
1402
- * 仅查看当前用户参与的项目
1403
- */
1404
- listProjects: (params) => {
1405
- return HttpRequest.get("/api/project/list", { pageNum: params.pageNum, pageSize: params.pageSize, status: params.status, companyId: params.companyId, customerId: params.customerId }, null).then((res) => {
1406
- return res;
1407
- });
1408
- },
1409
- /*
1410
- * 仅查看当前用户为管理员及以上的项目
1411
- * 仅查看当前用户为管理员及以上的项目
1412
- */
1413
- listProjectsByManager: (params) => {
1414
- return HttpRequest.get("/api/project/listByManager", { pageNum: params.pageNum, pageSize: params.pageSize }, null).then((res) => {
1415
- return res;
1416
- });
1417
- },
1418
- /*
1419
- * /api/project/status
1420
- */
1421
- changeStatus: (params) => {
1422
- return HttpRequest.put("/api/project/status", { id: params.id, status: params.status }, null).then((res) => {
1423
- return res;
1424
- });
1425
- },
1426
- /*
1427
- * /api/project/members
1428
- */
1429
- getProjectMembers: (params) => {
1430
- return HttpRequest.get("/api/project/members", { projectId: params.projectId }, null).then((res) => {
1431
- return res;
1432
- });
1433
- },
1434
- /*
1435
- * 获取用户在项目中的角色.
1436
- * 获取用户在项目中的角色.
1437
- */
1438
- getMemberRole: (params) => {
1439
- return HttpRequest.get("/api/project/member/role", { projectId: params.projectId, userId: params.userId }, null).then((res) => {
1440
- return res;
1441
- });
1442
- },
1443
- /*
1444
- * /api/project/members/assign
1445
- */
1446
- assignMember: (data) => {
1447
- return HttpRequest.post("/api/project/members/assign", null, { userId: data.userId, role: data.role, projectId: data.projectId }).then((res) => {
1448
- return res;
1449
- });
1450
- },
1451
- /*
1452
- * /api/project/members/remove
1453
- */
1454
- removeMember: (data) => {
1455
- return HttpRequest.post("/api/project/members/remove", null, { userId: data.userId, role: data.role, projectId: data.projectId }).then((res) => {
1456
- return res;
1457
- });
1458
- }
1459
- };
1460
- var projectprogress = {
1461
- /*
1462
- * 创建项目进展记录 POST /api/project/progress/create
1463
- * 创建项目进展记录 POST /api/project/progress/create
1464
- */
1465
- createProgress: (data) => {
1466
- return HttpRequest.post("/api/project/progress/create", null, { projectId: data.projectId, descs: data.descs, commentCount: data.commentCount, progressTime: data.progressTime }).then((res) => {
1467
- return res;
1468
- });
1469
- },
1470
- /*
1471
- * 更新项目进展记录 PUT /api/project/progress/update/:id
1472
- * 更新项目进展记录 PUT /api/project/progress/update/:id
1473
- */
1474
- updateProgress: (data) => {
1475
- return HttpRequest.put("/api/project/progress/update", null, { id: data.id, descs: data.descs, progressTime: data.progressTime }).then((res) => {
1476
- return res;
1477
- });
1478
- },
1479
- /*
1480
- * 删除项目进展记录 DELETE /api/project/progress/delete/:id
1481
- * 删除项目进展记录 DELETE /api/project/progress/delete/:id
1482
- */
1483
- deleteProgress: (params) => {
1484
- return HttpRequest.delete("/api/project/progress/delete", { id: params.id }, null).then((res) => {
1485
- return res;
1486
- });
1487
- },
1488
- /*
1489
- * 获取项目进展列表 GET /api/project/progress/list/:projectId
1490
- * 获取项目进展列表 GET /api/project/progress/list/:projectId
1491
- */
1492
- getProgressList: (params) => {
1493
- return HttpRequest.get("/api/project/progress/list", { projectId: params.projectId }, null).then((res) => {
1494
- return res;
1495
- });
1496
- },
1497
- /*
1498
- * 添加进展评论 POST /api/project/progress/comment/add
1499
- * 添加进展评论 POST /api/project/progress/comment/add
1500
- */
1501
- addComment: (data) => {
1502
- return HttpRequest.post("/api/project/progress/comment/add", null, { progressId: data.progressId, comment: data.comment }).then((res) => {
1503
- return res;
1504
- });
1505
- },
1506
- /*
1507
- * 删除进展评论 DELETE /api/project/progress/comment/delete/:id
1508
- * 删除进展评论 DELETE /api/project/progress/comment/delete/:id
1509
- */
1510
- deleteComment: (params) => {
1511
- return HttpRequest.delete("/api/project/progress/comment/delete", { id: params.id }, null).then((res) => {
1512
- return res;
1513
- });
1514
- },
1515
- /*
1516
- * 更新进展评论 PUT /api/project/progress/comment/update/:id
1517
- * 更新进展评论 PUT /api/project/progress/comment/update/:id
1518
- */
1519
- updateComment: (params) => {
1520
- return HttpRequest.put("/api/project/progress/comment/update", { id: params.id }, {}).then((res) => {
1521
- return res;
1522
- });
1523
- },
1524
- /*
1525
- * 获取进展评论列表 GET /api/project/progress/comment/list/:progressId
1526
- * 获取进展评论列表 GET /api/project/progress/comment/list/:progressId
1527
- */
1528
- getCommentList: (params) => {
1529
- return HttpRequest.get("/api/project/progress/comment/list", { progressId: params.progressId, pageNum: params.pageNum, pageSize: params.pageSize }, null).then((res) => {
1530
- return res;
1531
- });
1532
- }
1533
- };
1534
-
1535
- // src/api/index.ts
1536
- var API = {
1537
- base: base_exports,
1538
- user: user_exports,
1539
- project: project_exports
1540
- };
1541
-
1542
- // src/utils/CacheDepartmentInfo.ts
1543
- var CACHE_EXPIRATION_MS = 24 * 60 * 60 * 1e3;
1544
- var DepartmentInfoDatabase = class extends Dexie {
1545
- constructor() {
1546
- super("DepartmentInfoDB");
1547
- __publicField(this, "departmentCache");
1548
- this.version(1).stores({
1549
- departmentCache: "id, timestamp"
1550
- });
1551
- }
1552
- };
1553
- var db = new DepartmentInfoDatabase();
1554
- var departmentListPromise = null;
1555
- var getFromCache = async () => {
1556
- try {
1557
- const cached = await db.departmentCache.get("DEPARTMENT_ALL");
1558
- if (cached) {
1559
- const now = Date.now();
1560
- if (now - cached.timestamp < CACHE_EXPIRATION_MS) {
1561
- return cached.data;
1562
- }
1563
- await db.departmentCache.delete("DEPARTMENT_ALL");
1564
- }
1565
- return null;
1566
- } catch (error) {
1567
- console.error("\u8BFB\u53D6\u90E8\u95E8\u7F13\u5B58\u5931\u8D25:", error);
1568
- return null;
1569
- }
1570
- };
1571
- var setToCache = async (data) => {
1572
- try {
1573
- await db.departmentCache.put({
1574
- id: "DEPARTMENT_ALL",
1575
- data,
1576
- timestamp: Date.now()
1577
- });
1578
- } catch (error) {
1579
- console.error("\u5199\u5165\u90E8\u95E8\u7F13\u5B58\u5931\u8D25:", error);
1580
- }
1581
- };
1582
- var clearCache = async () => {
1583
- try {
1584
- await db.departmentCache.clear();
1585
- } catch (error) {
1586
- console.error("\u6E05\u9664\u90E8\u95E8\u7F13\u5B58\u5931\u8D25:", error);
1587
- }
1588
- };
1589
- var attachCompanyInfo = (departments, company) => {
1590
- return departments.map((department) => ({
1591
- ...department,
1592
- company_id: department.company_id || company.id,
1593
- company,
1594
- children: department.children ? attachCompanyInfo(department.children, company) : void 0
1595
- }));
1596
- };
1597
- var fetchDepartmentsFromApi = async () => {
1598
- const companyRes = await API.user.role.listCompanies();
1599
- if (companyRes.code !== 200 /* SUCCESS */) {
1600
- return null;
1601
- }
1602
- const companies = (companyRes.data || []).map((company) => ({
1603
- id: company.id,
1604
- name: company.name,
1605
- descs: company.descs,
1606
- parent_id: company.parent_id,
1607
- admin_id: company.admin_id,
1608
- is_spv_company: company.is_spv_company,
1609
- created_at: company.created_at
1610
- }));
1611
- if (companies.length === 0) {
1612
- return [];
1613
- }
1614
- const departmentResults = await Promise.all(
1615
- companies.map(async (company) => {
1616
- const departmentRes = await API.user.role.listCompanyDepartments({ company_id: company.id });
1617
- if (departmentRes.code !== 200 /* SUCCESS */) {
1618
- return null;
1619
- }
1620
- return attachCompanyInfo(departmentRes.data || [], company);
1621
- })
1622
- );
1623
- if (departmentResults.some((result) => result === null)) {
1624
- return null;
1625
- }
1626
- return departmentResults.flatMap((result) => result || []);
1627
- };
1628
- var getDepartmentList = async ({
1629
- forceRefresh = false
1630
- }) => {
1631
- if (!forceRefresh) {
1632
- const cachedDeptInfo = await getFromCache();
1633
- if (cachedDeptInfo) {
1634
- return cachedDeptInfo;
1635
- }
1636
- }
1637
- if (!departmentListPromise) {
1638
- departmentListPromise = fetchDepartmentsFromApi().then(async (departments2) => {
1639
- if (departments2) {
1640
- await setToCache(departments2);
1641
- }
1642
- return departments2;
1643
- }).finally(() => {
1644
- departmentListPromise = null;
1645
- });
1646
- }
1647
- const departments = await departmentListPromise;
1648
- if (!departments) {
1649
- return null;
1650
- }
1651
- return departments;
1652
- };
1653
- var getFlatDepartmentList = async ({
1654
- forceRefresh = false
1655
- }) => {
1656
- const departments = await getDepartmentList({ forceRefresh });
1657
- if (!departments) {
1658
- return null;
1659
- }
1660
- const flatten = (depts) => {
1661
- let result = [];
1662
- for (const dept of depts) {
1663
- const { children, ...deptWithoutChildren } = dept;
1664
- result.push(deptWithoutChildren);
1665
- if (dept.children && dept.children.length > 0) {
1666
- result = result.concat(flatten(dept.children));
1667
- }
1668
- }
1669
- return result;
1670
- };
1671
- return flatten(departments);
1672
- };
1673
- var getDepartmentById = async ({
1674
- deptId,
1675
- forceRefresh = false
1676
- }) => {
1677
- const departments = await getFlatDepartmentList({ forceRefresh });
1678
- if (!departments) {
1679
- return null;
1680
- }
1681
- return departments.find((dept) => dept.id === deptId) || null;
1682
- };
1683
- var getDepartmentNameById = async ({
1684
- deptId,
1685
- forceRefresh = false
1686
- }) => {
1687
- const dept = await getDepartmentById({ deptId, forceRefresh });
1688
- return dept?.name || "";
1689
- };
1690
- var clearDepartmentCache = async () => {
1691
- await clearCache();
1692
- };
1693
- var getCacheStats = async () => {
1694
- try {
1695
- const all = await db.departmentCache.toArray();
1696
- if (all.length === 0) {
1697
- return { count: 0, oldest: null, newest: null };
1698
- }
1699
- const timestamps = all.map((item) => item.timestamp);
1700
- return {
1701
- count: all.length,
1702
- oldest: Math.min(...timestamps),
1703
- newest: Math.max(...timestamps)
1704
- };
1705
- } catch (error) {
1706
- console.error("\u83B7\u53D6\u7F13\u5B58\u7EDF\u8BA1\u5931\u8D25:", error);
1707
- return { count: 0, oldest: null, newest: null };
1708
- }
1709
- };
1710
- var CacheDepartmentInfo = {
1711
- /**
1712
- * 获取所有部门信息
1713
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
1714
- * @returns 部门信息数组
1715
- */
1716
- getDepartmentList,
1717
- /**
1718
- * 获取扁平化的部门列表(包含所有子部门)
1719
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
1720
- * @returns 扁平化的部门信息数组
1721
- */
1722
- getFlatDepartmentList,
1723
- /**
1724
- * 根据部门ID获取部门信息
1725
- * @param deptId 部门ID
1726
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
1727
- * @returns 部门信息或null
1728
- */
1729
- getDepartmentById,
1730
- /**
1731
- * 根据部门ID获取部门名称
1732
- * @param deptId 部门ID
1733
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
1734
- * @returns 部门名称或空字符串
1735
- */
1736
- getDepartmentNameById,
1737
- /**
1738
- * 清除部门缓存
1739
- */
1740
- clearDepartmentCache,
1741
- /**
1742
- * 获取缓存统计信息
1743
- * @returns 缓存统计信息
1744
- */
1745
- getCacheStats
1746
- };
1747
-
1748
- // src/utils/CacheFileContent.ts
1749
- import Dexie2 from "dexie";
1750
- import * as febs3 from "febs-browser";
1751
- var FileContentDatabase = class extends Dexie2 {
1752
- constructor() {
1753
- super("FileContentDB");
1754
- __publicField(this, "fileCache");
1755
- __publicField(this, "fileMeta");
1756
- this.version(1).stores({
1757
- fileCache: "id, fileId, crc32, fileSize, updateTime"
1758
- });
1759
- this.version(2).stores({
1760
- fileCache: "id, fileId, crc32, fileSize, updateTime",
1761
- fileMeta: "id, fileId, projectId, updateTime"
1762
- });
1763
- }
1764
- };
1765
- var db2 = new FileContentDatabase();
1766
- var calculateCrc32 = async (blob) => {
1767
- return new Promise((resolve, reject) => {
1768
- const file2 = new File([blob], "temp");
1769
- febs3.crypt.crc32_file(file2, (crc) => {
1770
- if (crc === 0) {
1771
- reject(new Error("CRC32 \u8BA1\u7B97\u5931\u8D25"));
1772
- } else {
1773
- resolve(crc);
1774
- }
1775
- });
1776
- });
1777
- };
1778
- var getCacheRecord = async (fileId) => {
1779
- try {
1780
- const records = await db2.fileCache.where("fileId").equals(fileId).toArray();
1781
- return records.length > 0 ? records[0] : void 0;
1782
- } catch (error) {
1783
- console.error("\u8BFB\u53D6\u6587\u4EF6\u7F13\u5B58\u5931\u8D25:", error);
1784
- return void 0;
1785
- }
1786
- };
1787
- var saveToCache = async (fileId, content, crc32, fileSize, contentType) => {
1788
- try {
1789
- const actualCrc32 = crc32 ?? await calculateCrc32(content);
1790
- const actualSize = fileSize ?? content.size;
1791
- const actualContentType = contentType ?? content.type ?? "";
1792
- const arrayBuffer = await content.arrayBuffer();
1793
- await db2.fileCache.where("fileId").equals(fileId).delete();
1794
- const record = {
1795
- id: fileId,
1796
- fileId,
1797
- content: arrayBuffer,
1798
- crc32: actualCrc32,
1799
- fileSize: actualSize,
1800
- contentType: actualContentType,
1801
- updateTime: Date.now()
1802
- };
1803
- await db2.fileCache.put(record);
1804
- } catch (error) {
1805
- console.error("\u5199\u5165\u6587\u4EF6\u7F13\u5B58\u5931\u8D25:", error);
1806
- }
1807
- };
1808
- var removeFromCache = async (fileId) => {
1809
- try {
1810
- await db2.fileCache.where("fileId").equals(fileId).delete();
1811
- } catch (error) {
1812
- console.error("\u5220\u9664\u6587\u4EF6\u7F13\u5B58\u5931\u8D25:", error);
1813
- }
1814
- };
1815
- var hasCache = async (fileId) => {
1816
- const record = await getCacheRecord(fileId);
1817
- return record !== void 0;
1818
- };
1819
- var getCachedContent = async (fileId) => {
1820
- const record = await getCacheRecord(fileId);
1821
- if (!record) {
1822
- console.log("[CacheFileContent] getCachedContent: \u65E0\u7F13\u5B58\u8BB0\u5F55 fileId=", fileId);
1823
- return null;
1824
- }
1825
- const safeContentType = record.contentType ?? "";
1826
- let blob;
1827
- if (record.content instanceof ArrayBuffer) {
1828
- blob = new Blob([record.content], { type: safeContentType });
1829
- console.log(
1830
- "[CacheFileContent] getCachedContent: fileId=",
1831
- fileId,
1832
- "[ArrayBuffer] byteLength=",
1833
- record.content.byteLength,
1834
- "reconstructedBlob.size=",
1835
- blob.size,
1836
- "contentType=",
1837
- safeContentType
1838
- );
1839
- } else if (record.content instanceof Blob) {
1840
- const oldBlob = record.content;
1841
- if (oldBlob.size === 0) {
1842
- console.warn("[CacheFileContent] getCachedContent: \u65E7 Blob \u5DF2\u635F\u574F (size=0)\uFF0C\u5C06\u5220\u9664\u7F13\u5B58\u5E76\u91CD\u65B0\u4E0B\u8F7D");
1843
- await removeFromCache(fileId);
1844
- return null;
1845
- }
1846
- try {
1847
- const ab = await oldBlob.arrayBuffer();
1848
- blob = new Blob([ab], { type: safeContentType || oldBlob.type });
1849
- console.log(
1850
- "[CacheFileContent] getCachedContent: fileId=",
1851
- fileId,
1852
- "[Blob\u2192ArrayBuffer] size=",
1853
- blob.size,
1854
- "contentType=",
1855
- safeContentType
1856
- );
1857
- await saveToCache(fileId, blob, record.crc32, record.fileSize, safeContentType || oldBlob.type);
1858
- } catch (e) {
1859
- console.warn("[CacheFileContent] getCachedContent: \u65E7 Blob \u8BFB\u53D6\u5931\u8D25\uFF0C\u5220\u9664\u7F13\u5B58:", e);
1860
- await removeFromCache(fileId);
1861
- return null;
1862
- }
1863
- } else {
1864
- console.warn("[CacheFileContent] getCachedContent: \u672A\u77E5 content \u7C7B\u578B\uFF0C\u5220\u9664\u7F13\u5B58");
1865
- await removeFromCache(fileId);
1866
- return null;
1867
- }
1868
- return { content: blob, crc32: record.crc32, contentType: safeContentType };
1869
- };
1870
- var validateCache = async (fileId, expectedCrc32) => {
1871
- const record = await getCacheRecord(fileId);
1872
- if (!record) {
1873
- console.log("[CacheFileContent] validateCache: \u65E0\u7F13\u5B58\u8BB0\u5F55 fileId=", fileId);
1874
- return false;
1875
- }
1876
- const storedCrc32 = record.crc32;
1877
- const expected = expectedCrc32;
1878
- const isMatch = storedCrc32 === expected;
1879
- if (!isMatch) {
1880
- console.warn(
1881
- "[CacheFileContent] validateCache: crc32 \u4E0D\u5339\u914D",
1882
- "stored=",
1883
- storedCrc32,
1884
- typeof storedCrc32,
1885
- "expected=",
1886
- expected,
1887
- typeof expected
1888
- );
1889
- }
1890
- return isMatch;
1891
- };
1892
- var clearAllCache = async () => {
1893
- try {
1894
- await db2.fileCache.clear();
1895
- } catch (error) {
1896
- console.error("\u6E05\u9664\u6240\u6709\u6587\u4EF6\u7F13\u5B58\u5931\u8D25:", error);
1897
- }
1898
- };
1899
- var getCacheStats2 = async () => {
1900
- try {
1901
- const all = await db2.fileCache.toArray();
1902
- if (all.length === 0) {
1903
- return { fileCount: 0, totalSize: 0, oldestTime: null, newestTime: null };
1904
- }
1905
- const totalSize = all.reduce((sum, record) => sum + record.fileSize, 0);
1906
- const updateTimes = all.map((record) => record.updateTime);
1907
- return {
1908
- fileCount: all.length,
1909
- totalSize,
1910
- oldestTime: Math.min(...updateTimes),
1911
- newestTime: Math.max(...updateTimes)
1912
- };
1913
- } catch (error) {
1914
- console.error("\u83B7\u53D6\u6587\u4EF6\u7F13\u5B58\u7EDF\u8BA1\u5931\u8D25:", error);
1915
- return { fileCount: 0, totalSize: 0, oldestTime: null, newestTime: null };
1916
- }
1917
- };
1918
- var getCacheList = async () => {
1919
- try {
1920
- const all = await db2.fileCache.toArray();
1921
- return all.map((record) => ({
1922
- fileId: record.fileId,
1923
- crc32: record.crc32,
1924
- fileSize: record.fileSize,
1925
- updateTime: record.updateTime
1926
- }));
1927
- } catch (error) {
1928
- console.error("\u83B7\u53D6\u6587\u4EF6\u7F13\u5B58\u5217\u8868\u5931\u8D25:", error);
1929
- return [];
1930
- }
1931
- };
1932
- var CacheFileContent = {
1933
- saveToCache,
1934
- removeFromCache,
1935
- hasCache,
1936
- getCachedContent,
1937
- validateCache,
1938
- clearAllCache,
1939
- getCacheStats: getCacheStats2,
1940
- getCacheList
1941
- };
1942
- var saveFileMetaBatch = async (projectId, files) => {
1943
- try {
1944
- if (!files || files.length === 0) return;
1945
- const now = Date.now();
1946
- const records = files.map((f) => ({
1947
- id: f.id,
1948
- fileId: f.id,
1949
- projectId,
1950
- meta: f,
1951
- updateTime: now
1952
- }));
1953
- await db2.fileMeta.bulkPut(records);
1954
- } catch (error) {
1955
- console.error("\u6279\u91CF\u4FDD\u5B58\u6587\u4EF6\u5143\u6570\u636E\u7F13\u5B58\u5931\u8D25:", error);
1956
- }
1957
- };
1958
- var saveFileMeta = async (projectId, file2) => {
1959
- try {
1960
- await db2.fileMeta.put({
1961
- id: file2.id,
1962
- fileId: file2.id,
1963
- projectId,
1964
- meta: file2,
1965
- updateTime: Date.now()
1966
- });
1967
- } catch (error) {
1968
- console.error("\u4FDD\u5B58\u6587\u4EF6\u5143\u6570\u636E\u7F13\u5B58\u5931\u8D25:", error);
1969
- }
1970
- };
1971
- var listFileMetaByProject = async (projectId) => {
1972
- try {
1973
- const records = await db2.fileMeta.where("projectId").equals(projectId).toArray();
1974
- return records.map((r) => r.meta);
1975
- } catch (error) {
1976
- console.error("\u5217\u51FA\u9879\u76EE\u6587\u4EF6\u5143\u6570\u636E\u7F13\u5B58\u5931\u8D25:", error);
1977
- return [];
1978
- }
1979
- };
1980
- var getFileMeta = async (fileId) => {
1981
- try {
1982
- const records = await db2.fileMeta.where("fileId").equals(fileId).toArray();
1983
- return records.length > 0 ? records[0].meta : void 0;
1984
- } catch (error) {
1985
- console.error("\u83B7\u53D6\u6587\u4EF6\u5143\u6570\u636E\u7F13\u5B58\u5931\u8D25:", error);
1986
- return void 0;
1987
- }
1988
- };
1989
- var removeFileMeta = async (fileId) => {
1990
- try {
1991
- await db2.fileMeta.where("fileId").equals(fileId).delete();
1992
- } catch (error) {
1993
- console.error("\u5220\u9664\u6587\u4EF6\u5143\u6570\u636E\u7F13\u5B58\u5931\u8D25:", error);
1994
- }
1995
- };
1996
- var CacheFileMeta = {
1997
- saveFileMetaBatch,
1998
- saveFileMeta,
1999
- listFileMetaByProject,
2000
- getFileMeta,
2001
- removeFileMeta
2002
- };
2003
-
2004
- // src/utils/CachePermissionInfo.ts
2005
- import Dexie4 from "dexie";
2006
-
2007
- // src/utils/CacheUserInfo.ts
2008
- import * as febs4 from "febs-browser";
2009
- import Dexie3 from "dexie";
2010
- var CACHE_EXPIRATION_MS2 = 24 * 60 * 60 * 1e3;
2011
- var UserInfoDatabase = class extends Dexie3 {
2012
- constructor() {
2013
- super("UserInfoDB");
2014
- __publicField(this, "userCache");
2015
- this.version(1).stores({
2016
- userCache: "id, timestamp"
2017
- });
2018
- }
2019
- };
2020
- var UserAvatarDatabase = class extends Dexie3 {
2021
- constructor() {
2022
- super("UserAvatarDB");
2023
- __publicField(this, "userCache");
2024
- this.version(1).stores({
2025
- userCache: "id, timestamp"
2026
- });
2027
- }
2028
- };
2029
- var db3 = new UserInfoDatabase();
2030
- var avatarDb = new UserAvatarDatabase();
2031
- var getAvatarFromCache = async (userId) => {
2032
- try {
2033
- const cached = await avatarDb.userCache.get(userId);
2034
- if (cached) {
2035
- const now = Date.now();
2036
- if (now - cached.timestamp < CACHE_EXPIRATION_MS2) {
2037
- return cached.avatar;
2038
- }
2039
- await avatarDb.userCache.delete(userId);
2040
- }
2041
- return null;
2042
- } catch (error) {
2043
- console.error("\u8BFB\u53D6\u7528\u6237\u5934\u50CF\u7F13\u5B58\u5931\u8D25:", error);
2044
- return null;
2045
- }
2046
- };
2047
- var getFromCache2 = async (userId) => {
2048
- try {
2049
- const cached = await db3.userCache.get(userId);
2050
- if (cached) {
2051
- const now = Date.now();
2052
- const avatarCached = await avatarDb.userCache.get(userId);
2053
- if (avatarCached) {
2054
- if (now - avatarCached.timestamp < CACHE_EXPIRATION_MS2) {
2055
- cached.data.avatar = avatarCached.avatar;
2056
- } else {
2057
- cached.data.avatar = void 0;
2058
- await avatarDb.userCache.delete(userId);
2059
- }
2060
- } else {
2061
- cached.data.avatar = void 0;
2062
- }
2063
- if (now - cached.timestamp < CACHE_EXPIRATION_MS2) {
2064
- return cached.data;
2065
- }
2066
- await db3.userCache.delete(userId);
2067
- }
2068
- return null;
2069
- } catch (error) {
2070
- console.error("\u8BFB\u53D6\u7528\u6237\u7F13\u5B58\u5931\u8D25:", error);
2071
- return null;
2072
- }
2073
- };
2074
- var setAvatarToCache = async (userId, data) => {
2075
- try {
2076
- if (data) {
2077
- await avatarDb.userCache.put({
2078
- id: userId,
2079
- avatar: data,
2080
- timestamp: Date.now()
2081
- });
2082
- }
2083
- } catch (error) {
2084
- console.error("\u5199\u5165\u7528\u6237\u5934\u50CF\u7F13\u5B58\u5931\u8D25:", error);
2085
- }
2086
- };
2087
- var setToCache2 = async (userId, data) => {
2088
- try {
2089
- if (data.avatar) {
2090
- await avatarDb.userCache.put({
2091
- id: userId,
2092
- avatar: data.avatar,
2093
- timestamp: Date.now()
2094
- });
2095
- }
2096
- let avatar = data.avatar;
2097
- data.avatar = void 0;
2098
- await db3.userCache.put({
2099
- id: userId,
2100
- data,
2101
- timestamp: Date.now()
2102
- });
2103
- data.avatar = avatar;
2104
- } catch (error) {
2105
- console.error("\u5199\u5165\u7528\u6237\u7F13\u5B58\u5931\u8D25:", error);
2106
- }
2107
- };
2108
- var getMultipleFromCache = async (userIds) => {
2109
- const result = /* @__PURE__ */ new Map();
2110
- try {
2111
- const cached = await db3.userCache.bulkGet(userIds);
2112
- const now = Date.now();
2113
- for (let i = 0; i < userIds.length; i++) {
2114
- const item = cached[i];
2115
- if (item && now - item.timestamp < CACHE_EXPIRATION_MS2) {
2116
- result.set(userIds[i], item.data);
2117
- }
2118
- }
2119
- const avatarCached = await avatarDb.userCache.bulkGet(userIds);
2120
- for (let i = 0; i < userIds.length; i++) {
2121
- const item = avatarCached[i];
2122
- if (!item) continue;
2123
- const user2 = result.get(item.id);
2124
- if (user2 && now - item.timestamp < CACHE_EXPIRATION_MS2) {
2125
- user2.avatar = item.avatar;
2126
- }
2127
- }
2128
- } catch (error) {
2129
- console.error("\u6279\u91CF\u8BFB\u53D6\u7528\u6237\u7F13\u5B58\u5931\u8D25:", error);
2130
- }
2131
- return result;
2132
- };
2133
- var setMultipleToCache = async (users) => {
2134
- try {
2135
- const entries = users.map((u) => ({
2136
- id: u.id,
2137
- data: u.data,
2138
- timestamp: Date.now()
2139
- }));
2140
- let avatarEntries = users.map((u) => ({
2141
- id: u.id,
2142
- avatar: u.data.avatar,
2143
- timestamp: Date.now()
2144
- }));
2145
- avatarEntries = avatarEntries.filter((e) => e.avatar);
2146
- await avatarDb.userCache.bulkPut(avatarEntries);
2147
- entries.forEach((e) => {
2148
- e.data.avatar = void 0;
2149
- });
2150
- await db3.userCache.bulkPut(entries);
2151
- } catch (error) {
2152
- console.error("\u6279\u91CF\u5199\u5165\u7528\u6237\u7F13\u5B58\u5931\u8D25:", error);
2153
- }
2154
- };
2155
- var getAllFromCache = async () => {
2156
- const result = /* @__PURE__ */ new Map();
2157
- try {
2158
- const now = Date.now();
2159
- const all = await db3.userCache.toArray();
2160
- for (const item of all) {
2161
- if (now - item.timestamp < CACHE_EXPIRATION_MS2) {
2162
- const avatarCached = await avatarDb.userCache.get(item.id);
2163
- if (avatarCached && now - avatarCached.timestamp < CACHE_EXPIRATION_MS2) {
2164
- item.data.avatar = avatarCached.avatar;
2165
- }
2166
- result.set(item.id, item.data);
2167
- } else {
2168
- await db3.userCache.delete(item.id);
2169
- }
2170
- }
2171
- } catch (error) {
2172
- console.error("\u83B7\u53D6\u6240\u6709\u7F13\u5B58\u5931\u8D25:", error);
2173
- }
2174
- return result;
2175
- };
2176
- var clearCache2 = async () => {
2177
- try {
2178
- await db3.userCache.clear();
2179
- await avatarDb.userCache.clear();
2180
- } catch (error) {
2181
- console.error("\u6E05\u9664\u7528\u6237\u7F13\u5B58\u5931\u8D25:", error);
2182
- }
2183
- };
2184
- var getUserInfo = async ({
2185
- user_id,
2186
- forceRefresh = false,
2187
- forceAvatar = false
2188
- }) => {
2189
- let r = {
2190
- code: 200 /* SUCCESS */,
2191
- data: {
2192
- user_id,
2193
- isLogin: true
2194
- }
2195
- };
2196
- let isLoginNetworkError = false;
2197
- if (!user_id) {
2198
- try {
2199
- r = await API.user.gateway.isLogin();
2200
- } catch (e) {
2201
- isLoginNetworkError = true;
2202
- }
2203
- }
2204
- if (isLoginNetworkError) {
2205
- let localUserId;
2206
- try {
2207
- const rawUser = storage.namespace("bp.ss").get("user");
2208
- if (rawUser) {
2209
- const parsed = JSON.parse(rawUser);
2210
- localUserId = parsed?.id;
2211
- }
2212
- } catch {
2213
- }
2214
- const queryId = user_id ?? localUserId;
2215
- if (queryId) {
2216
- const cached = await getFromCache2(queryId);
2217
- if (cached) {
2218
- const av = await getUserAvatar({ user_id: queryId, forceRefresh: false, serverTick: cached.tick_avatar_self });
2219
- if (av) cached.avatar = av;
2220
- return cached;
2221
- }
2222
- }
2223
- try {
2224
- const rawUser = storage.namespace("bp.ss").get("user");
2225
- if (rawUser) return JSON.parse(rawUser);
2226
- } catch {
2227
- }
2228
- return null;
2229
- }
2230
- if (r?.code === 200 /* SUCCESS */ && r.data?.isLogin) {
2231
- let userId = r.data?.user_id;
2232
- let isAdminFlag = r.data?.isAdmin || false;
2233
- let cachedUserInfo = await getFromCache2(userId);
2234
- if (forceRefresh || !cachedUserInfo) {
2235
- try {
2236
- let r2 = await API.user.user.getInfo({ id: userId });
2237
- if (r2?.code == 200 /* SUCCESS */) {
2238
- if (!user_id) {
2239
- storage.namespace("bp.ss").set("user", JSON.stringify(r2.data));
2240
- }
2241
- const userInfo = {
2242
- ...r2.data
2243
- };
2244
- if (userId) {
2245
- await setToCache2(userId, userInfo);
2246
- }
2247
- try {
2248
- let avatar = await getUserAvatar({ user_id: userId, forceRefresh: forceAvatar, serverTick: r2.data?.tick_avatar_self });
2249
- if (avatar) {
2250
- userInfo.avatar = avatar;
2251
- }
2252
- } catch {
2253
- }
2254
- return userInfo;
2255
- } else if (cachedUserInfo) {
2256
- return cachedUserInfo;
2257
- } else {
2258
- return null;
2259
- }
2260
- } catch (e) {
2261
- if (cachedUserInfo) return cachedUserInfo;
2262
- try {
2263
- const rawUser = storage.namespace("bp.ss").get("user");
2264
- if (rawUser) return JSON.parse(rawUser);
2265
- } catch {
2266
- }
2267
- return null;
2268
- }
2269
- }
2270
- try {
2271
- let avatar = await getUserAvatar({ user_id: userId, forceRefresh: forceAvatar, serverTick: cachedUserInfo.tick_avatar_self });
2272
- if (avatar) {
2273
- cachedUserInfo.avatar = avatar;
2274
- }
2275
- } catch {
2276
- }
2277
- return cachedUserInfo;
2278
- } else {
2279
- AuthorizationHandler.clearStoreToken();
2280
- return null;
2281
- }
2282
- };
2283
- var getUserAvatar = async ({
2284
- user_id,
2285
- forceRefresh = false,
2286
- serverTick = Number.MAX_SAFE_INTEGER
2287
- // 服务器上最新的tick.
2288
- }) => {
2289
- if (!user_id) {
2290
- return void 0;
2291
- }
2292
- let cachedUserInfo = await getAvatarFromCache(user_id);
2293
- if (forceRefresh || !cachedUserInfo) {
2294
- const tickSelf = cachedUserInfo?.avatar_tick || -1;
2295
- if (tickSelf < serverTick) {
2296
- try {
2297
- let rAvatar = await API.user.user.getAvatar({ id: user_id, tick: tickSelf });
2298
- if (rAvatar?.code == 200 /* SUCCESS */ && tickSelf != rAvatar.data?.tick_self) {
2299
- cachedUserInfo = {
2300
- avatar: febs4.string.isEmpty(rAvatar.data?.avatar) ? void 0 : rAvatar.data?.avatar,
2301
- avatar_small: febs4.string.isEmpty(rAvatar.data?.avatar_small) ? void 0 : rAvatar.data?.avatar_small,
2302
- avatar_tick: rAvatar.data?.tick_self || -1
2303
- };
2304
- await setAvatarToCache(user_id, cachedUserInfo);
2305
- }
2306
- } catch {
2307
- }
2308
- }
2309
- }
2310
- return cachedUserInfo || void 0;
2311
- };
2312
- var current = async (options) => {
2313
- options = options || { forceRefresh: false };
2314
- return await getUserInfo(options);
2315
- };
2316
- var currentLocalUser = () => {
2317
- let user2 = storage.namespace("bp.ss").get("user");
2318
- if (user2) {
2319
- return JSON.parse(user2);
2320
- }
2321
- return null;
2322
- };
2323
- var getUserInfos = async ({
2324
- userIds,
2325
- keywords,
2326
- forceRefresh = false
2327
- }) => {
2328
- const result = /* @__PURE__ */ new Map();
2329
- if (!userIds) {
2330
- if (!forceRefresh && (!keywords || keywords.length === 0)) {
2331
- const cachedUsers = await getAllFromCache();
2332
- if (cachedUsers.size >= 100) {
2333
- const top100 = /* @__PURE__ */ new Map();
2334
- let count = 0;
2335
- for (const [id, info] of cachedUsers) {
2336
- if (count >= 100) break;
2337
- const avatar = await getUserAvatar({ user_id: id, forceRefresh: false, serverTick: info.tick_avatar_self });
2338
- info.avatar = avatar;
2339
- top100.set(id, info);
2340
- count++;
2341
- }
2342
- return top100;
2343
- }
2344
- return cachedUsers;
2345
- }
2346
- let listRes;
2347
- if (keywords && keywords.length > 0) {
2348
- listRes = await API.user.user.search({ pageNum: 1, pageSize: 100, keyword: keywords });
2349
- if (listRes?.code !== 200 /* SUCCESS */) {
2350
- return result;
2351
- }
2352
- } else {
2353
- listRes = await API.user.user.list({ pageNum: 1, pageSize: 100 });
2354
- if (listRes?.code !== 200 /* SUCCESS */) {
2355
- return result;
2356
- }
2357
- }
2358
- const users = listRes.data?.list || [];
2359
- const userInfos = [];
2360
- for (const user2 of users) {
2361
- const userInfo = {
2362
- ...user2
2363
- };
2364
- result.set(user2.id, userInfo);
2365
- userInfos.push({ id: user2.id, data: userInfo });
2366
- }
2367
- if (userInfos.length > 0) {
2368
- await setMultipleToCache(userInfos);
2369
- }
2370
- for (let i = 0; i < userInfos.length; i++) {
2371
- let avatar = await getUserAvatar({ user_id: userInfos[i].id, serverTick: userInfos[i].data.tick_avatar_self });
2372
- userInfos[i].data.avatar = avatar;
2373
- }
2374
- return result;
2375
- }
2376
- if (userIds.length == 0) {
2377
- return result;
2378
- }
2379
- const uniqueIds = [...new Set(userIds)];
2380
- if (!forceRefresh) {
2381
- const cachedUsers = await getMultipleFromCache(uniqueIds);
2382
- cachedUsers.forEach((info, id) => {
2383
- result.set(id, info);
2384
- });
2385
- }
2386
- const uncachedIds = uniqueIds.filter((id) => !result.has(id));
2387
- if (uncachedIds.length === 0) {
2388
- return result;
2389
- }
2390
- try {
2391
- let resUsers = await API.user.user.listByIds({ ids: JSON.stringify(uncachedIds) });
2392
- if (resUsers?.code != 200 /* SUCCESS */) {
2393
- return result;
2394
- }
2395
- let users = resUsers.data?.list || [];
2396
- if (users.length > 0) {
2397
- let r = [];
2398
- for (const user2 of users) {
2399
- const userInfo = {
2400
- ...user2
2401
- };
2402
- r.push({ id: user2.id, data: userInfo });
2403
- }
2404
- await setMultipleToCache(r);
2405
- }
2406
- let userAvatarCache = [];
2407
- if (users.length > 0) {
2408
- for (const user2 of users) {
2409
- const avatar = await getUserAvatar({ user_id: user2.id, serverTick: user2.tick_avatar_self || -1 });
2410
- userAvatarCache.push({
2411
- id: user2.id,
2412
- avatar_small: avatar?.avatar_small || "",
2413
- avatar_tick: user2.tick_avatar_self || -1
2414
- });
2415
- }
2416
- }
2417
- for (const user2 of users) {
2418
- const avatar = userAvatarCache.find((v) => v.id == user2.id);
2419
- const userInfo = {
2420
- ...user2,
2421
- avatar: {
2422
- avatar: "",
2423
- avatar_small: avatar?.avatar_small || "",
2424
- avatar_tick: avatar?.avatar_tick || -1
2425
- }
2426
- };
2427
- result.set(user2.id, userInfo);
2428
- }
2429
- } catch (error) {
2430
- console.error("\u6279\u91CF\u83B7\u53D6\u7528\u6237\u4FE1\u606F\u5931\u8D25:", error);
2431
- }
2432
- return result;
2433
- };
2434
- var clearUserCache = async (userId) => {
2435
- if (userId) {
2436
- await db3.userCache.delete(userId);
2437
- } else {
2438
- await clearCache2();
2439
- }
2440
- };
2441
- var getCacheStats3 = async () => {
2442
- try {
2443
- const all = await db3.userCache.toArray();
2444
- if (all.length === 0) {
2445
- return { count: 0, oldest: null, newest: null };
2446
- }
2447
- const timestamps = all.map((item) => item.timestamp);
2448
- return {
2449
- count: all.length,
2450
- oldest: Math.min(...timestamps),
2451
- newest: Math.max(...timestamps)
2452
- };
2453
- } catch (error) {
2454
- console.error("\u83B7\u53D6\u7F13\u5B58\u7EDF\u8BA1\u5931\u8D25:", error);
2455
- return { count: 0, oldest: null, newest: null };
2456
- }
2457
- };
2458
- var CacheUserInfo = {
2459
- /**
2460
- * 从缓存获取用户信息
2461
- * @param userId 用户ID
2462
- * @returns 缓存的用户信息或null
2463
- */
2464
- getFromCache: getFromCache2,
2465
- getAvatarFromCache,
2466
- /**
2467
- * 获取当前登录用户信息
2468
- * @param user_id 用户ID(可选,不传则获取当前登录用户)
2469
- * @param isAdmin 是否为管理员
2470
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
2471
- * @returns 用户信息
2472
- */
2473
- getUserInfo,
2474
- getUserAvatar,
2475
- /**
2476
- * 获取当前登录角色
2477
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
2478
- * @returns 用户信息
2479
- */
2480
- current,
2481
- /**
2482
- * 获取本地存储的当前登录用户信息
2483
- */
2484
- currentLocalUser,
2485
- /**
2486
- * 批量获取多个用户信息;
2487
- * @param keywords 搜索关键词, 可选,与userIds不能同时提供.
2488
- * @param userIds 用户ID数组, length=0, 则获取前100个.
2489
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
2490
- * @returns 用户信息映射表(key为用户ID,value为用户信息)
2491
- */
2492
- getUserInfos,
2493
- /**
2494
- * 清除指定用户的缓存
2495
- * @param userId 用户ID
2496
- */
2497
- clearUserCache,
2498
- /**
2499
- * 获取缓存统计信息
2500
- * @returns 缓存统计信息
2501
- */
2502
- getCacheStats: getCacheStats3
2503
- };
2504
-
2505
- // src/utils/CachePermissionInfo.ts
2506
- var PERMISSION_INVOICE_LIST = "approver:approvalinvoice:getInvoiceList";
2507
- var PERMISSION_FOLDER_DOWNLOAD = "project:projectfile:downloadFolderPermission";
2508
- var PERMISSION_CRM_CREATE = "crm:customer:createCustomer";
2509
- var PERMISSION_CRM_UPDATE = "crm:customer:updateCustomer";
2510
- var PERMISSION_CRM_DELETE = "crm:customer:deleteCustomer";
2511
- var PERMISSION_CRM_VIEW_CONTACT = "crm:customer:viewContact";
2512
- var PERMISSION_CRM_TRANSFER = "crm:customer:transferCustomer";
2513
- var PERMISSION_CRM_VIEW_FILE = "crm:file:viewFile";
2514
- var PERMISSION_CRM_MANAGE_FILE = "crm:file:manageFile";
2515
- var CACHE_EXPIRATION_MS3 = 10 * 60 * 1e3;
2516
- var PermissionInfoDatabase = class extends Dexie4 {
2517
- constructor() {
2518
- super("PermissionInfoDB");
2519
- __publicField(this, "permissionCache");
2520
- this.version(1).stores({
2521
- permissionCache: "id, timestamp"
2522
- });
2523
- }
2524
- };
2525
- var db4 = new PermissionInfoDatabase();
2526
- var getFromCache3 = async (userId) => {
2527
- try {
2528
- const cached = await db4.permissionCache.get(`PERMISSION_${userId}`);
2529
- if (cached) {
2530
- const now = Date.now();
2531
- if (now - cached.timestamp < CACHE_EXPIRATION_MS3) {
2532
- return cached.data;
2533
- }
2534
- await db4.permissionCache.delete(`PERMISSION_${userId}`);
2535
- }
2536
- return null;
2537
- } catch (error) {
2538
- console.error("\u8BFB\u53D6\u6743\u9650\u7F13\u5B58\u5931\u8D25:", error);
2539
- return null;
2540
- }
2541
- };
2542
- var setToCache3 = async (userId, data) => {
2543
- try {
2544
- await db4.permissionCache.put({
2545
- id: `PERMISSION_${userId}`,
2546
- data,
2547
- timestamp: Date.now()
2548
- });
2549
- } catch (error) {
2550
- console.error("\u5199\u5165\u6743\u9650\u7F13\u5B58\u5931\u8D25:", error);
2551
- }
2552
- };
2553
- var clearCache3 = async (userId) => {
2554
- try {
2555
- if (userId) {
2556
- await db4.permissionCache.delete(`PERMISSION_${userId}`);
2557
- } else {
2558
- await db4.permissionCache.clear();
2559
- }
2560
- } catch (error) {
2561
- console.error("\u6E05\u9664\u6743\u9650\u7F13\u5B58\u5931\u8D25:", error);
2562
- }
2563
- };
2564
- var getUserPermissions = async ({
2565
- userId,
2566
- forceRefresh = false
2567
- }) => {
2568
- const user2 = userId ? { id: userId } : await CacheUserInfo.getUserInfo({});
2569
- if (!user2) {
2570
- return null;
2571
- }
2572
- const uid = user2.id;
2573
- if (!forceRefresh) {
2574
- const cachedPermissions = await getFromCache3(uid);
2575
- if (cachedPermissions) {
2576
- return cachedPermissions;
2577
- }
2578
- }
2579
- const res = await API.user.role.listUserPermissions({ user_id: uid });
2580
- if (res?.code !== 200 /* SUCCESS */) {
2581
- return null;
2582
- }
2583
- const permissions = res.data || [];
2584
- await setToCache3(uid, permissions);
2585
- return permissions;
2586
- };
2587
- var hasPermission = async ({
2588
- permission,
2589
- userId,
2590
- forceRefresh = false
2591
- }) => {
2592
- const permissions = await getUserPermissions({ userId, forceRefresh });
2593
- if (!permissions) {
2594
- return false;
2595
- }
2596
- return permissions.some((p) => p.permission === permission);
2597
- };
2598
- var hasPermissions = async ({
2599
- permissions,
2600
- userId,
2601
- forceRefresh = false,
2602
- allRequired = true
2603
- }) => {
2604
- const userPermissions = await getUserPermissions({ userId, forceRefresh });
2605
- if (!userPermissions) {
2606
- return false;
2607
- }
2608
- const userPermSet = new Set(userPermissions.map((p) => p.permission));
2609
- if (allRequired) {
2610
- return permissions.every((p) => userPermSet.has(p));
2611
- }
2612
- return permissions.some((p) => userPermSet.has(p));
2613
- };
2614
- var getPermissionDesc = async ({
2615
- permission,
2616
- userId,
2617
- forceRefresh = false
2618
- }) => {
2619
- const permissions = await getUserPermissions({ userId, forceRefresh });
2620
- if (!permissions) {
2621
- return "";
2622
- }
2623
- const found = permissions.find((p) => p.permission === permission);
2624
- return found?.descs || "";
2625
- };
2626
- var clearPermissionCache = async (userId) => {
2627
- await clearCache3(userId);
2628
- };
2629
- var getCacheStats4 = async () => {
2630
- try {
2631
- const all = await db4.permissionCache.toArray();
2632
- if (all.length === 0) {
2633
- return { count: 0, oldest: null, newest: null };
2634
- }
2635
- const timestamps = all.map((item) => item.timestamp);
2636
- return {
2637
- count: all.length,
2638
- oldest: Math.min(...timestamps),
2639
- newest: Math.max(...timestamps)
2640
- };
2641
- } catch (error) {
2642
- console.error("\u83B7\u53D6\u6743\u9650\u7F13\u5B58\u7EDF\u8BA1\u5931\u8D25:", error);
2643
- return { count: 0, oldest: null, newest: null };
2644
- }
2645
- };
2646
- var CachePermissionInfo = {
2647
- getUserPermissions,
2648
- hasPermission,
2649
- hasPermissions,
2650
- getPermissionDesc,
2651
- clearPermissionCache,
2652
- getCacheStats: getCacheStats4
2653
- };
2654
-
2655
- // src/utils/CacheRoleInfo.ts
2656
- import Dexie5 from "dexie";
2657
- var CACHE_EXPIRATION_MS4 = 1 * 60 * 60 * 1e3;
2658
- var RoleInfoDatabase = class extends Dexie5 {
2659
- constructor() {
2660
- super("RoleInfoDB");
2661
- __publicField(this, "roleCache");
2662
- this.version(1).stores({
2663
- roleCache: "id, timestamp"
2664
- });
2665
- }
2666
- };
2667
- var db5 = new RoleInfoDatabase();
2668
- var getFromCache4 = async () => {
2669
- try {
2670
- const cached = await db5.roleCache.get("ROLE_ALL");
2671
- if (cached) {
2672
- const now = Date.now();
2673
- if (now - cached.timestamp < CACHE_EXPIRATION_MS4) {
2674
- return cached.data;
2675
- }
2676
- await db5.roleCache.delete("ROLE_ALL");
2677
- }
2678
- return null;
2679
- } catch (error) {
2680
- console.error("\u8BFB\u53D6\u89D2\u8272\u7F13\u5B58\u5931\u8D25:", error);
2681
- return null;
2682
- }
2683
- };
2684
- var setToCache4 = async (data) => {
2685
- try {
2686
- await db5.roleCache.put({
2687
- id: "ROLE_ALL",
2688
- data,
2689
- timestamp: Date.now()
2690
- });
2691
- } catch (error) {
2692
- console.error("\u5199\u5165\u89D2\u8272\u7F13\u5B58\u5931\u8D25:", error);
2693
- }
2694
- };
2695
- var clearCache4 = async () => {
2696
- try {
2697
- await db5.roleCache.clear();
2698
- } catch (error) {
2699
- console.error("\u6E05\u9664\u89D2\u8272\u7F13\u5B58\u5931\u8D25:", error);
2700
- }
2701
- };
2702
- var getRoleList = async ({
2703
- forceRefresh = false
2704
- }) => {
2705
- if (!forceRefresh) {
2706
- const cachedRoleInfo = await getFromCache4();
2707
- if (cachedRoleInfo) {
2708
- return cachedRoleInfo;
2709
- }
2710
- }
2711
- const res = await API.user.role.listRoles();
2712
- if (res?.code !== 200 /* SUCCESS */) {
2713
- return null;
2714
- }
2715
- const roles = res.data || [];
2716
- await setToCache4(roles);
2717
- return roles;
2718
- };
2719
- var getRoleById = async ({
2720
- roleId,
2721
- forceRefresh = false
2722
- }) => {
2723
- const roles = await getRoleList({ forceRefresh });
2724
- if (!roles) {
2725
- return null;
2726
- }
2727
- return roles.find((role2) => role2.id === roleId) || null;
2728
- };
2729
- var getRoleNameById = async ({
2730
- roleId,
2731
- forceRefresh = false
2732
- }) => {
2733
- const role2 = await getRoleById({ roleId, forceRefresh });
2734
- return role2?.name || "";
2735
- };
2736
- var getRoleNameMap = async ({
2737
- forceRefresh = false
2738
- } = {}) => {
2739
- const roles = await getRoleList({ forceRefresh });
2740
- const map = {};
2741
- (roles || []).forEach((role2) => {
2742
- map[role2.id] = role2.name;
2743
- });
2744
- return map;
2745
- };
2746
- var getRoleNameMapForIds = async ({
2747
- roleIds
2748
- }) => {
2749
- let map = await getRoleNameMap();
2750
- const missing = (roleIds || []).filter((id) => !!id && !map[id]);
2751
- if (missing.length > 0) {
2752
- map = await getRoleNameMap({ forceRefresh: true });
2753
- }
2754
- return map;
2755
- };
2756
- var clearRoleCache = async () => {
2757
- await clearCache4();
2758
- };
2759
- var getCacheStats5 = async () => {
2760
- try {
2761
- const all = await db5.roleCache.toArray();
2762
- if (all.length === 0) {
2763
- return { count: 0, oldest: null, newest: null };
2764
- }
2765
- const timestamps = all.map((item) => item.timestamp);
2766
- return {
2767
- count: all.length,
2768
- oldest: Math.min(...timestamps),
2769
- newest: Math.max(...timestamps)
2770
- };
2771
- } catch (error) {
2772
- console.error("\u83B7\u53D6\u7F13\u5B58\u7EDF\u8BA1\u5931\u8D25:", error);
2773
- return { count: 0, oldest: null, newest: null };
2774
- }
2775
- };
2776
- var CacheRoleInfo = {
2777
- /**
2778
- * 获取所有角色信息
2779
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
2780
- * @returns 角色信息数组
2781
- */
2782
- getRoleList,
2783
- /**
2784
- * 根据角色ID获取角色信息
2785
- * @param roleId 角色ID
2786
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
2787
- * @returns 角色信息或null
2788
- */
2789
- getRoleById,
2790
- /**
2791
- * 根据角色ID获取角色名称
2792
- * @param roleId 角色ID
2793
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
2794
- * @returns 角色名称或空字符串
2795
- */
2796
- getRoleNameById,
2797
- /**
2798
- * 获取角色ID到角色名称的映射
2799
- * @param forceRefresh 是否强制刷新缓存(默认false,使用缓存)
2800
- * @returns 角色ID -> 角色名称
2801
- */
2802
- getRoleNameMap,
2803
- /**
2804
- * 获取指定角色ID的名称映射;若缓存中缺失部分角色,强制刷新一次后重试
2805
- * @param roleIds 需要解析的角色ID数组
2806
- * @returns 角色ID -> 角色名称
2807
- */
2808
- getRoleNameMapForIds,
2809
- /**
2810
- * 清除角色缓存
2811
- */
2812
- clearRoleCache,
2813
- /**
2814
- * 获取缓存统计信息
2815
- * @returns 缓存统计信息
2816
- */
2817
- getCacheStats: getCacheStats5
2818
- };
2819
-
2820
- // src/utils/CacheViewToggleInfo.ts
2821
- import Dexie6 from "dexie";
2822
- var ViewToggleDatabase = class extends Dexie6 {
2823
- constructor() {
2824
- super("ViewToggleDB");
2825
- __publicField(this, "viewModeCache");
2826
- this.version(1).stores({
2827
- viewModeCache: "pageKey, timestamp"
2828
- });
2829
- }
2830
- };
2831
- var db6 = new ViewToggleDatabase();
2832
- var getFromCache5 = async (pageKey) => {
2833
- try {
2834
- const cached = await db6.viewModeCache.get(pageKey);
2835
- if (cached) {
2836
- return cached.viewMode;
2837
- }
2838
- return null;
2839
- } catch (error) {
2840
- console.error("\u8BFB\u53D6\u89C6\u56FE\u6A21\u5F0F\u7F13\u5B58\u5931\u8D25:", error);
2841
- return null;
2842
- }
2843
- };
2844
- var setToCache5 = async (pageKey, viewMode) => {
2845
- try {
2846
- await db6.viewModeCache.put({
2847
- pageKey,
2848
- viewMode,
2849
- timestamp: Date.now()
2850
- });
2851
- } catch (error) {
2852
- console.error("\u5199\u5165\u89C6\u56FE\u6A21\u5F0F\u7F13\u5B58\u5931\u8D25:", error);
2853
- }
2854
- };
2855
- var clearCache5 = async (pageKey) => {
2856
- try {
2857
- await db6.viewModeCache.delete(pageKey);
2858
- } catch (error) {
2859
- console.error("\u6E05\u9664\u89C6\u56FE\u6A21\u5F0F\u7F13\u5B58\u5931\u8D25:", error);
2860
- }
2861
- };
2862
- var clearAllCache2 = async () => {
2863
- try {
2864
- await db6.viewModeCache.clear();
2865
- } catch (error) {
2866
- console.error("\u6E05\u9664\u6240\u6709\u89C6\u56FE\u6A21\u5F0F\u7F13\u5B58\u5931\u8D25:", error);
2867
- }
2868
- };
2869
- var getViewMode = async (pageKey) => {
2870
- return await getFromCache5(pageKey);
2871
- };
2872
- var setViewMode = async (pageKey, viewMode) => {
2873
- await setToCache5(pageKey, viewMode);
2874
- };
2875
- var clearViewModeCache = async (pageKey) => {
2876
- await clearCache5(pageKey);
2877
- };
2878
- var clearAllViewModeCache = async () => {
2879
- await clearAllCache2();
2880
- };
2881
- var getAllCachedViewModes = async () => {
2882
- try {
2883
- return await db6.viewModeCache.toArray();
2884
- } catch (error) {
2885
- console.error("\u83B7\u53D6\u6240\u6709\u89C6\u56FE\u6A21\u5F0F\u7F13\u5B58\u5931\u8D25:", error);
2886
- return [];
2887
- }
2888
- };
2889
- var CacheViewToggleInfo = {
2890
- /**
2891
- * 获取指定页面的视图模式
2892
- * @param pageKey 页面标识(如路由路径)
2893
- * @returns 视图模式值或null
2894
- */
2895
- getViewMode,
2896
- /**
2897
- * 设置指定页面的视图模式
2898
- * @param pageKey 页面标识(如路由路径)
2899
- * @param viewMode 视图模式值
2900
- */
2901
- setViewMode,
2902
- /**
2903
- * 清除指定页面的视图模式缓存
2904
- * @param pageKey 页面标识
2905
- */
2906
- clearViewModeCache,
2907
- /**
2908
- * 清除所有视图模式缓存
2909
- */
2910
- clearAllViewModeCache,
2911
- /**
2912
- * 获取所有缓存的页面视图模式
2913
- * @returns 所有缓存的页面视图模式
2914
- */
2915
- getAllCachedViewModes
2916
- };
2917
-
2918
- // src/utils/MessageContentUtils.ts
2919
- var MESSAGE_TYPE_LABELS = {
2920
- project: "\u9879\u76EE\u52A8\u6001",
2921
- approval: "\u5BA1\u6279\u52A8\u6001",
2922
- knowledge: "\u77E5\u8BC6\u5E93",
2923
- todo: "\u5F85\u529E\u4EFB\u52A1",
2924
- crm: "\u5BA2\u6237\u7BA1\u7406"
2925
- };
2926
- var PROJECT_BIZ_LABELS = {
2927
- file_add: "\u6587\u4EF6\u65B0\u589E",
2928
- file_update: "\u6587\u4EF6\u66F4\u65B0",
2929
- file_delete: "\u6587\u4EF6\u5220\u9664",
2930
- contract_add: "\u5408\u540C\u65B0\u589E",
2931
- contract_delete: "\u5408\u540C\u5220\u9664",
2932
- contract_update: "\u5408\u540C\u66F4\u65B0",
2933
- detail: "\u8BE6\u60C5\u66F4\u65B0",
2934
- member_add: "\u6210\u5458\u52A0\u5165",
2935
- member_remove: "\u6210\u5458\u79FB\u9664",
2936
- member_role_change: "\u89D2\u8272\u53D8\u66F4",
2937
- file_download: "\u6587\u4EF6\u4E0B\u8F7D"
2938
- };
2939
- var APPROVAL_BIZ_LABELS = {
2940
- submit: "\u5BA1\u6279\u63D0\u4EA4",
2941
- approve: "\u5BA1\u6279\u901A\u8FC7",
2942
- reject: "\u5BA1\u6279\u9A73\u56DE",
2943
- cancel: "\u5BA1\u6279\u64A4\u9500",
2944
- deal: "\u4EA7\u7269\u66F4\u65B0"
2945
- };
2946
- var KNOWLEDGE_BIZ_LABELS = {
2947
- kb_new: "\u65B0\u589E\u77E5\u8BC6"
2948
- };
2949
- var TODO_BIZ_LABELS = {
2950
- task_assign: "\u4EFB\u52A1\u6307\u6D3E",
2951
- task_remind: "\u5230\u671F\u63D0\u9192"
2952
- };
2953
- var CRM_BIZ_LABELS = {
2954
- customer_transfer_in: "\u5BA2\u6237\u79FB\u4EA4\uFF08\u63A5\u6536\uFF09",
2955
- customer_transfer_out: "\u5BA2\u6237\u79FB\u4EA4\uFF08\u79FB\u4EA4\u51FA\uFF09"
2956
- };
2957
- var PROJECT_BIZ_TAB_MAP = {
2958
- file_add: "files",
2959
- file_update: "files",
2960
- file_delete: "files",
2961
- contract_add: "contracts",
2962
- contract_update: "contracts",
2963
- contract_delete: "contracts",
2964
- detail: "detail",
2965
- member_add: "members",
2966
- member_remove: "members",
2967
- member_role_change: "members"
2968
- };
2969
- var MessageContentUtils = class _MessageContentUtils {
2970
- /**
2971
- * 构造消息 content JSON 字符串
2972
- * @param type 消息大类
2973
- * @param bizType 业务子类型
2974
- * @param id 关联业务主键
2975
- * @param text 人话描述
2976
- * @returns 序列化后的 JSON 字符串
2977
- */
2978
- static buildContent(type, bizType, id, text) {
2979
- const content = { type, bizType, id: id || "", text: text || "" };
2980
- return JSON.stringify(content);
2981
- }
2982
- /**
2983
- * 解析消息 content JSON 字符串
2984
- * @param content content 字段
2985
- * @returns 解析后的结构,解析失败返回 null
2986
- */
2987
- static parseContent(content) {
2988
- if (!content) {
2989
- return null;
2990
- }
2991
- try {
2992
- const obj = JSON.parse(content);
2993
- if (obj && typeof obj.type === "string" && typeof obj.bizType === "string" && typeof obj.id === "string") {
2994
- const parsed = {
2995
- type: obj.type,
2996
- bizType: obj.bizType,
2997
- id: obj.id,
2998
- text: typeof obj.text === "string" ? obj.text : ""
2999
- };
3000
- if (typeof obj.url === "string") {
3001
- parsed.url = obj.url;
3002
- }
3003
- if (typeof obj.fileName === "string") {
3004
- parsed.fileName = obj.fileName;
3005
- }
3006
- if (typeof obj.jobId === "string") {
3007
- parsed.jobId = obj.jobId;
3008
- }
3009
- if (typeof obj.expireAt === "number") {
3010
- parsed.expireAt = obj.expireAt;
3011
- }
3012
- return parsed;
3013
- }
3014
- return null;
3015
- } catch (e) {
3016
- return null;
3017
- }
3018
- }
3019
- /** 判断是否为受支持的消息大类 */
3020
- static isMessageType(type) {
3021
- return Object.prototype.hasOwnProperty.call(MESSAGE_TYPE_LABELS, type);
3022
- }
3023
- /** 获取消息大类展示名称,未知类型降级为「系统消息」 */
3024
- static getTypeLabel(type) {
3025
- return MESSAGE_TYPE_LABELS[type] || "\u7CFB\u7EDF\u6D88\u606F";
3026
- }
3027
- /** 获取业务子类型展示名称,未知子类型返回空串 */
3028
- static getBizTypeLabel(type, bizType) {
3029
- switch (type) {
3030
- case "project":
3031
- return PROJECT_BIZ_LABELS[bizType] || "";
3032
- case "approval":
3033
- return APPROVAL_BIZ_LABELS[bizType] || "";
3034
- case "knowledge":
3035
- return KNOWLEDGE_BIZ_LABELS[bizType] || "";
3036
- case "todo":
3037
- return TODO_BIZ_LABELS[bizType] || "";
3038
- case "crm":
3039
- return CRM_BIZ_LABELS[bizType] || "";
3040
- default:
3041
- return "";
3042
- }
3043
- }
3044
- /**
3045
- * 获取消息正文:优先展示后端下发的人话 text,
3046
- * text 缺失时降级为业务子类型名称。
3047
- */
3048
- static getDisplayText(content) {
3049
- if (!content) {
3050
- return "";
3051
- }
3052
- return content.text || _MessageContentUtils.getBizTypeLabel(content.type, content.bizType);
3053
- }
3054
- /**
3055
- * 获取消息关联业务页面的跳转路由(含查询参数)。
3056
- * project -> /project?id=xxx&tab=files|contracts|members|detail
3057
- * approval -> /approval?instanceId=xxx
3058
- * knowledge -> /knowledge?id=xxx
3059
- * todo -> /todo?todoId=xxx(待办页读取参数后自动打开任务抽屉)
3060
- * 未知类型或缺少关联ID时返回 null。
3061
- */
3062
- static getJumpRoute(content) {
3063
- if (!content || !content.id) {
3064
- return null;
3065
- }
3066
- const id = encodeURIComponent(content.id);
3067
- switch (content.type) {
3068
- case "project": {
3069
- if (content.bizType === "file_download") {
3070
- return null;
3071
- }
3072
- const tab = PROJECT_BIZ_TAB_MAP[content.bizType];
3073
- return `/project?id=${id}${tab ? `&tab=${tab}` : ""}`;
3074
- }
3075
- case "approval":
3076
- return `/approval?instanceId=${id}`;
3077
- case "knowledge":
3078
- return `/knowledge?id=${id}`;
3079
- case "todo":
3080
- return `/todo?todoId=${id}`;
3081
- case "crm":
3082
- return `/crm?id=${id}`;
3083
- default:
3084
- return null;
3085
- }
3086
- }
3087
- };
3088
-
3089
- // src/utils/clipboard.ts
3090
- async function copyToClipboard(text) {
3091
- if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
3092
- try {
3093
- await navigator.clipboard.writeText(text);
3094
- return;
3095
- } catch {
3096
- }
3097
- }
3098
- const succeeded = copyViaExecCommand(text);
3099
- if (!succeeded) {
3100
- throw new Error("\u590D\u5236\u5230\u526A\u8D34\u677F\u5931\u8D25");
3101
- }
3102
- }
3103
- function copyViaExecCommand(text) {
3104
- const textarea = document.createElement("textarea");
3105
- textarea.value = text;
3106
- textarea.setAttribute("contenteditable", "true");
3107
- textarea.style.position = "fixed";
3108
- textarea.style.top = "0";
3109
- textarea.style.left = "0";
3110
- textarea.style.width = "1px";
3111
- textarea.style.height = "1px";
3112
- textarea.style.padding = "0";
3113
- textarea.style.border = "none";
3114
- textarea.style.outline = "none";
3115
- textarea.style.boxShadow = "none";
3116
- textarea.style.background = "transparent";
3117
- textarea.style.opacity = "0";
3118
- document.body.appendChild(textarea);
3119
- const isIOS = /ipad|iphone|ipod/i.test(navigator.userAgent);
3120
- let succeeded = false;
3121
- try {
3122
- if (isIOS) {
3123
- const selection = document.getSelection();
3124
- const range = document.createRange();
3125
- range.selectNodeContents(textarea);
3126
- selection?.removeAllRanges();
3127
- selection?.addRange(range);
3128
- textarea.setSelectionRange(0, text.length);
3129
- } else {
3130
- textarea.focus();
3131
- textarea.select();
3132
- textarea.setSelectionRange(0, text.length);
3133
- }
3134
- succeeded = document.execCommand("copy");
3135
- } catch {
3136
- succeeded = false;
3137
- } finally {
3138
- document.body.removeChild(textarea);
3139
- }
3140
- return succeeded;
3141
- }
3142
-
3143
- // src/utils/companyEmail.ts
3144
- var companyEmailRules = (import.meta.env.VITE_COMPANY_EMAIL_DOMAINS || "").split(",").map((rule) => rule.trim().toLowerCase().replace(/^@/, "")).filter(Boolean);
3145
- var normalizeEmail = (email) => (email || "").trim().toLowerCase();
3146
- var getCompanyEmailRuleText = () => companyEmailRules.join("\u3001");
3147
- var isCompanyEmail = (email) => {
3148
- const normalizedEmail = normalizeEmail(email);
3149
- const domain = normalizedEmail.split("@")[1];
3150
- return companyEmailRules.some((rule) => rule.includes("@") ? rule === normalizedEmail : Boolean(domain && rule === domain));
3151
- };
3152
-
3153
- // src/utils/forbidDebugger.ts
3154
- function forbidDebugger() {
3155
- const check = function() {
3156
- function doCheck(a) {
3157
- if (("" + a / a)["length"] !== 1 || a % 20 === 0) {
3158
- ;
3159
- (function() {
3160
- })["constructor"]("debugger")();
3161
- } else {
3162
- ;
3163
- (function() {
3164
- })["constructor"]("debugger")();
3165
- }
3166
- doCheck(++a);
3167
- }
3168
- try {
3169
- doCheck(0);
3170
- } catch (err) {
3171
- ;
3172
- }
3173
- };
3174
- const checkDebuggerWindow = function() {
3175
- const thresholdW = 160;
3176
- const thresholdH = 160 + 200;
3177
- if (window.outerWidth - window.innerWidth > thresholdW || window.outerHeight - window.innerHeight > thresholdH) {
3178
- window.close();
3179
- window.location = "about:blank";
3180
- }
3181
- };
3182
- setInterval(function() {
3183
- if (!__debug) {
3184
- checkDebuggerWindow();
3185
- check();
3186
- }
3187
- }, 5e3);
3188
- if (!__debug) {
3189
- checkDebuggerWindow();
3190
- check();
3191
- window.onkeydown = window.onkeyup = window.onkeypress = function(event) {
3192
- if (event.keyCode === 123) {
3193
- event.preventDefault();
3194
- window.event.returnValue = false;
3195
- }
3196
- };
3197
- }
3198
- }
3199
-
3200
- // src/utils/formatters.ts
3201
- var initalDate = 0;
3202
- var formatDate = (date) => {
3203
- if (!date) return "\u65E0";
3204
- if (typeof date === "string") {
3205
- date = new Date(date);
3206
- }
3207
- if (date.getTime() == initalDate) {
3208
- return "\u65E0";
3209
- }
3210
- if (isNaN(date.getTime())) {
3211
- return "\u65E0";
3212
- }
3213
- return date.toLocaleDateString("zh-CN", {
3214
- year: "numeric",
3215
- month: "2-digit",
3216
- day: "numeric"
3217
- });
3218
- };
3219
- var formatDatetime = (date) => {
3220
- if (!date) return "\u65E0";
3221
- if (typeof date === "string") {
3222
- date = new Date(date);
3223
- }
3224
- if (date.getTime() == initalDate) {
3225
- return "\u65E0";
3226
- }
3227
- if (isNaN(date.getTime())) {
3228
- return "\u65E0";
3229
- }
3230
- return date.toLocaleDateString("zh-CN", {
3231
- year: "numeric",
3232
- month: "2-digit",
3233
- day: "numeric",
3234
- hour: "2-digit",
3235
- minute: "2-digit"
3236
- });
3237
- };
3238
- var formatCurrency = (amount) => {
3239
- return new Intl.NumberFormat("zh-CN", {
3240
- style: "currency",
3241
- currency: "CNY"
3242
- }).format(amount);
3243
- };
3244
- var formatDisksize = (filesize) => {
3245
- if (!filesize) return "0 KB";
3246
- filesize = filesize / 1024;
3247
- if (filesize < 1024) {
3248
- if (filesize.toFixed(1).endsWith(".0")) {
3249
- return filesize.toFixed(2) + " KB";
3250
- }
3251
- return filesize.toFixed(1) + " KB";
3252
- }
3253
- filesize = filesize / 1024;
3254
- if (filesize < 1024) {
3255
- if (filesize.toFixed(1).endsWith(".0")) {
3256
- return filesize.toFixed(2) + " MB";
3257
- }
3258
- return filesize.toFixed(1) + " MB";
3259
- }
3260
- filesize = filesize / 1024;
3261
- if (filesize.toFixed(1).endsWith(".0")) {
3262
- return filesize.toFixed(2) + " GB";
3263
- }
3264
- return filesize.toFixed(1) + " GB";
3265
- };
3266
-
3267
- // src/utils/keyboard.ts
3268
- import key from "keymaster";
3269
- var keyboard = {
3270
- /**
3271
- * @descs: 定义一个快捷键.
3272
- *
3273
- * 可以使用如下的修饰键:
3274
- * - `⇧`, `shift`
3275
- * - `option`, `⌥`, `alt`
3276
- * - `ctrl`, `control`, `command`, and `⌘`.
3277
- *
3278
- * 可以使用如下的特殊键:
3279
- * - `backspace`, `tab`, `clear`
3280
- * - `enter`, `return`
3281
- * - `esc`, `escape`, `space`,
3282
- * - `up`, `down`, `left`, `right`, `home`, `end`, `pageup`, `pagedown`, `del`, `delete`
3283
- * - `f1` through `f19`.
3284
- *
3285
- * @example
3286
- *
3287
- * keyboard.on('a', () => {});
3288
- * keyboard.on('ctrl+r', () => {});
3289
- * keyboard.on('ctrl+r, ⌘+r', () => {});
3290
- */
3291
- on: function(keyname, callback) {
3292
- key(keyname, callback);
3293
- return this;
3294
- },
3295
- /**
3296
- * 解除按键handler.
3297
- */
3298
- off: function(keyname) {
3299
- key.unbind(keyname);
3300
- return this;
3301
- },
3302
- /**
3303
- * 检查指定的按键是否按下.
3304
- *
3305
- * @example
3306
- * if (keyboard.isPressed('M')) {
3307
- * alert('M key is pressed, can ya believe it!?');
3308
- * }
3309
- * if (keyboard.isPressed(77)) {
3310
- * alert('M key is pressed, can ya believe it!?');
3311
- * }
3312
- */
3313
- isPressed(keyCode) {
3314
- return key.isPressed(keyCode);
3315
- },
3316
- /**
3317
- * 检查shift键是否按下.
3318
- */
3319
- get shift() {
3320
- return key.shift;
3321
- },
3322
- get "\u21E7"() {
3323
- return key["\u21E7"];
3324
- },
3325
- /**
3326
- * 检查alt键是否按下.
3327
- */
3328
- get alt() {
3329
- return key.alt;
3330
- },
3331
- get option() {
3332
- return key.option;
3333
- },
3334
- get "\u2325"() {
3335
- return key["\u2325"];
3336
- },
3337
- /**
3338
- * 检查control键是否按下.
3339
- */
3340
- get ctrl() {
3341
- return key.ctrl;
3342
- },
3343
- get control() {
3344
- return key.control;
3345
- },
3346
- get "\u2303"() {
3347
- return key["\u2303"];
3348
- },
3349
- /**
3350
- * 检查command键是否按下.
3351
- */
3352
- get command() {
3353
- return key.command;
3354
- },
3355
- get "\u2318"() {
3356
- return key["\u2318"];
3357
- },
3358
- /**
3359
- * 获得按下按键的keyCode列表.
3360
- */
3361
- get pressedKeyCodes() {
3362
- return key.getPressedKeyCodes();
3363
- }
3364
- };
3365
-
3366
- // src/utils/mammothApi.ts
3367
- import * as mammothModule from "mammoth";
3368
- var mammoth = mammothModule.default ?? mammothModule;
3369
-
3370
- // src/utils/polyfills.ts
3371
- (function installPromiseAllSettled() {
3372
- if (typeof Promise === "undefined") return;
3373
- if (typeof Promise.allSettled === "function") return;
3374
- const allSettledImpl = function(values) {
3375
- const items = Array.isArray(values) ? values : Array.from(values);
3376
- if (items.length === 0) return Promise.resolve([]);
3377
- return new Promise((resolve) => {
3378
- const results = new Array(items.length);
3379
- let remaining = items.length;
3380
- const done = () => {
3381
- remaining -= 1;
3382
- if (remaining === 0) resolve(results);
3383
- };
3384
- items.forEach((input, index) => {
3385
- Promise.resolve(input).then(
3386
- (value) => {
3387
- results[index] = { status: "fulfilled", value };
3388
- done();
3389
- },
3390
- (reason) => {
3391
- results[index] = { status: "rejected", reason };
3392
- done();
3393
- }
3394
- );
3395
- });
3396
- });
3397
- };
3398
- try {
3399
- Object.defineProperty(Promise, "allSettled", {
3400
- configurable: true,
3401
- writable: true,
3402
- value: allSettledImpl
3403
- });
3404
- } catch (e) {
3405
- try {
3406
- Promise.allSettled = allSettledImpl;
3407
- } catch (_) {
3408
- }
3409
- }
3410
- try {
3411
- if (typeof Promise.allSettled !== "function") {
3412
- Promise.allSettled = allSettledImpl;
3413
- }
3414
- } catch (_) {
3415
- }
3416
- })();
3417
- function ensurePromiseAllSettled() {
3418
- try {
3419
- if (typeof Promise === "undefined") return;
3420
- if (typeof Promise.allSettled === "function") return;
3421
- const impl = (values) => {
3422
- const items = Array.isArray(values) ? values : Array.from(values);
3423
- if (items.length === 0) return Promise.resolve([]);
3424
- return new Promise((resolve) => {
3425
- const results = new Array(items.length);
3426
- let remaining = items.length;
3427
- const done = () => {
3428
- if (--remaining === 0) resolve(results);
3429
- };
3430
- items.forEach((input, index) => {
3431
- Promise.resolve(input).then(
3432
- (value) => {
3433
- results[index] = { status: "fulfilled", value };
3434
- done();
3435
- },
3436
- (reason) => {
3437
- results[index] = { status: "rejected", reason };
3438
- done();
3439
- }
3440
- );
3441
- });
3442
- });
3443
- };
3444
- try {
3445
- Object.defineProperty(Promise, "allSettled", { configurable: true, writable: true, value: impl });
3446
- } catch (_) {
3447
- }
3448
- if (typeof Promise.allSettled !== "function") {
3449
- try {
3450
- Promise.allSettled = impl;
3451
- } catch (_) {
3452
- }
3453
- }
3454
- } catch (_) {
3455
- }
3456
- }
3457
- function ensureWebStreamsPolyfill() {
3458
- try {
3459
- installWebStreamsPolyfill();
3460
- } catch (_) {
3461
- }
3462
- }
3463
- var ByteLengthQueuingStrategy = class {
3464
- constructor({ highWaterMark }) {
3465
- __publicField(this, "highWaterMark");
3466
- this.highWaterMark = highWaterMark;
3467
- }
3468
- size(chunk) {
3469
- return chunk?.byteLength ?? 0;
3470
- }
3471
- };
3472
- var CountQueuingStrategy = class {
3473
- constructor({ highWaterMark }) {
3474
- __publicField(this, "highWaterMark");
3475
- this.highWaterMark = highWaterMark;
3476
- }
3477
- size() {
3478
- return 1;
3479
- }
3480
- };
3481
- var PolyfillReadableStreamDefaultController = class {
3482
- constructor(stream) {
3483
- __publicField(this, "desiredSize", 0);
3484
- __publicField(this, "byobRequest", null);
3485
- __publicField(this, "_stream");
3486
- this._stream = stream;
3487
- }
3488
- enqueue(chunk) {
3489
- this._stream._push(chunk);
3490
- }
3491
- close() {
3492
- this._stream._close();
3493
- }
3494
- error(e) {
3495
- this._stream._error(e ?? new Error("ReadableStream errored"));
3496
- }
3497
- get desiredSizeInternal() {
3498
- return this._stream._chunks ? 1 : 0;
3499
- }
3500
- };
3501
- var PolyfillReadableByteStreamController = class {
3502
- constructor(stream) {
3503
- __publicField(this, "byobRequest", null);
3504
- __publicField(this, "desiredSize", 0);
3505
- __publicField(this, "_stream");
3506
- this._stream = stream;
3507
- }
3508
- close() {
3509
- this._stream._close();
3510
- }
3511
- enqueue(chunk) {
3512
- this._stream._push(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
3513
- }
3514
- error(e) {
3515
- this._stream._error(e ?? new Error("ReadableByteStream errored"));
3516
- }
3517
- };
3518
- var PolyfillReadableStreamDefaultReader = class {
3519
- constructor(stream) {
3520
- __publicField(this, "closed");
3521
- __publicField(this, "_stream");
3522
- __publicField(this, "_resolveClosed");
3523
- this._stream = stream;
3524
- this._stream._reader = this;
3525
- this.closed = new Promise((resolve) => {
3526
- this._resolveClosed = resolve;
3527
- });
3528
- }
3529
- read() {
3530
- return this._stream._read();
3531
- }
3532
- releaseLock() {
3533
- if (this._stream._reader === this) this._stream._reader = null;
3534
- }
3535
- cancel(reason) {
3536
- return this._stream.cancel(reason);
3537
- }
3538
- _onClosed() {
3539
- this._resolveClosed(void 0);
3540
- }
3541
- };
3542
- var PolyfillReadableStreamBYOBReader = class {
3543
- constructor(stream) {
3544
- __publicField(this, "closed");
3545
- __publicField(this, "_stream");
3546
- __publicField(this, "_resolveClosed");
3547
- this._stream = stream;
3548
- this._stream._byobReader = this;
3549
- this.closed = new Promise((resolve) => {
3550
- this._resolveClosed = resolve;
3551
- });
3552
- }
3553
- read(view) {
3554
- return this._stream._readInto(view);
3555
- }
3556
- releaseLock() {
3557
- if (this._stream._byobReader === this) this._stream._byobReader = null;
3558
- }
3559
- cancel(reason) {
3560
- return this._stream.cancel(reason);
3561
- }
3562
- _onClosed() {
3563
- this._resolveClosed(void 0);
3564
- }
3565
- };
3566
- var PolyfillReadableStream = class _PolyfillReadableStream {
3567
- constructor(underlyingSource, _strategy) {
3568
- __publicField(this, "locked", false);
3569
- // 内部字段用包内可见访问
3570
- __publicField(this, "_chunks", []);
3571
- __publicField(this, "_waiting", null);
3572
- __publicField(this, "_byobWaiting", null);
3573
- __publicField(this, "_reader", null);
3574
- __publicField(this, "_byobReader", null);
3575
- __publicField(this, "_state", { closed: false, errored: false, error: void 0 });
3576
- __publicField(this, "_source", null);
3577
- __publicField(this, "_cancelCallback", null);
3578
- __publicField(this, "_controller", null);
3579
- __publicField(this, "_pulling", false);
3580
- __publicField(this, "_pullScheduled", false);
3581
- __publicField(this, "_type");
3582
- __publicField(this, "_autoAllocateChunkSize");
3583
- this._source = underlyingSource ?? null;
3584
- this._cancelCallback = underlyingSource?.cancel ?? null;
3585
- if (underlyingSource && underlyingSource.type === "bytes") {
3586
- this._type = "bytes";
3587
- this._autoAllocateChunkSize = underlyingSource.autoAllocateChunkSize;
3588
- this._controller = new PolyfillReadableByteStreamController(
3589
- this
3590
- );
3591
- } else {
3592
- this._controller = new PolyfillReadableStreamDefaultController(this);
3593
- }
3594
- const start = underlyingSource?.start;
3595
- if (typeof start === "function") {
3596
- Promise.resolve(start.call(underlyingSource, this._controller)).catch((e) => {
3597
- this._error(e);
3598
- });
3599
- }
3600
- }
3601
- getReader() {
3602
- const options = arguments[0];
3603
- if (options?.mode === "byob") {
3604
- if (this._byobReader) throw new TypeError("ReadableStream is locked");
3605
- return new PolyfillReadableStreamBYOBReader(this);
3606
- }
3607
- if (this._reader) throw new TypeError("ReadableStream is locked");
3608
- return new PolyfillReadableStreamDefaultReader(this);
3609
- }
3610
- tee() {
3611
- const left = this._branch();
3612
- const right = this._branch();
3613
- return [left, right];
3614
- }
3615
- pipeThrough(transform, options) {
3616
- void this.pipeTo(transform.writable, options);
3617
- return transform.readable;
3618
- }
3619
- async pipeTo(dest, options) {
3620
- const preventClose = !!options?.preventClose;
3621
- const preventAbort = !!options?.preventAbort;
3622
- const preventCancel = !!options?.preventCancel;
3623
- const writer = dest && typeof dest.getWriter === "function" ? dest.getWriter() : null;
3624
- try {
3625
- const reader = this.getReader();
3626
- try {
3627
- while (true) {
3628
- const { done, value } = await reader.read();
3629
- if (done) break;
3630
- if (writer && typeof writer.ready !== "undefined") await writer.ready;
3631
- if (writer && typeof writer.write === "function") {
3632
- await writer.write(value);
3633
- } else if (dest && typeof dest.write === "function") {
3634
- dest.write(value);
3635
- }
3636
- }
3637
- } finally {
3638
- try {
3639
- reader.releaseLock();
3640
- } catch {
3641
- }
3642
- }
3643
- if (!preventClose) {
3644
- if (writer && typeof writer.close === "function") await writer.close();
3645
- else if (dest && typeof dest.close === "function") dest.close();
3646
- }
3647
- } catch (error) {
3648
- if (!preventAbort) {
3649
- try {
3650
- if (writer && typeof writer.abort === "function") await writer.abort(error);
3651
- else if (dest && typeof dest.abort === "function") dest.abort(error);
3652
- } catch {
3653
- }
3654
- }
3655
- if (!preventCancel) {
3656
- try {
3657
- await this.cancel(error);
3658
- } catch {
3659
- }
3660
- }
3661
- throw error;
3662
- } finally {
3663
- if (writer && typeof writer.releaseLock === "function") {
3664
- try {
3665
- writer.releaseLock();
3666
- } catch {
3667
- }
3668
- }
3669
- }
3670
- }
3671
- async cancel(reason) {
3672
- if (this._state.closed || this._state.errored) return;
3673
- this._state.closed = true;
3674
- try {
3675
- if (this._cancelCallback) await this._cancelCallback(reason);
3676
- } finally {
3677
- this._finalizeClose();
3678
- }
3679
- }
3680
- // --- 内部接口 ----------------------------------------------------------
3681
- _branch() {
3682
- const self = this;
3683
- const out = new _PolyfillReadableStream({
3684
- start: async (controller) => {
3685
- const reader = self.getReader();
3686
- try {
3687
- while (true) {
3688
- const { done, value } = await reader.read();
3689
- if (done) break;
3690
- controller.enqueue(value);
3691
- }
3692
- controller.close();
3693
- } catch (e) {
3694
- controller.error(e);
3695
- } finally {
3696
- try {
3697
- reader.releaseLock();
3698
- } catch {
3699
- }
3700
- }
3701
- }
3702
- });
3703
- return out;
3704
- }
3705
- _push(chunk) {
3706
- if (this._state.closed || this._state.errored) return;
3707
- if (this._waiting) {
3708
- const resolve = this._waiting;
3709
- this._waiting = null;
3710
- resolve({ done: false, value: chunk });
3711
- this._schedulePullIfNeeded();
3712
- return;
3713
- }
3714
- if (this._byobWaiting) {
3715
- const resolve = this._byobWaiting;
3716
- this._byobWaiting = null;
3717
- resolve(this._buildByobResult(chunk));
3718
- this._schedulePullIfNeeded();
3719
- return;
3720
- }
3721
- this._chunks.push({ type: "chunk", value: chunk });
3722
- this._schedulePullIfNeeded();
3723
- }
3724
- _close() {
3725
- if (this._state.closed || this._state.errored) return;
3726
- this._state.closed = true;
3727
- this._chunks.push({ type: "close" });
3728
- if (this._waiting) {
3729
- const resolve = this._waiting;
3730
- this._waiting = null;
3731
- resolve({ done: true, value: void 0 });
3732
- }
3733
- this._finalizeClose();
3734
- }
3735
- _error(error) {
3736
- if (this._state.closed || this._state.errored) return;
3737
- this._state.errored = true;
3738
- this._state.error = error;
3739
- this._chunks.push({ type: "error", error });
3740
- if (this._waiting) {
3741
- const resolve = this._waiting;
3742
- this._waiting = null;
3743
- resolve(Promise.reject(error));
3744
- }
3745
- this._finalizeClose();
3746
- }
3747
- _finalizeClose() {
3748
- if (this._reader) this._reader._onClosed();
3749
- if (this._byobReader) this._byobReader._onClosed();
3750
- }
3751
- _schedulePullIfNeeded() {
3752
- if (this._pullScheduled) return;
3753
- const pull = this._source?.pull;
3754
- if (typeof pull !== "function") return;
3755
- if (this._state.closed || this._state.errored) return;
3756
- if (this._chunks.length > 0 || this._waiting || this._byobWaiting) return;
3757
- this._pullScheduled = true;
3758
- queueMicrotask(() => {
3759
- this._pullScheduled = false;
3760
- if (this._pulling) return;
3761
- if (this._state.closed || this._state.errored) return;
3762
- this._pulling = true;
3763
- Promise.resolve(pull.call(this._source, this._controller)).catch((e) => this._error(e)).finally(() => {
3764
- this._pulling = false;
3765
- });
3766
- });
3767
- }
3768
- _read() {
3769
- if (this._state.errored) return Promise.reject(this._state.error);
3770
- if (this._state.closed) return Promise.resolve({ done: true, value: void 0 });
3771
- while (this._chunks.length) {
3772
- const item = this._chunks.shift();
3773
- if (item.type === "chunk") {
3774
- this._schedulePullIfNeeded();
3775
- return Promise.resolve({ done: false, value: item.value });
3776
- }
3777
- if (item.type === "close") {
3778
- return Promise.resolve({ done: true, value: void 0 });
3779
- }
3780
- if (item.type === "error") {
3781
- return Promise.reject(item.error);
3782
- }
3783
- }
3784
- return new Promise((resolve, reject) => {
3785
- this._waiting = (value) => {
3786
- if (this._state.errored) reject(this._state.error);
3787
- else resolve(value);
3788
- };
3789
- this._schedulePullIfNeeded();
3790
- });
3791
- }
3792
- _readInto(view) {
3793
- if (this._state.errored) return Promise.reject(this._state.error);
3794
- if (this._state.closed) return Promise.resolve({ done: true, value: view });
3795
- let written = 0;
3796
- const target = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
3797
- while (this._chunks.length && written < target.byteLength) {
3798
- const item = this._chunks[0];
3799
- if (item.type === "chunk") {
3800
- const src = this._toUint8(item.value);
3801
- const toCopy = Math.min(src.length, target.byteLength - written);
3802
- target.set(src.subarray(0, toCopy), written);
3803
- written += toCopy;
3804
- if (toCopy < src.length) {
3805
- this._chunks[0].value = src.subarray(toCopy);
3806
- } else {
3807
- this._chunks.shift();
3808
- }
3809
- } else if (item.type === "close") {
3810
- this._chunks.shift();
3811
- const outView = written === 0 ? view : new DataView(view.buffer, view.byteOffset, written);
3812
- return Promise.resolve({ done: true, value: written ? outView : view });
3813
- } else if (item.type === "error") {
3814
- this._chunks.shift();
3815
- return Promise.reject(item.error);
3816
- }
3817
- }
3818
- if (written > 0) {
3819
- const newView = new DataView(view.buffer, view.byteOffset, written);
3820
- this._schedulePullIfNeeded();
3821
- return Promise.resolve({ done: false, value: newView });
3822
- }
3823
- return new Promise((resolve, reject) => {
3824
- this._byobWaiting = (res) => {
3825
- if (this._state.errored) reject(this._state.error);
3826
- else resolve(res);
3827
- };
3828
- this._schedulePullIfNeeded();
3829
- });
3830
- }
3831
- _buildByobResult(chunk) {
3832
- const src = this._toUint8(chunk);
3833
- const out = new Uint8Array(src.length);
3834
- out.set(src);
3835
- return { done: false, value: out };
3836
- }
3837
- _toUint8(chunk) {
3838
- if (chunk instanceof Uint8Array) return chunk;
3839
- if (ArrayBuffer.isView(chunk)) {
3840
- return new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
3841
- }
3842
- if (chunk instanceof ArrayBuffer) return new Uint8Array(chunk);
3843
- if (typeof chunk === "string") {
3844
- const enc = new TextEncoder();
3845
- return enc.encode(chunk);
3846
- }
3847
- if (Array.isArray(chunk)) return new Uint8Array(chunk);
3848
- return new Uint8Array(0);
3849
- }
3850
- };
3851
- var PolyfillWritableStreamDefaultWriter = class {
3852
- constructor(stream) {
3853
- __publicField(this, "closed");
3854
- __publicField(this, "ready");
3855
- __publicField(this, "desiredSize", 1);
3856
- __publicField(this, "_stream");
3857
- __publicField(this, "_resolveClosed");
3858
- __publicField(this, "_resolveReady");
3859
- this._stream = stream;
3860
- this._stream._writer = this;
3861
- this.closed = new Promise((res) => {
3862
- this._resolveClosed = res;
3863
- });
3864
- this.ready = new Promise((res) => {
3865
- this._resolveReady = res;
3866
- });
3867
- Promise.resolve().then(() => this._resolveReady(void 0));
3868
- }
3869
- abort(reason) {
3870
- return this._stream.abort(reason);
3871
- }
3872
- close() {
3873
- return this._stream.close();
3874
- }
3875
- releaseLock() {
3876
- if (this._stream._writer === this) this._stream._writer = null;
3877
- }
3878
- write(chunk) {
3879
- return this._stream.write(chunk);
3880
- }
3881
- _onClosed() {
3882
- this._resolveClosed(void 0);
3883
- }
3884
- };
3885
- var PolyfillWritableStream = class {
3886
- constructor(underlyingSink, _strategy) {
3887
- __publicField(this, "locked", false);
3888
- __publicField(this, "_writer", null);
3889
- __publicField(this, "_state", { closed: false, errored: false, error: void 0 });
3890
- __publicField(this, "_sink", {});
3891
- __publicField(this, "_controller", null);
3892
- this._sink = underlyingSink ?? {};
3893
- const start = this._sink.start;
3894
- this._controller = {
3895
- error: (e) => this._error(e ?? new Error("WritableStream errored")),
3896
- signal: { aborted: false, reason: void 0 }
3897
- };
3898
- if (typeof start === "function") {
3899
- Promise.resolve(start.call(this._sink, this._controller)).catch((e) => this._error(e));
3900
- }
3901
- }
3902
- getWriter() {
3903
- if (this._writer) throw new TypeError("WritableStream is locked");
3904
- return new PolyfillWritableStreamDefaultWriter(this);
3905
- }
3906
- async abort(reason) {
3907
- if (this._state.closed || this._state.errored) return;
3908
- this._controller.signal.aborted = true;
3909
- this._controller.signal.reason = reason;
3910
- this._state.errored = true;
3911
- this._state.error = reason;
3912
- const abort = this._sink.abort;
3913
- if (typeof abort === "function") await abort.call(this._sink, reason);
3914
- this._finalize();
3915
- }
3916
- async close() {
3917
- if (this._state.closed || this._state.errored) return;
3918
- this._state.closed = true;
3919
- const closeFn = this._sink.close;
3920
- if (typeof closeFn === "function") await closeFn.call(this._sink);
3921
- this._finalize();
3922
- }
3923
- async write(chunk) {
3924
- if (this._state.errored) throw this._state.error;
3925
- if (this._state.closed) throw new TypeError("WritableStream is closed");
3926
- const writeFn = this._sink.write;
3927
- if (typeof writeFn === "function") {
3928
- const result = writeFn.call(this._sink, chunk, this._controller);
3929
- await Promise.resolve(result);
3930
- }
3931
- }
3932
- _finalize() {
3933
- if (this._writer) this._writer._onClosed();
3934
- }
3935
- _error(e) {
3936
- if (this._state.closed || this._state.errored) return;
3937
- this._state.errored = true;
3938
- this._state.error = e;
3939
- this._finalize();
3940
- }
3941
- };
3942
- var PolyfillTransformStream = class {
3943
- constructor(transformer, _writableStrategy, _readableStrategy) {
3944
- __publicField(this, "readable");
3945
- __publicField(this, "writable");
3946
- let readableController;
3947
- this.readable = new PolyfillReadableStream({
3948
- start: (controller) => {
3949
- readableController = controller;
3950
- const startFn = transformer?.start;
3951
- if (typeof startFn === "function") {
3952
- Promise.resolve(startFn.call(transformer, readableController)).catch(
3953
- (e) => readableController.error(e)
3954
- );
3955
- }
3956
- }
3957
- });
3958
- this.writable = new PolyfillWritableStream({
3959
- write: async (chunk, _controller) => {
3960
- const fn = transformer?.transform;
3961
- if (typeof fn === "function") {
3962
- await Promise.resolve(fn.call(transformer, chunk, readableController));
3963
- } else {
3964
- readableController.enqueue(chunk);
3965
- }
3966
- },
3967
- close: async () => {
3968
- const flush = transformer?.flush;
3969
- if (typeof flush === "function") {
3970
- await Promise.resolve(flush.call(transformer, readableController));
3971
- }
3972
- readableController.close();
3973
- },
3974
- abort: async (reason) => {
3975
- readableController.error(reason);
3976
- const abort = transformer?.abort;
3977
- if (typeof abort === "function") await abort.call(transformer, reason);
3978
- }
3979
- });
3980
- }
3981
- };
3982
- var PolyfillTextDecoderStream = class {
3983
- constructor(label, options) {
3984
- __publicField(this, "readable");
3985
- __publicField(this, "writable");
3986
- __publicField(this, "encoding");
3987
- __publicField(this, "fatal");
3988
- __publicField(this, "ignoreBOM");
3989
- const decoder = new TextDecoder(label, options);
3990
- this.encoding = decoder.encoding;
3991
- this.fatal = decoder.fatal;
3992
- this.ignoreBOM = decoder.ignoreBOM;
3993
- const ts = new PolyfillTransformStream({
3994
- transform(chunk, controller) {
3995
- controller.enqueue(decoder.decode(chunk, { stream: true }));
3996
- },
3997
- flush(controller) {
3998
- const tail = decoder.decode();
3999
- if (tail) controller.enqueue(tail);
4000
- }
4001
- });
4002
- this.readable = ts.readable;
4003
- this.writable = ts.writable;
4004
- }
4005
- };
4006
- var PolyfillTextEncoderStream = class {
4007
- constructor() {
4008
- __publicField(this, "readable");
4009
- __publicField(this, "writable");
4010
- __publicField(this, "encoding", "utf-8");
4011
- const encoder = new TextEncoder();
4012
- const ts = new PolyfillTransformStream({
4013
- transform(chunk, controller) {
4014
- controller.enqueue(encoder.encode(chunk));
4015
- }
4016
- });
4017
- this.readable = ts.readable;
4018
- this.writable = ts.writable;
4019
- }
4020
- };
4021
- function forceDefineOnGlobal(key2, value) {
4022
- const glb = globalThis;
4023
- try {
4024
- Object.defineProperty(glb, key2, {
4025
- configurable: true,
4026
- writable: true,
4027
- enumerable: false,
4028
- value
4029
- });
4030
- } catch (_) {
4031
- try {
4032
- glb[key2] = value;
4033
- } catch (__) {
4034
- }
4035
- }
4036
- try {
4037
- if (glb[key2] !== value) glb[key2] = value;
4038
- } catch (_) {
4039
- }
4040
- }
4041
- function installIfMissing(key2, value) {
4042
- const glb = globalThis;
4043
- try {
4044
- if (typeof glb[key2] === "undefined") {
4045
- forceDefineOnGlobal(key2, value);
4046
- }
4047
- } catch {
4048
- }
4049
- }
4050
- function detectBrokenWebStreamsImplementation() {
4051
- try {
4052
- const RS = globalThis.ReadableStream;
4053
- const RBC = globalThis.ReadableByteStreamController;
4054
- const WS = globalThis.WritableStream;
4055
- const TS = globalThis.TransformStream;
4056
- if (typeof RS !== "function") return false;
4057
- if (typeof RBC !== "function") return true;
4058
- try {
4059
- const src = {
4060
- type: "bytes",
4061
- start(c) {
4062
- try {
4063
- c.close();
4064
- } catch (_) {
4065
- }
4066
- }
4067
- };
4068
- const tmp = new RS(src);
4069
- try {
4070
- const byob = tmp.getReader({ mode: "byob" });
4071
- if (!byob) return true;
4072
- try {
4073
- byob.releaseLock();
4074
- } catch (_) {
4075
- }
4076
- } catch (brErr) {
4077
- const msg = String(brErr?.message ?? "");
4078
- if (/not implemented|ReadableByteStreamController|byob|not supported|invalid mode/i.test(msg)) return true;
4079
- }
4080
- try {
4081
- tmp.cancel && tmp.cancel();
4082
- } catch (_) {
4083
- }
4084
- } catch (e) {
4085
- const msg = String(e?.message ?? "");
4086
- if (/ReadableByteStreamController is not implemented|is not implemented|not supported|type bytes|invalid type/i.test(msg)) return true;
4087
- }
4088
- const proto = RS.prototype;
4089
- if (!proto || typeof proto.pipeTo !== "function" || typeof proto.pipeThrough !== "function" || typeof proto.tee !== "function") {
4090
- if (typeof WS !== "function") return true;
4091
- }
4092
- if (typeof TS !== "undefined" && typeof TS !== "function") return true;
4093
- return false;
4094
- } catch (_) {
4095
- return false;
4096
- }
4097
- }
4098
- function installWebStreamsPolyfill() {
4099
- if (typeof globalThis === "undefined") return;
4100
- const needsFullOverride = detectBrokenWebStreamsImplementation();
4101
- if (needsFullOverride) {
4102
- forceDefineOnGlobal("ReadableStream", PolyfillReadableStream);
4103
- forceDefineOnGlobal("ReadableByteStreamController", PolyfillReadableByteStreamController);
4104
- forceDefineOnGlobal("ReadableStreamDefaultController", PolyfillReadableStreamDefaultController);
4105
- forceDefineOnGlobal("ReadableStreamDefaultReader", PolyfillReadableStreamDefaultReader);
4106
- forceDefineOnGlobal("ReadableStreamBYOBReader", PolyfillReadableStreamBYOBReader);
4107
- forceDefineOnGlobal("WritableStream", PolyfillWritableStream);
4108
- forceDefineOnGlobal("WritableStreamDefaultWriter", PolyfillWritableStreamDefaultWriter);
4109
- forceDefineOnGlobal("TransformStream", PolyfillTransformStream);
4110
- forceDefineOnGlobal("TextDecoderStream", PolyfillTextDecoderStream);
4111
- forceDefineOnGlobal("TextEncoderStream", PolyfillTextEncoderStream);
4112
- forceDefineOnGlobal("ByteLengthQueuingStrategy", ByteLengthQueuingStrategy);
4113
- forceDefineOnGlobal("CountQueuingStrategy", CountQueuingStrategy);
4114
- } else {
4115
- installIfMissing("ByteLengthQueuingStrategy", ByteLengthQueuingStrategy);
4116
- installIfMissing("CountQueuingStrategy", CountQueuingStrategy);
4117
- installIfMissing("ReadableStream", PolyfillReadableStream);
4118
- installIfMissing("WritableStream", PolyfillWritableStream);
4119
- installIfMissing("TransformStream", PolyfillTransformStream);
4120
- installIfMissing("ReadableByteStreamController", PolyfillReadableByteStreamController);
4121
- installIfMissing("ReadableStreamDefaultController", PolyfillReadableStreamDefaultController);
4122
- installIfMissing("ReadableStreamDefaultReader", PolyfillReadableStreamDefaultReader);
4123
- installIfMissing("ReadableStreamBYOBReader", PolyfillReadableStreamBYOBReader);
4124
- installIfMissing("WritableStreamDefaultWriter", PolyfillWritableStreamDefaultWriter);
4125
- installIfMissing("TextDecoderStream", PolyfillTextDecoderStream);
4126
- installIfMissing("TextEncoderStream", PolyfillTextEncoderStream);
4127
- }
4128
- try {
4129
- const GlbReadable = globalThis.ReadableStream;
4130
- if (typeof GlbReadable === "function") {
4131
- const proto = GlbReadable.prototype;
4132
- if (proto && typeof proto.pipeTo !== "function") {
4133
- Object.defineProperty(proto, "pipeTo", {
4134
- configurable: true,
4135
- writable: true,
4136
- value: PolyfillReadableStream.prototype.pipeTo
4137
- });
4138
- Object.defineProperty(proto, "pipeThrough", {
4139
- configurable: true,
4140
- writable: true,
4141
- value: PolyfillReadableStream.prototype.pipeThrough
4142
- });
4143
- Object.defineProperty(proto, "tee", {
4144
- configurable: true,
4145
- writable: true,
4146
- value: PolyfillReadableStream.prototype.tee
4147
- });
4148
- }
4149
- }
4150
- } catch {
4151
- }
4152
- }
4153
- try {
4154
- installWebStreamsPolyfill();
4155
- } catch (e) {
4156
- console.warn("[polyfills] \u5B89\u88C5 Web Streams polyfill \u5931\u8D25\uFF1A", e);
4157
- }
4158
-
4159
- // src/utils/regex.ts
4160
- var regexCurrency = /^(0|[1-9](\d+)?(\.\d\d?)?)$/;
4161
-
4162
- // src/utils/workerBootstrap.ts
4163
- var POLYFILLS_URL = (typeof window !== "undefined" ? window.location.origin : "") + "/polyfills/polyfills.js";
4164
- var wrappedUrlCache = /* @__PURE__ */ new Map();
4165
- var wrappedModuleUrlCache = /* @__PURE__ */ new Map();
4166
- function resolveAbsoluteUrl(url) {
4167
- if (/^https?:\/\//i.test(url) || url.startsWith("blob:")) {
4168
- return url;
4169
- }
4170
- const origin = typeof window !== "undefined" ? window.location.origin : "";
4171
- if (url.startsWith("/")) {
4172
- return origin + url;
4173
- }
4174
- return origin + "/" + url;
4175
- }
4176
- function withPolyfillWorkerBootstrap(realWorkerUrl) {
4177
- const cached = wrappedUrlCache.get(realWorkerUrl);
4178
- if (cached) return cached;
4179
- const absoluteRealWorkerUrl = resolveAbsoluteUrl(realWorkerUrl);
4180
- const bootstrapSource = `/* auto-generated bootstrap: polyfills first, then real worker (${absoluteRealWorkerUrl}) */
4181
- try { self.importScripts(${JSON.stringify(POLYFILLS_URL)}); } catch (e) { console.error('[worker-bootstrap] polyfills load failed:', e); }
4182
- self.importScripts(${JSON.stringify(absoluteRealWorkerUrl)});
4183
- `;
4184
- const blob = new Blob([bootstrapSource], { type: "text/javascript" });
4185
- const objectUrl = URL.createObjectURL(blob);
4186
- wrappedUrlCache.set(realWorkerUrl, objectUrl);
4187
- return objectUrl;
4188
- }
4189
- function withPolyfillModuleWorkerBootstrap(realWorkerUrl) {
4190
- const cached = wrappedModuleUrlCache.get(realWorkerUrl);
4191
- if (cached) return cached;
4192
- const absoluteRealWorkerUrl = resolveAbsoluteUrl(realWorkerUrl);
4193
- const bootstrapSource = `/* auto-generated module bootstrap: polyfills first, then real worker (${absoluteRealWorkerUrl}) */
4194
- import ${JSON.stringify(POLYFILLS_URL)};
4195
- import ${JSON.stringify(absoluteRealWorkerUrl)};
4196
- `;
4197
- const blob = new Blob([bootstrapSource], { type: "text/javascript" });
4198
- const objectUrl = URL.createObjectURL(blob);
4199
- wrappedModuleUrlCache.set(realWorkerUrl, objectUrl);
4200
- return objectUrl;
4201
- }
4202
-
4203
- // src/utils/htmlUtils.tsx
4204
- import { useEffect as useEffect2, useRef as useRef2 } from "react";
4205
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
4206
- function htmlNoData() {
4207
- return /* @__PURE__ */ jsxs2("div", { className: "ant-empty ant-empty-normal justify-self-center text-muted py-4", children: [
4208
- /* @__PURE__ */ jsx3("div", { className: "ant-empty-image", children: /* @__PURE__ */ jsxs2("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: [
4209
- /* @__PURE__ */ jsx3("title", { children: " \u65E0\u6570\u636E " }),
4210
- /* @__PURE__ */ jsxs2("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [
4211
- /* @__PURE__ */ jsx3("ellipse", { fill: "rgb(var(--color-muted) / 0.12)", cx: "32", cy: "33", rx: "32", ry: "7" }),
4212
- /* @__PURE__ */ jsxs2("g", { fillRule: "nonzero", stroke: "rgb(var(--color-border))", children: [
4213
- /* @__PURE__ */ jsx3("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }),
4214
- /* @__PURE__ */ jsx3("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "rgb(var(--color-surface))" })
4215
- ] })
4216
- ] })
4217
- ] }) }),
4218
- /* @__PURE__ */ jsx3("div", { className: "ant-empty-description justify-self-center text-sm font-thin text-muted", children: " \u65E0\u6570\u636E " })
4219
- ] });
4220
- }
4221
- function useEffectResize(onSmallView, onLargeView, smallViewWidth = 768) {
4222
- const onSmallViewRef = useRef2(onSmallView);
4223
- const onLargeViewRef = useRef2(onLargeView);
4224
- onSmallViewRef.current = onSmallView;
4225
- onLargeViewRef.current = onLargeView;
4226
- useEffect2(() => {
4227
- let isSmallView = window.innerWidth <= smallViewWidth;
4228
- const handleResize = () => {
4229
- const newIsSmallView = window.innerWidth <= smallViewWidth;
4230
- if (newIsSmallView === isSmallView) {
4231
- return;
4232
- }
4233
- isSmallView = newIsSmallView;
4234
- if (newIsSmallView) {
4235
- onSmallViewRef.current();
4236
- } else {
4237
- onLargeViewRef.current();
4238
- }
4239
- };
4240
- if (isSmallView) {
4241
- onSmallViewRef.current();
4242
- } else {
4243
- onLargeViewRef.current();
4244
- }
4245
- window.addEventListener("resize", handleResize);
4246
- return () => window.removeEventListener("resize", handleResize);
4247
- }, [smallViewWidth]);
4248
- }
4249
- export {
4250
- APPROVAL_BIZ_LABELS,
4251
- CRM_BIZ_LABELS,
4252
- CacheDepartmentInfo,
4253
- CacheFileContent,
4254
- CacheFileMeta,
4255
- CachePermissionInfo,
4256
- CacheRoleInfo,
4257
- CacheUserInfo,
4258
- CacheViewToggleInfo,
4259
- KNOWLEDGE_BIZ_LABELS,
4260
- MESSAGE_TYPE_LABELS,
4261
- MessageContentUtils,
4262
- PERMISSION_CRM_CREATE,
4263
- PERMISSION_CRM_DELETE,
4264
- PERMISSION_CRM_MANAGE_FILE,
4265
- PERMISSION_CRM_TRANSFER,
4266
- PERMISSION_CRM_UPDATE,
4267
- PERMISSION_CRM_VIEW_CONTACT,
4268
- PERMISSION_CRM_VIEW_FILE,
4269
- PERMISSION_FOLDER_DOWNLOAD,
4270
- PERMISSION_INVOICE_LIST,
4271
- PROJECT_BIZ_LABELS,
4272
- TODO_BIZ_LABELS,
4273
- clearAllViewModeCache,
4274
- clearViewModeCache,
4275
- copyToClipboard,
4276
- ensurePromiseAllSettled,
4277
- ensureWebStreamsPolyfill,
4278
- forbidDebugger,
4279
- formatCurrency,
4280
- formatDate,
4281
- formatDatetime,
4282
- formatDisksize,
4283
- getCompanyEmailRuleText,
4284
- getViewMode,
4285
- htmlNoData,
4286
- installWebStreamsPolyfill,
4287
- isCompanyEmail,
4288
- keyboard,
4289
- mammoth,
4290
- regexCurrency,
4291
- setViewMode,
4292
- storage,
4293
- useEffectResize,
4294
- withPolyfillModuleWorkerBootstrap,
4295
- withPolyfillWorkerBootstrap
4296
- };