@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.
- package/.vscode/extensions.json +3 -0
- package/README.md +5 -0
- package/auto-imports.d.ts +12 -0
- package/components.d.ts +45 -0
- package/dist.zip +0 -0
- package/index.html +13 -0
- package/package.json +100 -0
- package/presets/eslint/.eslintrc-auto-import.json +462 -0
- package/presets/plugins/html.ts +14 -0
- package/presets/shared/env.ts +46 -0
- package/presets/shared/resolvers.ts +29 -0
- package/presets/tov.ts +132 -0
- package/presets/types/auto-imports.d.ts +806 -0
- package/presets/types/components.d.ts +164 -0
- package/presets/types/env.d.ts +17 -0
- package/public/favicon.svg +1 -0
- package/public/icons.svg +24 -0
- package/public/testfile/README.md +5 -0
- package/public/testfile/useFileContextMenu.js +74 -0
- package/public/testfile//345/217/221/347/245/250.pdf +0 -0
- package/public/testfile//346/216/245/346/224/266/345/207/275.docx +0 -0
- package/public/testfile//350/247/204/346/240/274/345/236/213/345/217/2671.txt +263 -0
- package/public/testfile//350/247/206/351/242/2211.mp4 +0 -0
- package/public/testfile//351/237/263/351/242/2211.mp3 +0 -0
- package/src/App.vue +8 -0
- package/src/api/admin/admin-2fa.js +18 -0
- package/src/api/admin/admin-download-log.js +37 -0
- package/src/api/admin/admin-login-log.js +9 -0
- package/src/api/admin/admin-permission.js +9 -0
- package/src/api/admin/admin-setting.js +121 -0
- package/src/api/admin/admin-share.js +20 -0
- package/src/api/admin/admin-short-link.js +49 -0
- package/src/api/admin/admin-sso.js +38 -0
- package/src/api/admin/admin-storage.js +189 -0
- package/src/api/admin/admin-user.js +61 -0
- package/src/api/home/common.js +9 -0
- package/src/api/home/file-operator.js +89 -0
- package/src/api/home/home.js +87 -0
- package/src/api/home/install.js +18 -0
- package/src/api/home/login.js +9 -0
- package/src/api/home/only-office.js +10 -0
- package/src/api/home/share.js +115 -0
- package/src/api/home/user.js +74 -0
- package/src/api/tools/tools-115.js +17 -0
- package/src/api/tools/tools-gd.js +13 -0
- package/src/api/tools/tools-s3.js +25 -0
- package/src/api/tools/tools-sharepoint.js +19 -0
- package/src/assets/hero.png +0 -0
- package/src/assets/icons/401.svg +1 -0
- package/src/assets/icons/403.svg +45 -0
- package/src/assets/icons/404.svg +1 -0
- package/src/assets/icons/500.svg +1 -0
- package/src/assets/icons/admin-login.svg +1 -0
- package/src/assets/icons/document.svg +1 -0
- package/src/assets/icons/empty.svg +145 -0
- package/src/assets/icons/file-type-apk.svg +1 -0
- package/src/assets/icons/file-type-archive.svg +1 -0
- package/src/assets/icons/file-type-audio.svg +1 -0
- package/src/assets/icons/file-type-back.svg +1 -0
- package/src/assets/icons/file-type-css.svg +1 -0
- package/src/assets/icons/file-type-deb.svg +1 -0
- package/src/assets/icons/file-type-dll.svg +1 -0
- package/src/assets/icons/file-type-doc.svg +1 -0
- package/src/assets/icons/file-type-document.svg +1 -0
- package/src/assets/icons/file-type-docx.svg +1 -0
- package/src/assets/icons/file-type-exe.svg +1 -0
- package/src/assets/icons/file-type-expression.svg +1 -0
- package/src/assets/icons/file-type-file.svg +1 -0
- package/src/assets/icons/file-type-folder.svg +1 -0
- package/src/assets/icons/file-type-html.svg +1 -0
- package/src/assets/icons/file-type-image.svg +1 -0
- package/src/assets/icons/file-type-java.svg +1 -0
- package/src/assets/icons/file-type-js.svg +1 -0
- package/src/assets/icons/file-type-less.svg +1 -0
- package/src/assets/icons/file-type-md.svg +1 -0
- package/src/assets/icons/file-type-office.svg +1 -0
- package/src/assets/icons/file-type-pdf.svg +1 -0
- package/src/assets/icons/file-type-php.svg +1 -0
- package/src/assets/icons/file-type-ppt.svg +1 -0
- package/src/assets/icons/file-type-pptx.svg +1 -0
- package/src/assets/icons/file-type-py.svg +1 -0
- package/src/assets/icons/file-type-rb.svg +1 -0
- package/src/assets/icons/file-type-root.svg +1 -0
- package/src/assets/icons/file-type-rpm.svg +1 -0
- package/src/assets/icons/file-type-rust.svg +1 -0
- package/src/assets/icons/file-type-script.svg +1 -0
- package/src/assets/icons/file-type-text.svg +1 -0
- package/src/assets/icons/file-type-three3d.svg +5 -0
- package/src/assets/icons/file-type-vbs.svg +1 -0
- package/src/assets/icons/file-type-video.svg +1 -0
- package/src/assets/icons/file-type-xls.svg +1 -0
- package/src/assets/icons/file-type-xlsx.svg +1 -0
- package/src/assets/icons/file-type-xml.svg +1 -0
- package/src/assets/icons/file-type-yaml.svg +1 -0
- package/src/assets/icons/file-upload.svg +1 -0
- package/src/assets/icons/github.svg +1 -0
- package/src/assets/icons/install-step.svg +40 -0
- package/src/assets/icons/reset-password.svg +1 -0
- package/src/assets/icons/storage-aliyun.svg +1 -0
- package/src/assets/icons/storage-baidu.svg +1 -0
- package/src/assets/icons/storage-doge-cloud.svg +207 -0
- package/src/assets/icons/storage-ftp.svg +13 -0
- package/src/assets/icons/storage-google-drive.svg +8 -0
- package/src/assets/icons/storage-huawei.svg +1 -0
- package/src/assets/icons/storage-local.svg +11 -0
- package/src/assets/icons/storage-minio.svg +1 -0
- package/src/assets/icons/storage-onedrive-china.svg +18 -0
- package/src/assets/icons/storage-onedrive.svg +4 -0
- package/src/assets/icons/storage-open115.svg +23 -0
- package/src/assets/icons/storage-qiniu.svg +1 -0
- package/src/assets/icons/storage-s3.svg +5 -0
- package/src/assets/icons/storage-sftp.svg +13 -0
- package/src/assets/icons/storage-sharepoint-china.svg +23 -0
- package/src/assets/icons/storage-sharepoint.svg +1 -0
- package/src/assets/icons/storage-tencent.svg +9 -0
- package/src/assets/icons/storage-ufile.svg +14 -0
- package/src/assets/icons/storage-upyun.svg +1 -0
- package/src/assets/icons/storage-webdav.svg +1 -0
- package/src/assets/icons/upload.svg +50 -0
- package/src/assets/icons/zfile-basic.svg +17 -0
- package/src/assets/icons/zfile-horizontal.svg +16 -0
- package/src/assets/icons/zfile.svg +1 -0
- package/src/assets/vite.svg +1 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/HelloWorld.vue +319 -0
- package/src/components/common/QrCodePreview.vue +118 -0
- package/src/components/common/dialog/ZDialog.vue +171 -0
- package/src/components/common/dialog/types.ts +19 -0
- package/src/components/common/dialog/useDialog.ts +18 -0
- package/src/components/common/dialog/useDialogWithForm.ts +21 -0
- package/src/components/copy.vue +133 -0
- package/src/components/file/preview/AudioPlayer.vue +333 -0
- package/src/components/file/preview/CopyCode.vue +47 -0
- package/src/components/file/preview/FileGallery.vue +199 -0
- package/src/components/file/preview/ImageViewer.vue +432 -0
- package/src/components/file/preview/KkFileViewer.vue +86 -0
- package/src/components/file/preview/KkFileViewerDialog.vue +42 -0
- package/src/components/file/preview/MarkdownViewer.vue +102 -0
- package/src/components/file/preview/MarkdownViewerAsyncLoading.vue +17 -0
- package/src/components/file/preview/MarkdownViewerDialogAsyncLoading.vue +12 -0
- package/src/components/file/preview/OfficeViewer.vue +76 -0
- package/src/components/file/preview/OfficeViewerDialog.vue +55 -0
- package/src/components/file/preview/PdfViewer.vue +157 -0
- package/src/components/file/preview/PdfViewerDialog.vue +41 -0
- package/src/components/file/preview/TextViewer.vue +232 -0
- package/src/components/file/preview/TextViewerAsyncLoading.vue +22 -0
- package/src/components/file/preview/TextViewerDialog.vue +53 -0
- package/src/components/file/preview/Three3dPreview.vue +114 -0
- package/src/components/file/preview/Three3dPreviewDialog.vue +50 -0
- package/src/components/file/preview/VideoPlayer.vue +341 -0
- package/src/components/file/preview/VideoPlayerAsyncLoading.vue +45 -0
- package/src/components/file/preview/VideoPlayerDialog.vue +51 -0
- package/src/components/file/selectFolder/SelectFolder.vue +208 -0
- package/src/components/file/selectFolder/index.ts +50 -0
- package/src/components/file/selectFolder/types.ts +5 -0
- package/src/components/fileReview/AudioPlayer-copy.vue +333 -0
- package/src/components/fileReview/PdfViewer-copy.vue +157 -0
- package/src/components/fileReview/TextViewer-copy.vue +44 -0
- package/src/components/fileReview/VideoPlayer-copy.vue +341 -0
- package/src/components/messageBox/confirm/confirm.vue +137 -0
- package/src/components/messageBox/confirm/index.ts +27 -0
- package/src/components/messageBox/confirm/types.ts +15 -0
- package/src/components/messageBox/messageBox.ts +9 -0
- package/src/components/messageBox/prompt/index.ts +27 -0
- package/src/components/messageBox/prompt/prompt.vue +178 -0
- package/src/components/messageBox/prompt/types.ts +24 -0
- package/src/components/vue-codemirror/editor.vue +212 -0
- package/src/components/vue-codemirror/encodings.ts +27 -0
- package/src/components/vue-codemirror/index.vue +380 -0
- package/src/components/vue-codemirror/lang-code/cpp/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/css/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/dockerfile/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/erlang/index.ts +6 -0
- package/src/components/vue-codemirror/lang-code/go/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/html/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/java/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/javascript/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/json/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/jsx/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/lua/index.ts +6 -0
- package/src/components/vue-codemirror/lang-code/markdown/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/mysql/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/nginx/index.ts +6 -0
- package/src/components/vue-codemirror/lang-code/perl/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/pgsql/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/php/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/powershell/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/python/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/r/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/ruby/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/rust/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/shell/index.ts +5 -0
- package/src/components/vue-codemirror/lang-code/sql/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/stylus/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/swift/index.ts +4 -0
- package/src/components/vue-codemirror/lang-code/toml/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/tsx/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/typescript/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/vb/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/vbscript/index.ts +3 -0
- package/src/components/vue-codemirror/lang-code/xml/index.ts +2 -0
- package/src/components/vue-codemirror/lang-code/yaml/index.ts +3 -0
- package/src/components/vue-codemirror/languages.ts +8 -0
- package/src/components/vue-codemirror/themes.ts +5 -0
- package/src/components/vue-codemirror/toolbar.vue +183 -0
- package/src/components/vue-codemirror/types.ts +12 -0
- package/src/components.d.ts +49 -0
- package/src/composables/admin/layout/admin-layout.js +53 -0
- package/src/composables/admin/link/useLinkSetting.js +16 -0
- package/src/composables/admin/sso/baseSsoConfig.js +54 -0
- package/src/composables/admin/sso/useSsoConfig.js +176 -0
- package/src/composables/admin/storage/storage-copy.js +89 -0
- package/src/composables/admin/storage/storage-filter.js +64 -0
- package/src/composables/admin/storage/storage-list.js +202 -0
- package/src/composables/admin/storage/storage-password.js +101 -0
- package/src/composables/admin/storage/storage-readme.js +102 -0
- package/src/composables/admin/storage/utils/open115-util.js +61 -0
- package/src/composables/admin/useAdminSetting.js +60 -0
- package/src/composables/admin/useClientInfo.js +20 -0
- package/src/composables/admin/user/user-copy.js +79 -0
- package/src/composables/file/useBatchOperatorResult.js +19 -0
- package/src/composables/file/useFileContextMenu.js +74 -0
- package/src/composables/file/useFileData.js +243 -0
- package/src/composables/file/useFileLink.js +175 -0
- package/src/composables/file/useFileLoading.js +41 -0
- package/src/composables/file/useFileLongPressEvent.js +71 -0
- package/src/composables/file/useFileOperator.js +347 -0
- package/src/composables/file/useFilePreview.js +99 -0
- package/src/composables/file/useFilePwd.js +138 -0
- package/src/composables/file/useFileSelect.js +105 -0
- package/src/composables/file/useFileShare.js +39 -0
- package/src/composables/file/useFileUpload.js +1045 -0
- package/src/composables/file/useKkFileViewDialog.js +24 -0
- package/src/composables/file/useOfficeViewerDialog.js +20 -0
- package/src/composables/file/usePdfViewerDialog.js +22 -0
- package/src/composables/file/useShareActions.js +94 -0
- package/src/composables/file/useShareTableOperator.js +84 -0
- package/src/composables/file/useTableOperator.js +211 -0
- package/src/composables/file/useTextViewerDialog.js +22 -0
- package/src/composables/file/useThree3dPreviewDialog.js +23 -0
- package/src/composables/file/useVideoPlayerDialog.js +19 -0
- package/src/composables/header/useHeaderBreadcrumb.js +111 -0
- package/src/composables/header/useHeaderStorageList.js +150 -0
- package/src/composables/header/useSetting.js +58 -0
- package/src/composables/share/useShareData.js +178 -0
- package/src/composables/useDarks.ts +4 -0
- package/src/composables/useRouterData.js +41 -0
- package/src/constant/index.js +193 -0
- package/src/http/index.js +153 -0
- package/src/http/request.js +31 -0
- package/src/main.ts +23 -0
- package/src/stores/file-data.ts +108 -0
- package/src/stores/global-config.ts +115 -0
- package/src/stores/storage-config.ts +123 -0
- package/src/style.css +296 -0
- package/src/styles/admin.scss +91 -0
- package/src/styles/code-editor-variables.scss +52 -0
- package/src/styles/element-plus.scss +22 -0
- package/src/styles/error-page.css +26 -0
- package/src/styles/main.css +142 -0
- package/src/styles/tailwind/index.scss +33 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/models/base.ts +34 -0
- package/src/utils/models/file.ts +95 -0
- package/src/utils/models/path.ts +117 -0
- package/src/utils/models/qrcode.ts +21 -0
- package/src/utils/models/time.ts +132 -0
- package/src/utils/models/util.ts +42 -0
- package/src/utils/models/window.ts +14 -0
- package/stats.html +4950 -0
- package/tsconfig.app.json +16 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +57 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="z-dialog-wrapper">
|
|
3
|
+
<el-dialog
|
|
4
|
+
v-bind="attrs"
|
|
5
|
+
:model-value="modelValue"
|
|
6
|
+
:draggable="draggable"
|
|
7
|
+
:show-close="false"
|
|
8
|
+
:fullscreen="attrs?.fullscreen ?? isFullscreen"
|
|
9
|
+
:before-close="handleNativeClose"
|
|
10
|
+
>
|
|
11
|
+
<template #header>
|
|
12
|
+
<div class="z-dialog-title">
|
|
13
|
+
<template v-if="slots.header">
|
|
14
|
+
<slot name="header"></slot>
|
|
15
|
+
</template>
|
|
16
|
+
<template v-else>
|
|
17
|
+
{{ title }}
|
|
18
|
+
</template>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="z-dialog-title-btns">
|
|
21
|
+
<el-icon v-if="isFullScreenBtn" @click="handleFullscreen"><ArrowsPointingOutIcon /></el-icon>
|
|
22
|
+
<el-icon size="20" @click="handleClose('close')"><XMarkIcon /></el-icon>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<div class="z-dialog-content" v-loading="loading">
|
|
27
|
+
<slot></slot>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<template #footer>
|
|
31
|
+
<span v-if="!slots.footer && showFooter" class="z-dialog-footer">
|
|
32
|
+
<el-button type="primary" @click="handleConfirm">{{ confirmText }}</el-button>
|
|
33
|
+
<el-button @click="handleClose('cancel')">{{ cancelText }}</el-button>
|
|
34
|
+
</span>
|
|
35
|
+
<slot v-else name="footer"></slot>
|
|
36
|
+
</template>
|
|
37
|
+
</el-dialog>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
import { computed, ref, useAttrs, useSlots } from "vue";
|
|
42
|
+
import { ArrowsPointingOutIcon, XMarkIcon } from '@heroicons/vue/24/outline';
|
|
43
|
+
import { ElDialog, ElIcon, ElButton } from "element-plus";
|
|
44
|
+
import type { DialogCloseType, PropsType } from "./types";
|
|
45
|
+
|
|
46
|
+
const attrs = useAttrs();
|
|
47
|
+
const slots = useSlots();
|
|
48
|
+
|
|
49
|
+
const props = withDefaults(defineProps<PropsType>(), {
|
|
50
|
+
title: "",
|
|
51
|
+
isDraggable: false,
|
|
52
|
+
modelValue: false,
|
|
53
|
+
hiddenFullBtn: false,
|
|
54
|
+
loading: false,
|
|
55
|
+
confirmText: "确认",
|
|
56
|
+
cancelText: "关闭",
|
|
57
|
+
destroyOnClose: false,
|
|
58
|
+
draggable: false,
|
|
59
|
+
autoFullScreen: false,
|
|
60
|
+
onClose: null,
|
|
61
|
+
showFooter: true,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const emits = defineEmits<{
|
|
65
|
+
(e: "update:modelValue"): void;
|
|
66
|
+
(e: "confirm"): void;
|
|
67
|
+
(e: "close", type: DialogCloseType): void;
|
|
68
|
+
}>();
|
|
69
|
+
|
|
70
|
+
const isFullscreen = ref(props.autoFullScreen ? window.innerWidth < 768 : false);
|
|
71
|
+
const isFullScreenBtn = computed(() => {
|
|
72
|
+
// 如果指定了原生的 fullscreen 属性,则不显示全屏按钮
|
|
73
|
+
if (attrs?.fullscreen) return false;
|
|
74
|
+
return !props.hiddenFullBtn;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const handleFullscreen = () => {
|
|
78
|
+
// 如果指定了原生的 fullscreen 属性,则不响应全屏按钮的操作
|
|
79
|
+
if (attrs?.fullscreen) return;
|
|
80
|
+
isFullscreen.value = !isFullscreen.value;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// 发生了原生的关闭事件(点击遮罩,按 esc 键)
|
|
84
|
+
const handleNativeClose = () => {
|
|
85
|
+
handleClose("close");
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const handleClose = (type: DialogCloseType) => {
|
|
89
|
+
// 如果定义了原生的 before-close 属性,则先执行 before-close 方法
|
|
90
|
+
if (Reflect.has(attrs, "before-close") && typeof attrs["before-close"] === "function") {
|
|
91
|
+
attrs["before-close"]();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 判断 emits 里是否有 close 事件,有则触发,没有则直接更新 modelValue
|
|
95
|
+
if (props.onClose) {
|
|
96
|
+
emits("close", type)
|
|
97
|
+
} else {
|
|
98
|
+
emits("update:modelValue");
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const handleConfirm = () => {
|
|
103
|
+
emits("confirm");
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
defineExpose({
|
|
107
|
+
isVisible: props.modelValue,
|
|
108
|
+
});
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<style lang="scss" scoped>
|
|
112
|
+
// 去除默认的顶部 padding,使得标题可以紧贴顶部,不会显得距离顶部比距离正文多
|
|
113
|
+
:deep(.el-dialog) {
|
|
114
|
+
padding-top: 0;
|
|
115
|
+
padding-bottom: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 标题区样式,左侧标题,右侧按钮,下方分割线
|
|
119
|
+
:deep(.el-dialog__header) {
|
|
120
|
+
border-bottom: 1px solid #eee;
|
|
121
|
+
padding: 12px 0;
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: space-between;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 标题文字样式,居左显示,超出后显示省略号
|
|
128
|
+
.z-dialog-title {
|
|
129
|
+
width: 100%;
|
|
130
|
+
line-height: 24px;
|
|
131
|
+
font-size: 18px;
|
|
132
|
+
color: #303133;
|
|
133
|
+
text-align: left;
|
|
134
|
+
|
|
135
|
+
margin-right: 16px;
|
|
136
|
+
// 标题超出后显示省略号
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
display: -webkit-box;
|
|
139
|
+
-webkit-box-orient: vertical;
|
|
140
|
+
-webkit-line-clamp: 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 标题按钮区样式,右侧按钮区域,按钮之间有间距, 按钮 hover 时颜色变化
|
|
144
|
+
.z-dialog-title-btns {
|
|
145
|
+
display: flex;
|
|
146
|
+
align-items: center;
|
|
147
|
+
i {
|
|
148
|
+
margin-right: 8px;
|
|
149
|
+
|
|
150
|
+
font-size: 16px;
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
}
|
|
153
|
+
i:hover, i:focus {
|
|
154
|
+
color: var(--el-color-primary);
|
|
155
|
+
}
|
|
156
|
+
i:last-child {
|
|
157
|
+
margin-right: 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.z-dialog-content {
|
|
162
|
+
height: 100%;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.z-dialog-wrapper {
|
|
166
|
+
:deep(.el-dialog__footer) {
|
|
167
|
+
@apply pb-4;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface PropsType {
|
|
2
|
+
title?: string;
|
|
3
|
+
isDraggable?: boolean;
|
|
4
|
+
modelValue?: boolean;
|
|
5
|
+
hiddenFullBtn?: boolean;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
confirmText?: string;
|
|
8
|
+
cancelText?: string;
|
|
9
|
+
destroyOnClose?: boolean;
|
|
10
|
+
draggable?: boolean;
|
|
11
|
+
/*
|
|
12
|
+
是否根据设备是否是移动端来自动设置全屏
|
|
13
|
+
*/
|
|
14
|
+
autoFullScreen?: boolean;
|
|
15
|
+
onClose?: Function | null;
|
|
16
|
+
showFooter?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export declare type DialogCloseType = 'cancel' | 'close';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
|
|
3
|
+
export default function useDialog() {
|
|
4
|
+
const visible = ref(false);
|
|
5
|
+
const loading = ref(false);
|
|
6
|
+
const openDialog = () => (visible.value = true);
|
|
7
|
+
const closeDialog = () => (visible.value = false);
|
|
8
|
+
const openLoading = () => (loading.value = true);
|
|
9
|
+
const closeLoading = () => (loading.value = false);
|
|
10
|
+
return {
|
|
11
|
+
visible,
|
|
12
|
+
loading,
|
|
13
|
+
openDialog,
|
|
14
|
+
closeDialog,
|
|
15
|
+
openLoading,
|
|
16
|
+
closeLoading,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FormInstance } from "element-plus";
|
|
2
|
+
import { Ref, ref } from "vue";
|
|
3
|
+
|
|
4
|
+
export default function useDialogFn(
|
|
5
|
+
formInstance: Ref<FormInstance|undefined>
|
|
6
|
+
) {
|
|
7
|
+
|
|
8
|
+
const visible = ref(false);
|
|
9
|
+
|
|
10
|
+
const closeDialog = () => {
|
|
11
|
+
formInstance.value?.resetFields();
|
|
12
|
+
visible.value = false;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const openDialog = () => {
|
|
16
|
+
visible.value = true;
|
|
17
|
+
formInstance.value?.resetFields();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return { visible, openDialog, closeDialog };
|
|
21
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { concatPath, getFileType, buildShareBasePath } from '~/utils'
|
|
4
|
+
import PdfViewer from '~/components/file/preview/PdfViewer.vue'
|
|
5
|
+
import VideoPlayer from '~/components/file/preview/VideoPlayer.vue'
|
|
6
|
+
import AudioPlayer from '~/components/file/preview/AudioPlayer.vue'
|
|
7
|
+
// import TextViewer from '~/components/file/preview/TextViewer.vue'
|
|
8
|
+
// import MarkdownViewer from '~/components/file/preview/MarkdownViewer.vue'
|
|
9
|
+
import OfficeViewer from '~/components/file/preview/OfficeViewer.vue'
|
|
10
|
+
import KkFileViewer from '~/components/file/preview/KkFileViewer.vue'
|
|
11
|
+
import Three3dPreview from '~/components/file/preview/Three3dPreview.vue'
|
|
12
|
+
const fileType = ref('')
|
|
13
|
+
// 文件列表数据
|
|
14
|
+
const files = ref([
|
|
15
|
+
{ name: '文档1.pdf', path: 'https://gylfile.newbtob.cn/2025/06/27/80ea498ede08499295caf1951e3a60f1.pdf', type: 'FILE', fileType: 'pdf' },
|
|
16
|
+
{ name: '视频1.mp4', path: 'https://mp4.vjshi.com/2025-09-08/02a4a8bdaedf499da50480359a65860f.mp4', type: 'FILE' },
|
|
17
|
+
{ name: '音频1.mp3', path: '/testfile/音频1.mp3', type: 'FILE' },
|
|
18
|
+
{ name: '文档3.txt', path: '/testfile/规格型号1.txt', type: 'FILE' },
|
|
19
|
+
{ name: 'useFileContextMenu.js', path: '/testfile/useFileContextMenu.js', type: 'FILE' },
|
|
20
|
+
{ name: '接收函.docx', path: '/testfile/接收函.docx', type: 'FILE' },
|
|
21
|
+
{ name: 'README.md', path: '/testfile/README.md', type: 'FILE' }
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
// 当前选中的文件
|
|
25
|
+
const selectedFile = ref(null)
|
|
26
|
+
|
|
27
|
+
// 处理文件点击事件
|
|
28
|
+
const selectFile = (file) => {
|
|
29
|
+
selectedFile.value = file
|
|
30
|
+
fileType.value = getFileType(file.name);
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<div class="container">
|
|
36
|
+
<!-- 文件列表 -->
|
|
37
|
+
<div class="file-list">
|
|
38
|
+
<h3>文件列表</h3>
|
|
39
|
+
<ul>
|
|
40
|
+
<li
|
|
41
|
+
v-for="file in files"
|
|
42
|
+
:key="file.name"
|
|
43
|
+
@click="selectFile(file)"
|
|
44
|
+
:class="{ active: selectedFile === file }"
|
|
45
|
+
>
|
|
46
|
+
{{ file.name }}
|
|
47
|
+
</li>
|
|
48
|
+
</ul>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<!-- PDF 预览区域 -->
|
|
52
|
+
<div class="preview-area">
|
|
53
|
+
<h3>文件预览</h3>
|
|
54
|
+
<!-- PDF预览 -->
|
|
55
|
+
<div v-if="fileType === 'pdf'">
|
|
56
|
+
<PdfViewer :file-name="selectedFile.name" :file-url="selectedFile.path" />
|
|
57
|
+
</div>
|
|
58
|
+
<!-- 视频预览 -->
|
|
59
|
+
<div v-else-if="fileType === 'video'">
|
|
60
|
+
<VideoPlayer :file-name="selectedFile.name" :file-url="selectedFile.path" />
|
|
61
|
+
</div>
|
|
62
|
+
<!-- 音频预览 -->
|
|
63
|
+
<div v-else-if="fileType === 'audio'">
|
|
64
|
+
<AudioPlayer :file-name="selectedFile.name" :file-url="selectedFile.path" />
|
|
65
|
+
</div>
|
|
66
|
+
<!-- 文本预览 -->
|
|
67
|
+
<div class="textviewer" v-else-if="fileType === 'text'">
|
|
68
|
+
<!-- <TextViewer :key="selectedFile?.path" :file-name="selectedFile.name" :file-url="selectedFile.path" v-if="selectedFile.name.indexOf('.md') === -1" /> -->
|
|
69
|
+
<!-- <MarkdownViewer :file-name="selectedFile.name" :file-url="selectedFile.path" v-if="selectedFile.name.indexOf('.md') !== -1"></MarkdownViewer> -->
|
|
70
|
+
</div>
|
|
71
|
+
<!-- 图片预览 -->
|
|
72
|
+
<div v-else-if="fileType === 'image'">
|
|
73
|
+
|
|
74
|
+
</div>
|
|
75
|
+
<div v-else-if="fileType === 'office'">
|
|
76
|
+
<OfficeViewer :file-name="selectedFile.name" :file-url="selectedFile.path"></OfficeViewer>
|
|
77
|
+
</div>
|
|
78
|
+
<div v-else-if="fileType === 'kkfileview'">
|
|
79
|
+
<KkFileViewer :file-name="selectedFile.name" :file-url="selectedFile.path"></KkFileViewer>
|
|
80
|
+
</div>
|
|
81
|
+
<div v-else-if="fileType === 'three3d'">
|
|
82
|
+
<Three3dPreview :file-name="selectedFile.name" :file-url="selectedFile.path"></Three3dPreview>
|
|
83
|
+
</div>
|
|
84
|
+
<div v-else-if="selectedFile">
|
|
85
|
+
<p>当前文件不支持预览</p>
|
|
86
|
+
</div>
|
|
87
|
+
<div v-else>
|
|
88
|
+
<p>请选择一个文件进行预览</p>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<style scoped>
|
|
95
|
+
.container {
|
|
96
|
+
gap: 20px;
|
|
97
|
+
padding: 20px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.file-list, .preview-area {
|
|
101
|
+
border: 1px solid #ddd;
|
|
102
|
+
border-radius: 8px;
|
|
103
|
+
padding: 15px;
|
|
104
|
+
height: 500px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.file-list ul {
|
|
108
|
+
list-style: none;
|
|
109
|
+
padding: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.file-list li {
|
|
113
|
+
padding: 10px;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
border-bottom: 1px solid #eee;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.file-list li:hover {
|
|
119
|
+
background-color: #f5f5f5;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.file-list li.active {
|
|
123
|
+
background-color: #e6f7ff;
|
|
124
|
+
font-weight: bold;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.preview-area {
|
|
128
|
+
min-height: 400px;
|
|
129
|
+
}
|
|
130
|
+
.textviewer{
|
|
131
|
+
height: 100%;
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -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>
|