@chenghongyu/xpt-file-viewer 1.1.0

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 (274) hide show
  1. package/.vscode/extensions.json +3 -0
  2. package/README.md +5 -0
  3. package/auto-imports.d.ts +12 -0
  4. package/components.d.ts +45 -0
  5. package/dist.zip +0 -0
  6. package/index.html +13 -0
  7. package/package.json +100 -0
  8. package/presets/eslint/.eslintrc-auto-import.json +462 -0
  9. package/presets/plugins/html.ts +14 -0
  10. package/presets/shared/env.ts +46 -0
  11. package/presets/shared/resolvers.ts +29 -0
  12. package/presets/tov.ts +132 -0
  13. package/presets/types/auto-imports.d.ts +806 -0
  14. package/presets/types/components.d.ts +164 -0
  15. package/presets/types/env.d.ts +17 -0
  16. package/public/favicon.svg +1 -0
  17. package/public/icons.svg +24 -0
  18. package/public/testfile/README.md +5 -0
  19. package/public/testfile/useFileContextMenu.js +74 -0
  20. package/public/testfile//345/217/221/347/245/250.pdf +0 -0
  21. package/public/testfile//346/216/245/346/224/266/345/207/275.docx +0 -0
  22. package/public/testfile//350/247/204/346/240/274/345/236/213/345/217/2671.txt +263 -0
  23. package/public/testfile//350/247/206/351/242/2211.mp4 +0 -0
  24. package/public/testfile//351/237/263/351/242/2211.mp3 +0 -0
  25. package/src/App.vue +8 -0
  26. package/src/api/admin/admin-2fa.js +18 -0
  27. package/src/api/admin/admin-download-log.js +37 -0
  28. package/src/api/admin/admin-login-log.js +9 -0
  29. package/src/api/admin/admin-permission.js +9 -0
  30. package/src/api/admin/admin-setting.js +121 -0
  31. package/src/api/admin/admin-share.js +20 -0
  32. package/src/api/admin/admin-short-link.js +49 -0
  33. package/src/api/admin/admin-sso.js +38 -0
  34. package/src/api/admin/admin-storage.js +189 -0
  35. package/src/api/admin/admin-user.js +61 -0
  36. package/src/api/home/common.js +9 -0
  37. package/src/api/home/file-operator.js +89 -0
  38. package/src/api/home/home.js +87 -0
  39. package/src/api/home/install.js +18 -0
  40. package/src/api/home/login.js +9 -0
  41. package/src/api/home/only-office.js +10 -0
  42. package/src/api/home/share.js +115 -0
  43. package/src/api/home/user.js +74 -0
  44. package/src/api/tools/tools-115.js +17 -0
  45. package/src/api/tools/tools-gd.js +13 -0
  46. package/src/api/tools/tools-s3.js +25 -0
  47. package/src/api/tools/tools-sharepoint.js +19 -0
  48. package/src/assets/hero.png +0 -0
  49. package/src/assets/icons/401.svg +1 -0
  50. package/src/assets/icons/403.svg +45 -0
  51. package/src/assets/icons/404.svg +1 -0
  52. package/src/assets/icons/500.svg +1 -0
  53. package/src/assets/icons/admin-login.svg +1 -0
  54. package/src/assets/icons/document.svg +1 -0
  55. package/src/assets/icons/empty.svg +145 -0
  56. package/src/assets/icons/file-type-apk.svg +1 -0
  57. package/src/assets/icons/file-type-archive.svg +1 -0
  58. package/src/assets/icons/file-type-audio.svg +1 -0
  59. package/src/assets/icons/file-type-back.svg +1 -0
  60. package/src/assets/icons/file-type-css.svg +1 -0
  61. package/src/assets/icons/file-type-deb.svg +1 -0
  62. package/src/assets/icons/file-type-dll.svg +1 -0
  63. package/src/assets/icons/file-type-doc.svg +1 -0
  64. package/src/assets/icons/file-type-document.svg +1 -0
  65. package/src/assets/icons/file-type-docx.svg +1 -0
  66. package/src/assets/icons/file-type-exe.svg +1 -0
  67. package/src/assets/icons/file-type-expression.svg +1 -0
  68. package/src/assets/icons/file-type-file.svg +1 -0
  69. package/src/assets/icons/file-type-folder.svg +1 -0
  70. package/src/assets/icons/file-type-html.svg +1 -0
  71. package/src/assets/icons/file-type-image.svg +1 -0
  72. package/src/assets/icons/file-type-java.svg +1 -0
  73. package/src/assets/icons/file-type-js.svg +1 -0
  74. package/src/assets/icons/file-type-less.svg +1 -0
  75. package/src/assets/icons/file-type-md.svg +1 -0
  76. package/src/assets/icons/file-type-office.svg +1 -0
  77. package/src/assets/icons/file-type-pdf.svg +1 -0
  78. package/src/assets/icons/file-type-php.svg +1 -0
  79. package/src/assets/icons/file-type-ppt.svg +1 -0
  80. package/src/assets/icons/file-type-pptx.svg +1 -0
  81. package/src/assets/icons/file-type-py.svg +1 -0
  82. package/src/assets/icons/file-type-rb.svg +1 -0
  83. package/src/assets/icons/file-type-root.svg +1 -0
  84. package/src/assets/icons/file-type-rpm.svg +1 -0
  85. package/src/assets/icons/file-type-rust.svg +1 -0
  86. package/src/assets/icons/file-type-script.svg +1 -0
  87. package/src/assets/icons/file-type-text.svg +1 -0
  88. package/src/assets/icons/file-type-three3d.svg +5 -0
  89. package/src/assets/icons/file-type-vbs.svg +1 -0
  90. package/src/assets/icons/file-type-video.svg +1 -0
  91. package/src/assets/icons/file-type-xls.svg +1 -0
  92. package/src/assets/icons/file-type-xlsx.svg +1 -0
  93. package/src/assets/icons/file-type-xml.svg +1 -0
  94. package/src/assets/icons/file-type-yaml.svg +1 -0
  95. package/src/assets/icons/file-upload.svg +1 -0
  96. package/src/assets/icons/github.svg +1 -0
  97. package/src/assets/icons/install-step.svg +40 -0
  98. package/src/assets/icons/reset-password.svg +1 -0
  99. package/src/assets/icons/storage-aliyun.svg +1 -0
  100. package/src/assets/icons/storage-baidu.svg +1 -0
  101. package/src/assets/icons/storage-doge-cloud.svg +207 -0
  102. package/src/assets/icons/storage-ftp.svg +13 -0
  103. package/src/assets/icons/storage-google-drive.svg +8 -0
  104. package/src/assets/icons/storage-huawei.svg +1 -0
  105. package/src/assets/icons/storage-local.svg +11 -0
  106. package/src/assets/icons/storage-minio.svg +1 -0
  107. package/src/assets/icons/storage-onedrive-china.svg +18 -0
  108. package/src/assets/icons/storage-onedrive.svg +4 -0
  109. package/src/assets/icons/storage-open115.svg +23 -0
  110. package/src/assets/icons/storage-qiniu.svg +1 -0
  111. package/src/assets/icons/storage-s3.svg +5 -0
  112. package/src/assets/icons/storage-sftp.svg +13 -0
  113. package/src/assets/icons/storage-sharepoint-china.svg +23 -0
  114. package/src/assets/icons/storage-sharepoint.svg +1 -0
  115. package/src/assets/icons/storage-tencent.svg +9 -0
  116. package/src/assets/icons/storage-ufile.svg +14 -0
  117. package/src/assets/icons/storage-upyun.svg +1 -0
  118. package/src/assets/icons/storage-webdav.svg +1 -0
  119. package/src/assets/icons/upload.svg +50 -0
  120. package/src/assets/icons/zfile-basic.svg +17 -0
  121. package/src/assets/icons/zfile-horizontal.svg +16 -0
  122. package/src/assets/icons/zfile.svg +1 -0
  123. package/src/assets/vite.svg +1 -0
  124. package/src/assets/vue.svg +1 -0
  125. package/src/components/HelloWorld.vue +319 -0
  126. package/src/components/common/QrCodePreview.vue +118 -0
  127. package/src/components/common/dialog/ZDialog.vue +171 -0
  128. package/src/components/common/dialog/types.ts +19 -0
  129. package/src/components/common/dialog/useDialog.ts +18 -0
  130. package/src/components/common/dialog/useDialogWithForm.ts +21 -0
  131. package/src/components/copy.vue +133 -0
  132. package/src/components/file/preview/AudioPlayer.vue +333 -0
  133. package/src/components/file/preview/CopyCode.vue +47 -0
  134. package/src/components/file/preview/FileGallery.vue +199 -0
  135. package/src/components/file/preview/ImageViewer.vue +432 -0
  136. package/src/components/file/preview/KkFileViewer.vue +86 -0
  137. package/src/components/file/preview/KkFileViewerDialog.vue +42 -0
  138. package/src/components/file/preview/MarkdownViewer.vue +102 -0
  139. package/src/components/file/preview/MarkdownViewerAsyncLoading.vue +17 -0
  140. package/src/components/file/preview/MarkdownViewerDialogAsyncLoading.vue +12 -0
  141. package/src/components/file/preview/OfficeViewer.vue +76 -0
  142. package/src/components/file/preview/OfficeViewerDialog.vue +55 -0
  143. package/src/components/file/preview/PdfViewer.vue +157 -0
  144. package/src/components/file/preview/PdfViewerDialog.vue +41 -0
  145. package/src/components/file/preview/TextViewer.vue +232 -0
  146. package/src/components/file/preview/TextViewerAsyncLoading.vue +22 -0
  147. package/src/components/file/preview/TextViewerDialog.vue +53 -0
  148. package/src/components/file/preview/Three3dPreview.vue +114 -0
  149. package/src/components/file/preview/Three3dPreviewDialog.vue +50 -0
  150. package/src/components/file/preview/VideoPlayer.vue +341 -0
  151. package/src/components/file/preview/VideoPlayerAsyncLoading.vue +45 -0
  152. package/src/components/file/preview/VideoPlayerDialog.vue +51 -0
  153. package/src/components/file/selectFolder/SelectFolder.vue +208 -0
  154. package/src/components/file/selectFolder/index.ts +50 -0
  155. package/src/components/file/selectFolder/types.ts +5 -0
  156. package/src/components/fileReview/AudioPlayer-copy.vue +333 -0
  157. package/src/components/fileReview/PdfViewer-copy.vue +157 -0
  158. package/src/components/fileReview/TextViewer-copy.vue +44 -0
  159. package/src/components/fileReview/VideoPlayer-copy.vue +341 -0
  160. package/src/components/messageBox/confirm/confirm.vue +137 -0
  161. package/src/components/messageBox/confirm/index.ts +27 -0
  162. package/src/components/messageBox/confirm/types.ts +15 -0
  163. package/src/components/messageBox/messageBox.ts +9 -0
  164. package/src/components/messageBox/prompt/index.ts +27 -0
  165. package/src/components/messageBox/prompt/prompt.vue +178 -0
  166. package/src/components/messageBox/prompt/types.ts +24 -0
  167. package/src/components/vue-codemirror/editor.vue +212 -0
  168. package/src/components/vue-codemirror/encodings.ts +27 -0
  169. package/src/components/vue-codemirror/index.vue +380 -0
  170. package/src/components/vue-codemirror/lang-code/cpp/index.ts +3 -0
  171. package/src/components/vue-codemirror/lang-code/css/index.ts +2 -0
  172. package/src/components/vue-codemirror/lang-code/dockerfile/index.ts +5 -0
  173. package/src/components/vue-codemirror/lang-code/erlang/index.ts +6 -0
  174. package/src/components/vue-codemirror/lang-code/go/index.ts +5 -0
  175. package/src/components/vue-codemirror/lang-code/html/index.ts +3 -0
  176. package/src/components/vue-codemirror/lang-code/java/index.ts +3 -0
  177. package/src/components/vue-codemirror/lang-code/javascript/index.ts +3 -0
  178. package/src/components/vue-codemirror/lang-code/json/index.ts +3 -0
  179. package/src/components/vue-codemirror/lang-code/jsx/index.ts +3 -0
  180. package/src/components/vue-codemirror/lang-code/lua/index.ts +6 -0
  181. package/src/components/vue-codemirror/lang-code/markdown/index.ts +2 -0
  182. package/src/components/vue-codemirror/lang-code/mysql/index.ts +3 -0
  183. package/src/components/vue-codemirror/lang-code/nginx/index.ts +6 -0
  184. package/src/components/vue-codemirror/lang-code/perl/index.ts +5 -0
  185. package/src/components/vue-codemirror/lang-code/pgsql/index.ts +2 -0
  186. package/src/components/vue-codemirror/lang-code/php/index.ts +3 -0
  187. package/src/components/vue-codemirror/lang-code/powershell/index.ts +3 -0
  188. package/src/components/vue-codemirror/lang-code/python/index.ts +2 -0
  189. package/src/components/vue-codemirror/lang-code/r/index.ts +5 -0
  190. package/src/components/vue-codemirror/lang-code/ruby/index.ts +5 -0
  191. package/src/components/vue-codemirror/lang-code/rust/index.ts +2 -0
  192. package/src/components/vue-codemirror/lang-code/shell/index.ts +5 -0
  193. package/src/components/vue-codemirror/lang-code/sql/index.ts +3 -0
  194. package/src/components/vue-codemirror/lang-code/stylus/index.ts +3 -0
  195. package/src/components/vue-codemirror/lang-code/swift/index.ts +4 -0
  196. package/src/components/vue-codemirror/lang-code/toml/index.ts +3 -0
  197. package/src/components/vue-codemirror/lang-code/tsx/index.ts +2 -0
  198. package/src/components/vue-codemirror/lang-code/typescript/index.ts +2 -0
  199. package/src/components/vue-codemirror/lang-code/vb/index.ts +3 -0
  200. package/src/components/vue-codemirror/lang-code/vbscript/index.ts +3 -0
  201. package/src/components/vue-codemirror/lang-code/xml/index.ts +2 -0
  202. package/src/components/vue-codemirror/lang-code/yaml/index.ts +3 -0
  203. package/src/components/vue-codemirror/languages.ts +8 -0
  204. package/src/components/vue-codemirror/themes.ts +5 -0
  205. package/src/components/vue-codemirror/toolbar.vue +183 -0
  206. package/src/components/vue-codemirror/types.ts +12 -0
  207. package/src/components.d.ts +49 -0
  208. package/src/composables/admin/layout/admin-layout.js +53 -0
  209. package/src/composables/admin/link/useLinkSetting.js +16 -0
  210. package/src/composables/admin/sso/baseSsoConfig.js +54 -0
  211. package/src/composables/admin/sso/useSsoConfig.js +176 -0
  212. package/src/composables/admin/storage/storage-copy.js +89 -0
  213. package/src/composables/admin/storage/storage-filter.js +64 -0
  214. package/src/composables/admin/storage/storage-list.js +202 -0
  215. package/src/composables/admin/storage/storage-password.js +101 -0
  216. package/src/composables/admin/storage/storage-readme.js +102 -0
  217. package/src/composables/admin/storage/utils/open115-util.js +61 -0
  218. package/src/composables/admin/useAdminSetting.js +60 -0
  219. package/src/composables/admin/useClientInfo.js +20 -0
  220. package/src/composables/admin/user/user-copy.js +79 -0
  221. package/src/composables/file/useBatchOperatorResult.js +19 -0
  222. package/src/composables/file/useFileContextMenu.js +74 -0
  223. package/src/composables/file/useFileData.js +243 -0
  224. package/src/composables/file/useFileLink.js +175 -0
  225. package/src/composables/file/useFileLoading.js +41 -0
  226. package/src/composables/file/useFileLongPressEvent.js +71 -0
  227. package/src/composables/file/useFileOperator.js +347 -0
  228. package/src/composables/file/useFilePreview.js +99 -0
  229. package/src/composables/file/useFilePwd.js +138 -0
  230. package/src/composables/file/useFileSelect.js +105 -0
  231. package/src/composables/file/useFileShare.js +39 -0
  232. package/src/composables/file/useFileUpload.js +1045 -0
  233. package/src/composables/file/useKkFileViewDialog.js +24 -0
  234. package/src/composables/file/useOfficeViewerDialog.js +20 -0
  235. package/src/composables/file/usePdfViewerDialog.js +22 -0
  236. package/src/composables/file/useShareActions.js +94 -0
  237. package/src/composables/file/useShareTableOperator.js +84 -0
  238. package/src/composables/file/useTableOperator.js +211 -0
  239. package/src/composables/file/useTextViewerDialog.js +22 -0
  240. package/src/composables/file/useThree3dPreviewDialog.js +23 -0
  241. package/src/composables/file/useVideoPlayerDialog.js +19 -0
  242. package/src/composables/header/useHeaderBreadcrumb.js +111 -0
  243. package/src/composables/header/useHeaderStorageList.js +150 -0
  244. package/src/composables/header/useSetting.js +58 -0
  245. package/src/composables/share/useShareData.js +178 -0
  246. package/src/composables/useDarks.ts +4 -0
  247. package/src/composables/useRouterData.js +41 -0
  248. package/src/constant/index.js +193 -0
  249. package/src/http/index.js +153 -0
  250. package/src/http/request.js +31 -0
  251. package/src/main.ts +23 -0
  252. package/src/stores/file-data.ts +108 -0
  253. package/src/stores/global-config.ts +115 -0
  254. package/src/stores/storage-config.ts +123 -0
  255. package/src/style.css +296 -0
  256. package/src/styles/admin.scss +91 -0
  257. package/src/styles/code-editor-variables.scss +52 -0
  258. package/src/styles/element-plus.scss +22 -0
  259. package/src/styles/error-page.css +26 -0
  260. package/src/styles/main.css +142 -0
  261. package/src/styles/tailwind/index.scss +33 -0
  262. package/src/utils/index.ts +7 -0
  263. package/src/utils/models/base.ts +34 -0
  264. package/src/utils/models/file.ts +95 -0
  265. package/src/utils/models/path.ts +117 -0
  266. package/src/utils/models/qrcode.ts +21 -0
  267. package/src/utils/models/time.ts +132 -0
  268. package/src/utils/models/util.ts +42 -0
  269. package/src/utils/models/window.ts +14 -0
  270. package/stats.html +4950 -0
  271. package/tsconfig.app.json +16 -0
  272. package/tsconfig.json +7 -0
  273. package/tsconfig.node.json +26 -0
  274. package/vite.config.ts +57 -0
@@ -0,0 +1,333 @@
1
+ <template>
2
+ <div class="audio-player-container">
3
+ <div id="aplayer" ref="playerRef"></div>
4
+ </div>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue'
9
+ import APlayer from "aplayer"
10
+ import "aplayer/dist/APlayer.min.css"
11
+ import { ElMessage } from 'element-plus'
12
+
13
+ // 组件接收的属性
14
+ const props = defineProps({
15
+ // 单个音频文件URL
16
+ fileUrl: {
17
+ type: String,
18
+ default: ''
19
+ },
20
+ // 单个音频文件名
21
+ fileName: {
22
+ type: String,
23
+ default: ''
24
+ },
25
+ // 音频列表(可选)
26
+ audioList: {
27
+ type: Array,
28
+ default: () => []
29
+ },
30
+ // 默认播放索引
31
+ defaultIndex: {
32
+ type: Number,
33
+ default: 0
34
+ },
35
+ // 是否自动播放
36
+ autoPlay: {
37
+ type: Boolean,
38
+ default: true // ❌ 改为 false,避免浏览器阻止自动播放
39
+ },
40
+ // 是否固定底部
41
+ fixed: {
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ // 是否显示播放列表
46
+ showList: {
47
+ type: Boolean,
48
+ default: true
49
+ }
50
+ })
51
+
52
+ // 发射事件
53
+ const emit = defineEmits(['play', 'pause', 'ended', 'error', 'switch'])
54
+
55
+ // 响应式数据
56
+ const playerRef = ref(null)
57
+ let ap = null
58
+
59
+ // 格式化单个音频文件
60
+ const formatSingleAudio = (url, name) => {
61
+ return {
62
+ name: name || '未知音频',
63
+ artist: '未知艺术家',
64
+ url: url,
65
+ cover: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF8WlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDUgNzkuMTYzNDk5LCAyMDE4LzA4LzEzLTE2OjQwOjIyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIiB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOnBob3Rvc2hvcD0iaHR0cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOSAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE5LTAzLTIxVDE1OjE3OjQ0KzA4OjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDE5LTAzLTIxVDE1OjE3OjQ0KzA4OjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0wMy0yMVQxNToxNzo0NCswODowMCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0NzQ3NjEwNy0xNGQ1LTA1NGYtYjQxNy1mNjYwNzE5MjU5NzQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NDc0NzYxMDctMTRkNS0wNTRmLWI0MTctZjY2MDcxOTI1OTc0IiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6NDc0NzYxMDctMTRkNS0wNTRmLWI0MTctZjY2MDcxOTI1OTc0IiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyI+IDx4bXBNTTpIaXN0b3J5PiA8cmRmOlNlcT4gPHJkZjpsaSBzdEV2dDphY3Rpb249ImNyZWF0ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NDc0NzYxMDctMTRkNS0wNTRmLWI0MTctZjY2MDcxOTI1OTc0IiBzdEV2dDp3aGVuPSIyMDE5LTAzLTIxVDE1OjE3OjQ0KzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOSAoV2luZG93cykiLz4gPC9yZGY6U2VxPiA8L3htcE1NOkhpc3Rvcnk+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+'
66
+ }
67
+ }
68
+
69
+ // 获取音频列表
70
+ const getAudioList = () => {
71
+ if (props.audioList && props.audioList.length > 0) {
72
+ return props.audioList.map(item => ({
73
+ name: item.name || item.fileName || '未知音频',
74
+ artist: item.artist || '未知艺术家',
75
+ url: item.url || item.fileUrl || item.path,
76
+ cover: item.cover || formatSingleAudio().cover
77
+ }))
78
+ }
79
+
80
+ if (props.fileUrl) {
81
+ return [formatSingleAudio(props.fileUrl, props.fileName)]
82
+ }
83
+
84
+ return []
85
+ }
86
+
87
+ // 初始化音频播放器
88
+ const initAudioPlayer = async () => {
89
+ const audioList = getAudioList()
90
+
91
+ if (!audioList || audioList.length === 0) {
92
+ console.warn('音频列表为空')
93
+ return
94
+ }
95
+
96
+ // 确保索引有效
97
+ let index = props.defaultIndex
98
+ if (index < 0 || index >= audioList.length) {
99
+ index = 0
100
+ }
101
+
102
+ // 销毁旧实例
103
+ if (ap) {
104
+ ap.destroy()
105
+ ap = null
106
+ }
107
+
108
+ // 等待 DOM 渲染完成
109
+ await nextTick()
110
+
111
+ if (!playerRef.value) {
112
+ console.error('播放器容器未找到')
113
+ return
114
+ }
115
+
116
+ // 清空容器
117
+ playerRef.value.innerHTML = ''
118
+
119
+ try {
120
+ ap = new APlayer({
121
+ container: playerRef.value,
122
+ audio: audioList,
123
+ fixed: props.fixed,
124
+ autoplay: false, // ❌ 关闭自动播放,防止浏览器拦截
125
+ preload: 'metadata',
126
+ theme: '#23ade5',
127
+ loop: 'all',
128
+ order: 'list',
129
+ volume: 0.7,
130
+ mutex: true,
131
+ listFolded: !props.showList,
132
+ })
133
+
134
+ // 绑定事件
135
+ ap.on('play', () => {
136
+ emit('play', getCurrentAudio())
137
+ })
138
+
139
+ ap.on('pause', () => {
140
+ emit('pause', getCurrentAudio())
141
+ })
142
+
143
+ ap.on('ended', () => {
144
+ emit('ended', getCurrentAudio())
145
+ })
146
+
147
+ ap.on('error', (error) => {
148
+ emit('error', error)
149
+ // ElMessage.error('音频加载失败,请检查文件路径或格式')
150
+ })
151
+
152
+ ap.on('listswitch', () => {
153
+ emit('switch', getCurrentAudio())
154
+ })
155
+
156
+ // 切换到指定索引并播放(需手动触发)
157
+ if (index >= 0 && index < audioList.length) {
158
+ ap.list.switch(index)
159
+ if (props.autoPlay) {
160
+ ap.play() // ⚠️ 注意:即使设置了 autoPlay=false,这里仍可调用 play()
161
+ }
162
+ }
163
+
164
+ } catch (error) {
165
+ console.error('APlayer初始化失败:', error)
166
+ ElMessage.error('播放器初始化失败')
167
+ }
168
+ }
169
+
170
+ // 获取当前播放的音频信息
171
+ const getCurrentAudio = () => {
172
+ if (ap && ap.list && ap.list.audios) {
173
+ return ap.list.audios[ap.list.index]
174
+ }
175
+ return null
176
+ }
177
+
178
+ // 播放
179
+ const play = () => {
180
+ if (ap) {
181
+ ap.play()
182
+ }
183
+ }
184
+
185
+ // 暂停
186
+ const pause = () => {
187
+ if (ap) {
188
+ ap.pause()
189
+ }
190
+ }
191
+
192
+ // 切换歌曲
193
+ const switchAudio = (index) => {
194
+ if (ap && index >= 0 && index < getAudioList().length) {
195
+ ap.list.switch(index)
196
+ ap.play()
197
+ }
198
+ }
199
+
200
+ // 销毁播放器
201
+ const destroy = () => {
202
+ if (ap) {
203
+ ap.destroy()
204
+ ap = null
205
+ }
206
+ }
207
+
208
+ // 监听文件URL变化
209
+ watch(() => [props.fileUrl, props.fileName], async () => {
210
+ if (props.fileUrl) {
211
+ await initAudioPlayer()
212
+ }
213
+ }, { immediate: true })
214
+
215
+ // 监听音频列表变化
216
+ watch(() => props.audioList, async (newList) => {
217
+ if (newList && newList.length > 0) {
218
+ await initAudioPlayer()
219
+ }
220
+ }, { deep: true })
221
+
222
+ // 监听默认索引变化
223
+ watch(() => props.defaultIndex, (newIndex) => {
224
+ if (ap && newIndex >= 0 && newIndex < getAudioList().length) {
225
+ ap.list.switch(newIndex)
226
+ if (props.autoPlay) {
227
+ ap.play()
228
+ }
229
+ }
230
+ })
231
+
232
+ // 生命周期
233
+ onMounted(async () => {
234
+ await nextTick()
235
+ if (props.fileUrl || (props.audioList && props.audioList.length > 0)) {
236
+ await initAudioPlayer()
237
+ }
238
+ })
239
+
240
+ onUnmounted(() => {
241
+ destroy()
242
+ })
243
+
244
+ // 暴露方法给父组件
245
+ defineExpose({
246
+ play,
247
+ pause,
248
+ switchAudio,
249
+ destroy,
250
+ getCurrentAudio
251
+ })
252
+ </script>
253
+
254
+ <style scoped lang="scss">
255
+ .audio-player-container {
256
+ width: 100%;
257
+ background-color: #f5f5f5;
258
+ border-radius: 8px;
259
+
260
+ :deep(.aplayer) {
261
+ background: #fff;
262
+ border-radius: 8px;
263
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
264
+
265
+ .aplayer-body {
266
+ background-color: #fff;
267
+ }
268
+
269
+ .aplayer-info {
270
+ border-top: 1px solid #e0e0e0;
271
+
272
+ .aplayer-music {
273
+ .aplayer-title {
274
+ color: #333;
275
+ }
276
+
277
+ .aplayer-author {
278
+ color: #666;
279
+ }
280
+ }
281
+
282
+ .aplayer-lrc {
283
+ &::before,
284
+ &::after {
285
+ background: linear-gradient(180deg, #fff 0, rgba(255, 255, 255, 0));
286
+ }
287
+
288
+ p {
289
+ color: #333;
290
+ }
291
+ }
292
+
293
+ .aplayer-controller {
294
+ .aplayer-time {
295
+ color: #666;
296
+ }
297
+
298
+ .aplayer-bar-wrap {
299
+ .aplayer-bar {
300
+ background: #cdcdcd;
301
+
302
+ .aplayer-played {
303
+ background: #23ade5;
304
+ }
305
+
306
+ .aplayer-thumb {
307
+ background: #23ade5;
308
+ }
309
+ }
310
+ }
311
+ }
312
+ }
313
+
314
+ .aplayer-list {
315
+ border-top: 1px solid #e0e0e0;
316
+
317
+ li {
318
+ &:hover {
319
+ background: #f5f5f5;
320
+ }
321
+
322
+ &.aplayer-list-light {
323
+ background: #e6f7ff;
324
+
325
+ .aplayer-list-title {
326
+ color: #23ade5;
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+ }
333
+ </style>
@@ -0,0 +1,157 @@
1
+ <template>
2
+ <div class="zfile-pdf-viewer">
3
+ <div class="app-header">
4
+ <div v-if="isLoading">
5
+ <span v-if="loadingProgress < 100">
6
+ 加载 {{ loadingProgress }}%
7
+ </span>
8
+ <span v-else>
9
+ 渲染所有页面中...
10
+ </span>
11
+ </div>
12
+ <div v-else>
13
+ <span v-if="showAllPages">
14
+ 共 {{ pageCount }} 页
15
+ </span>
16
+
17
+ <span v-else>
18
+ <button :disabled="page <= 1" @click="page--">❮</button>
19
+ {{ page }} / {{ pageCount }}
20
+ <button :disabled="page >= pageCount" @click="page++">❯</button>
21
+ </span>
22
+ </div>
23
+
24
+ <span v-show="!isLoading">
25
+ <button class="px-1 sm:px-4" @click="pdfViewCanvasWidthNum-=5">-</button>
26
+ <span>
27
+ <span class="hidden sm:inline">缩放比例</span>
28
+ {{pdfViewCanvasWidthNum}} %
29
+ </span>
30
+ <button class="px-1 sm:px-4" @click="pdfViewCanvasWidthNum+=5">+</button>
31
+ </span>
32
+
33
+ <label :class="isLoading ? 'invisible' : 'visible'">
34
+ <input v-model="showAllPages" type="checkbox">
35
+ 显示所有页
36
+ </label>
37
+ </div>
38
+
39
+ <div class="app-content">
40
+ <vue-pdf-embed
41
+ annotationLayer
42
+ textLayer
43
+ ref="pdfRef"
44
+ :source="doc"
45
+ :page="page"
46
+ @rendered="handleDocumentRender"
47
+ />
48
+ </div>
49
+ </div>
50
+ </template>
51
+
52
+ <script setup>
53
+ import { computed, ref, watch } from 'vue'
54
+ import VuePdfEmbed, { useVuePdfEmbed } from 'vue-pdf-embed'
55
+ import { useMagicKeys } from '@vueuse/core'
56
+ const { ArrowLeft, ArrowRight, NumpadAdd, NumpadSubtract } = useMagicKeys()
57
+
58
+ // optional styles
59
+ import 'vue-pdf-embed/dist/styles/annotationLayer.css'
60
+ import 'vue-pdf-embed/dist/styles/textLayer.css'
61
+
62
+ // 组件接收的属性:
63
+ // fileUrl: 文件下载路径
64
+ // fileName: 文件名
65
+ const props = defineProps({
66
+ fileUrl: String,
67
+ fileName: String
68
+ });
69
+
70
+ const pdfRef = ref();
71
+
72
+ const pdfViewCanvasWidthNum = ref(100);
73
+ // 图片外部容器宽度, 100 / 图片列数
74
+ let pdfViewCanvasWidth = computed(() => {
75
+ return `${pdfViewCanvasWidthNum.value}%`;
76
+ })
77
+
78
+ let isLoading = ref(true);
79
+ let page = ref(null);
80
+ let pageCount = ref(1);
81
+ let showAllPages = ref(true);
82
+
83
+ watch(() => showAllPages.value, () => {
84
+ page.value = showAllPages.value ? null : 1;
85
+ });
86
+
87
+ const handleDocumentRender = (a) => {
88
+ pageCount.value = pdfRef.value.doc.numPages;
89
+ isLoading.value = false;
90
+ };
91
+
92
+ const handlerDocumentError = (error) => {
93
+ isLoading.value = false;
94
+ ElMessage.error("PDF 加载失败");
95
+ };
96
+
97
+ const loadingProgress = ref(0);
98
+ const handleDocumentLoadProgress = (progressData) => {
99
+ // 保留2位小数
100
+ loadingProgress.value = (progressData.loaded / progressData.total * 100).toFixed(2);
101
+ };
102
+
103
+ // 支持按键翻页
104
+ watch(() => [ArrowLeft.value, ArrowRight.value], (value) => {
105
+ if (isLoading.value) return;
106
+ if (showAllPages.value) return;
107
+ if (value[0] && page.value > 1) {
108
+ page.value--;
109
+ }
110
+ if (value[1] && page.value < pageCount.value) {
111
+ page.value++;
112
+ }
113
+ })
114
+
115
+ // 支持按键缩放
116
+ watch(() => [NumpadSubtract.value, NumpadAdd.value], (value) => {
117
+ if (value[0]) {
118
+ pdfViewCanvasWidthNum.value -= 5;
119
+ }
120
+ if (value[1]) {
121
+ pdfViewCanvasWidthNum.value += 5;
122
+ }
123
+ })
124
+
125
+ const { doc } = useVuePdfEmbed( {
126
+ source: props.fileUrl,
127
+ onProgress: handleDocumentLoadProgress,
128
+ onError: handlerDocumentError,
129
+ })
130
+ </script>
131
+
132
+ <style scoped lang="scss">
133
+ .vue-pdf-embed {
134
+ :deep(> div) {
135
+ box-shadow: 0 2px 8px 4px rgba(0, 0, 0, 0.1);
136
+ @apply w-full h-full mt-2;
137
+ }
138
+
139
+ :deep(canvas) {
140
+ width: v-bind('pdfViewCanvasWidth') !important;
141
+ height: 100% !important;
142
+ margin: 0 auto;
143
+ }
144
+ }
145
+
146
+ .app-header {
147
+ box-shadow: 0 2px 8px 4px rgba(0, 0, 0, 0.1);
148
+ background-color: #555;
149
+ color: #ddd;
150
+ @apply flex content-between justify-between p-2 sm:p-4 bg-gray-600;
151
+
152
+ }
153
+
154
+ .app-content {
155
+ padding: 24px 0;
156
+ }
157
+ </style>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <VueCodeEditor v-if="fileContent" :fileName="fileName" :modelValue="fileContent" :language="fileSuffix"
3
+ :readonly="true"></VueCodeEditor>
4
+ </template>
5
+
6
+ <script setup>
7
+ // import useStorageConfigStore from "~/stores/storage-config";
8
+ // let storageConfigStore = useStorageConfigStore();
9
+ import { ref, onMounted, reactive } from "vue";
10
+ import { getFileSuffix } from "../../utils";
11
+ import VueCodeEditor from "../vue-codemirror/index.vue";
12
+
13
+ // 组件接收的属性:
14
+ // fileUrl: 文件下载路径
15
+ // fileName: 文件名
16
+ const props = defineProps({
17
+ fileUrl: String,
18
+ fileName: String
19
+ });
20
+
21
+ // 获取文件名后缀
22
+ const fileSuffix = getFileSuffix(props.fileName);
23
+
24
+ // 文件内容
25
+ const fileContent = ref(null);
26
+
27
+ import { getFileTextReq } from "../../api/home/common";
28
+
29
+ // 挂载时,加载文件内容,并初始化播放器
30
+ onMounted(() => {
31
+ let fileUrl = props.fileUrl;
32
+ getFileTextReq(fileUrl).then((res) => {
33
+ fileContent.value = res.request.response;
34
+ }).catch((e) => {
35
+ ElMessage({
36
+ message: `加载文本文件失败. 请检查此地址是否有效或是否限制了跨域访问.`,
37
+ type: 'error',
38
+ duration: 0,
39
+ showClose: true,
40
+ grouping: true,
41
+ })
42
+ });
43
+ });
44
+ </script>