@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,341 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="video-player-container">
|
|
3
|
+
<!-- 视频播放器区域 -->
|
|
4
|
+
<div class="artplayer-app" ref="playerRef"></div>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
import { ref, onMounted, onUnmounted, watch } from 'vue'
|
|
10
|
+
import Mpegts from "mpegts.js"
|
|
11
|
+
import Hls from 'hls.js/dist/hls.light.min'
|
|
12
|
+
import Artplayer from "artplayer"
|
|
13
|
+
import { ElMessage } from 'element-plus'
|
|
14
|
+
|
|
15
|
+
// 组件接收的属性
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
// 视频文件 URL
|
|
18
|
+
fileUrl: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
// 视频文件名
|
|
23
|
+
fileName: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
// 是否允许下载
|
|
28
|
+
allowDownload: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: true
|
|
31
|
+
},
|
|
32
|
+
// 视频列表(用于上下视频切换)
|
|
33
|
+
videoList: {
|
|
34
|
+
type: Array,
|
|
35
|
+
default: () => []
|
|
36
|
+
},
|
|
37
|
+
// 自动播放
|
|
38
|
+
autoPlay: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// 发射事件
|
|
45
|
+
const emit = defineEmits(['error', 'ready', 'ended'])
|
|
46
|
+
|
|
47
|
+
// 响应式数据
|
|
48
|
+
const playerRef = ref(null)
|
|
49
|
+
const hiddenTools = ref(false)
|
|
50
|
+
const isMobile = ref(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
|
|
51
|
+
const currentVideo = ref({ name: '', url: '' })
|
|
52
|
+
const prevVideo = ref(null)
|
|
53
|
+
const nextVideo = ref(null)
|
|
54
|
+
let art = null
|
|
55
|
+
let hlsInstance = null
|
|
56
|
+
|
|
57
|
+
// 初始化播放器
|
|
58
|
+
const initArtPlayer = async (name, url) => {
|
|
59
|
+
currentVideo.value = { name, url }
|
|
60
|
+
|
|
61
|
+
// 销毁旧实例
|
|
62
|
+
if (art) {
|
|
63
|
+
art.destroy(true)
|
|
64
|
+
}
|
|
65
|
+
if (hlsInstance) {
|
|
66
|
+
hlsInstance.destroy()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 判断视频类型
|
|
70
|
+
let videoType = 'mp4'
|
|
71
|
+
const nameLower = name.toLowerCase()
|
|
72
|
+
if (nameLower.endsWith('flv')) {
|
|
73
|
+
videoType = 'flv'
|
|
74
|
+
} else if (nameLower.endsWith('m3u8')) {
|
|
75
|
+
videoType = 'm3u8'
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 播放器配置
|
|
79
|
+
const options = {
|
|
80
|
+
container: playerRef.value,
|
|
81
|
+
title: name,
|
|
82
|
+
url: url,
|
|
83
|
+
type: videoType,
|
|
84
|
+
setting: true,
|
|
85
|
+
playbackRate: true,
|
|
86
|
+
flip: true,
|
|
87
|
+
fullscreen: true,
|
|
88
|
+
fastForward: true,
|
|
89
|
+
autoOrientation: true,
|
|
90
|
+
aspectRatio: true,
|
|
91
|
+
fullscreenWeb: true,
|
|
92
|
+
theme: '#23ade5',
|
|
93
|
+
lock: true,
|
|
94
|
+
miniProgressBar: true,
|
|
95
|
+
autoplay: props.autoPlay,
|
|
96
|
+
whitelist: ['*'],
|
|
97
|
+
airplay: true,
|
|
98
|
+
moreVideoAttr: {
|
|
99
|
+
'x5-video-player-type': 'h5',
|
|
100
|
+
'x5-video-player-fullscreen': false,
|
|
101
|
+
'x5-video-orientation': 'portraint',
|
|
102
|
+
preload: "metadata",
|
|
103
|
+
crossOrigin: 'anonymous',
|
|
104
|
+
},
|
|
105
|
+
// 自定义类型处理
|
|
106
|
+
customType: {
|
|
107
|
+
flv: function(video, url) {
|
|
108
|
+
if (Mpegts.isSupported()) {
|
|
109
|
+
const flvPlayer = Mpegts.createPlayer({
|
|
110
|
+
type: 'flv',
|
|
111
|
+
url: url,
|
|
112
|
+
})
|
|
113
|
+
flvPlayer.attachMediaElement(video)
|
|
114
|
+
flvPlayer.load()
|
|
115
|
+
} else {
|
|
116
|
+
ElMessage.error('不支持播放格式:flv')
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
m3u8: function(video, url) {
|
|
120
|
+
if (Hls.isSupported()) {
|
|
121
|
+
hlsInstance = new Hls()
|
|
122
|
+
hlsInstance.loadSource(url)
|
|
123
|
+
hlsInstance.attachMedia(video)
|
|
124
|
+
} else {
|
|
125
|
+
const canPlay = video.canPlayType('application/vnd.apple.mpegurl')
|
|
126
|
+
if (canPlay === 'probably' || canPlay === 'maybe') {
|
|
127
|
+
video.src = url
|
|
128
|
+
} else {
|
|
129
|
+
ElMessage.error('不支持播放格式:m3u8')
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
// 右键菜单
|
|
135
|
+
contextmenu: props.allowDownload ? [
|
|
136
|
+
{
|
|
137
|
+
html: '下载',
|
|
138
|
+
click: function() {
|
|
139
|
+
window.open(url)
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
] : [],
|
|
143
|
+
// 控制栏
|
|
144
|
+
controls: [
|
|
145
|
+
{
|
|
146
|
+
name: 'hidden-tools',
|
|
147
|
+
position: 'right',
|
|
148
|
+
html: hiddenTools.value ? '🙈' : '👁️',
|
|
149
|
+
click: function(_, event) {
|
|
150
|
+
hiddenTools.value = !hiddenTools.value
|
|
151
|
+
event.target.innerHTML = hiddenTools.value ? '🙈' : '👁️'
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 创建播放器实例
|
|
158
|
+
art = new Artplayer(options)
|
|
159
|
+
|
|
160
|
+
// 错误处理
|
|
161
|
+
art.on("error", (error) => {
|
|
162
|
+
emit('error', error)
|
|
163
|
+
ElMessage.error('视频加载失败')
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
// 就绪事件
|
|
167
|
+
art.on('ready', () => {
|
|
168
|
+
emit('ready', { name, url })
|
|
169
|
+
updatePrevNextVideo(name)
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
// 播放结束事件
|
|
173
|
+
art.on('video:ended', () => {
|
|
174
|
+
emit('ended', { name, url })
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 更新上下视频信息
|
|
179
|
+
const updatePrevNextVideo = (currentName) => {
|
|
180
|
+
if (!props.videoList || props.videoList.length === 0) {
|
|
181
|
+
prevVideo.value = null
|
|
182
|
+
nextVideo.value = null
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const currentIndex = props.videoList.findIndex(v => v.name === currentName)
|
|
187
|
+
if (currentIndex !== -1) {
|
|
188
|
+
prevVideo.value = props.videoList[currentIndex - 1] || null
|
|
189
|
+
nextVideo.value = props.videoList[currentIndex + 1] || null
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// 播放上一个视频
|
|
194
|
+
const playPrevVideo = () => {
|
|
195
|
+
if (prevVideo.value) {
|
|
196
|
+
initArtPlayer(prevVideo.value.name, prevVideo.value.url)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 播放下一个视频
|
|
201
|
+
const playNextVideo = () => {
|
|
202
|
+
if (nextVideo.value) {
|
|
203
|
+
initArtPlayer(nextVideo.value.name, nextVideo.value.url)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 打开外部播放器
|
|
208
|
+
const openTarget = (mode) => {
|
|
209
|
+
const url = currentVideo.value.url
|
|
210
|
+
const name = currentVideo.value.name
|
|
211
|
+
|
|
212
|
+
const handlers = {
|
|
213
|
+
download: () => { window.location = url },
|
|
214
|
+
thunder: () => { window.location = `thunder://${btoa('AA' + url + 'ZZ')}` },
|
|
215
|
+
motrix: () => { window.location = `motrix://new-task?uri=${encodeURIComponent(url)}&out=${encodeURIComponent(name)}` },
|
|
216
|
+
potplayer: () => { window.location = `potplayer://${url}` },
|
|
217
|
+
vlc: () => { window.location = `vlc://${url}` },
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (handlers[mode]) {
|
|
221
|
+
handlers[mode]()
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// 监听属性变化
|
|
226
|
+
watch(() => [props.fileUrl, props.fileName], ([newUrl, newName]) => {
|
|
227
|
+
if (newUrl && newName) {
|
|
228
|
+
initArtPlayer(newName, newUrl)
|
|
229
|
+
}
|
|
230
|
+
}, { immediate: true })
|
|
231
|
+
|
|
232
|
+
// 生命周期
|
|
233
|
+
onMounted(() => {
|
|
234
|
+
if (props.fileUrl && props.fileName) {
|
|
235
|
+
initArtPlayer(props.fileName, props.fileUrl)
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
onUnmounted(() => {
|
|
240
|
+
if (art) {
|
|
241
|
+
art.destroy(true)
|
|
242
|
+
}
|
|
243
|
+
if (hlsInstance) {
|
|
244
|
+
hlsInstance.destroy()
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
// 暴露方法给父组件
|
|
249
|
+
defineExpose({
|
|
250
|
+
play: () => art?.play(),
|
|
251
|
+
pause: () => art?.pause(),
|
|
252
|
+
destroy: () => art?.destroy(true),
|
|
253
|
+
})
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<style scoped lang="scss">
|
|
257
|
+
.video-player-container {
|
|
258
|
+
width: 100%;
|
|
259
|
+
background-color: #f5f5f5;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.artplayer-app {
|
|
263
|
+
width: 100%;
|
|
264
|
+
height: 60vh;
|
|
265
|
+
min-height: 400px;
|
|
266
|
+
background-color: #000;
|
|
267
|
+
|
|
268
|
+
:deep(.art-controls .art-control) {
|
|
269
|
+
min-width: 14px;
|
|
270
|
+
min-height: 14px;
|
|
271
|
+
|
|
272
|
+
@media (min-width: 640px) {
|
|
273
|
+
min-width: 46px;
|
|
274
|
+
min-height: 46px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.art-icon {
|
|
278
|
+
width: 28px;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.zfile-video-switch-tools {
|
|
284
|
+
display: flex;
|
|
285
|
+
justify-content: space-between;
|
|
286
|
+
padding: 12px 20px;
|
|
287
|
+
background-color: #f9fafb;
|
|
288
|
+
border-bottom: 1px solid #e5e7eb;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.zfile-video-tools {
|
|
292
|
+
display: grid;
|
|
293
|
+
grid-template-columns: repeat(3, 1fr);
|
|
294
|
+
gap: 0;
|
|
295
|
+
padding: 12px;
|
|
296
|
+
background-color: #f9fafb;
|
|
297
|
+
|
|
298
|
+
@media (min-width: 640px) {
|
|
299
|
+
display: flex;
|
|
300
|
+
flex-wrap: wrap;
|
|
301
|
+
justify-content: center;
|
|
302
|
+
gap: 16px;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.zfile-video-tools-item {
|
|
306
|
+
display: flex;
|
|
307
|
+
flex-direction: column;
|
|
308
|
+
align-items: center;
|
|
309
|
+
justify-content: center;
|
|
310
|
+
padding: 8px 12px;
|
|
311
|
+
margin: 4px;
|
|
312
|
+
background-color: #fff;
|
|
313
|
+
border-radius: 6px;
|
|
314
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
315
|
+
cursor: pointer;
|
|
316
|
+
transition: all 0.2s;
|
|
317
|
+
|
|
318
|
+
&:hover {
|
|
319
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
320
|
+
transform: translateY(-2px);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
img {
|
|
324
|
+
width: 32px;
|
|
325
|
+
height: 32px;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.zfile-video-tools-tips {
|
|
331
|
+
padding: 8px;
|
|
332
|
+
text-align: center;
|
|
333
|
+
color: #6b7280;
|
|
334
|
+
font-size: 12px;
|
|
335
|
+
background-color: #f9fafb;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.hidden-important {
|
|
339
|
+
display: none !important;
|
|
340
|
+
}
|
|
341
|
+
</style>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<TransitionRoot as="template" :show="show" >
|
|
3
|
+
<Dialog as="div" class="relative z-10" @close="handlerClose('clickModal')" :close-on-click-modal="closeOnClickModal">
|
|
4
|
+
<TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0" enter-to="opacity-100" leave="ease-in duration-200" leave-from="opacity-100" leave-to="opacity-0">
|
|
5
|
+
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
|
|
6
|
+
</TransitionChild>
|
|
7
|
+
|
|
8
|
+
<div class="fixed inset-0 z-10 overflow-y-auto">
|
|
9
|
+
<div class="flex min-h-full justify-center p-4 text-center items-center sm:p-0">
|
|
10
|
+
<TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" enter-to="opacity-100 translate-y-0 sm:scale-100" leave="ease-in duration-200" leave-from="opacity-100 translate-y-0 sm:scale-100" leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95">
|
|
11
|
+
<DialogPanel class="relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 w-11/12 max-w-sm sm:w-full sm:max-w-md sm:p-6">
|
|
12
|
+
<div v-show="showCloseButton" class="absolute right-0 top-0 pr-4 pt-4 block cursor-pointer">
|
|
13
|
+
<div type="button" class="rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" @click="handlerClose('close')">
|
|
14
|
+
<span class="sr-only">Close</span>
|
|
15
|
+
<XMarkIcon class="h-7 w-7" aria-hidden="true" />
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left w-full space-y-3">
|
|
19
|
+
<DialogTitle as="h3" class="text-base font-semibold leading-6 text-gray-900">{{ title }}</DialogTitle>
|
|
20
|
+
<div class="flex flex-row items-center space-x-2">
|
|
21
|
+
<div>
|
|
22
|
+
<InformationCircleIcon v-if="type === 'info'" class="h-7 w-7 text-gray-400" aria-hidden="true" />
|
|
23
|
+
<ExclamationCircleIcon v-else-if="type === 'warning'" class="h-7 w-7 text-yellow-500" aria-hidden="true" />
|
|
24
|
+
<XCircleIcon v-else-if="type === 'error'" class="h-7 w-7 text-red-400" aria-hidden="true" />
|
|
25
|
+
<CheckCircleIcon v-else-if="type === 'success'" class="h-7 w-7 text-green-500" aria-hidden="true" />
|
|
26
|
+
</div>
|
|
27
|
+
<div>
|
|
28
|
+
<p class="text-gray-500 text-sm" v-if="dangerouslyUseHTMLString" v-html="message"></p>
|
|
29
|
+
<p class="text-gray-500 text-sm" v-else>{{ message }}</p>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
<div
|
|
34
|
+
class="mt-5 sm:mt-4 sm:flex sm:justify-end">
|
|
35
|
+
<div class="space-y-4 sm:space-y-0 sm:space-x-2">
|
|
36
|
+
<button type="button"
|
|
37
|
+
v-show="showCancelButton"
|
|
38
|
+
class="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto"
|
|
39
|
+
@click="handlerClose('cancel')">
|
|
40
|
+
{{ props.cancelButtonText }}
|
|
41
|
+
</button>
|
|
42
|
+
<button type="button"
|
|
43
|
+
class="inline-flex w-full justify-center rounded-md bg-blue-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-400 sm:ml-3 sm:w-auto" @click="handlerClose('confirm')">
|
|
44
|
+
{{ confirmButtonText }}
|
|
45
|
+
</button>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</DialogPanel>
|
|
49
|
+
</TransitionChild>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</Dialog>
|
|
53
|
+
</TransitionRoot>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script lang="ts" setup>
|
|
57
|
+
import {
|
|
58
|
+
Dialog,
|
|
59
|
+
DialogPanel,
|
|
60
|
+
DialogTitle,
|
|
61
|
+
TransitionChild,
|
|
62
|
+
TransitionRoot
|
|
63
|
+
} from "@headlessui/vue";
|
|
64
|
+
import { XMarkIcon } from '@heroicons/vue/24/outline'
|
|
65
|
+
import { InformationCircleIcon, ExclamationCircleIcon, XCircleIcon, CheckCircleIcon} from '@heroicons/vue/24/solid'
|
|
66
|
+
import { MessageType } from "./types";
|
|
67
|
+
|
|
68
|
+
const props = defineProps({
|
|
69
|
+
type: {
|
|
70
|
+
type: String as () => MessageType,
|
|
71
|
+
default: 'info'
|
|
72
|
+
},
|
|
73
|
+
show: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
76
|
+
},
|
|
77
|
+
title: {
|
|
78
|
+
type: String,
|
|
79
|
+
required: true,
|
|
80
|
+
},
|
|
81
|
+
message: {
|
|
82
|
+
type: String,
|
|
83
|
+
required: true,
|
|
84
|
+
},
|
|
85
|
+
confirmButtonText: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: 'Confirm',
|
|
88
|
+
},
|
|
89
|
+
cancelButtonText: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: 'Cancel',
|
|
92
|
+
},
|
|
93
|
+
onClose: {
|
|
94
|
+
type: Function,
|
|
95
|
+
default: () => {}
|
|
96
|
+
},
|
|
97
|
+
dangerouslyUseHTMLString: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: false,
|
|
100
|
+
},
|
|
101
|
+
showCancelButton: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: true
|
|
104
|
+
},
|
|
105
|
+
showCloseButton: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: true
|
|
108
|
+
},
|
|
109
|
+
closeOnClickModal: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: true
|
|
112
|
+
},
|
|
113
|
+
closeOnPressEscape: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: true
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
import { useMagicKeys } from '@vueuse/core'
|
|
120
|
+
const { Escape } = useMagicKeys()
|
|
121
|
+
|
|
122
|
+
// 响应关闭事件
|
|
123
|
+
const emit = defineEmits(['update:show'])
|
|
124
|
+
const handlerClose = (type: 'clickModal' | 'pressEscape' | 'cancel' | 'close' | 'confirm') => {
|
|
125
|
+
if (type === 'clickModal' && Escape.value) {
|
|
126
|
+
type = 'pressEscape'
|
|
127
|
+
}
|
|
128
|
+
if (type === 'clickModal' && !props.closeOnClickModal) {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
if (type === 'pressEscape' && !props.closeOnPressEscape) {
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
emit('update:show', false)
|
|
135
|
+
props.onClose(type)
|
|
136
|
+
}
|
|
137
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createApp } from "vue";
|
|
2
|
+
import Confirm from "./confirm.vue";
|
|
3
|
+
import type { Props } from "./types";
|
|
4
|
+
|
|
5
|
+
const createDialog = (message: string, title: string, options: Props = {}) => new Promise((resolve, reject) => {
|
|
6
|
+
const mountNode = document.createElement('div')
|
|
7
|
+
const Instance = createApp(Confirm, {
|
|
8
|
+
show: true,
|
|
9
|
+
message,
|
|
10
|
+
title,
|
|
11
|
+
...options,
|
|
12
|
+
onClose: (type: string) => {
|
|
13
|
+
if (type === 'confirm') {
|
|
14
|
+
resolve(type);
|
|
15
|
+
} else {
|
|
16
|
+
reject(type);
|
|
17
|
+
}
|
|
18
|
+
Instance.unmount();
|
|
19
|
+
document.body.removeChild(mountNode);
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
document.body.appendChild(mountNode)
|
|
24
|
+
Instance.mount(mountNode)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default createDialog;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type MessageType = '' | 'success' | 'warning' | 'info' | 'error';
|
|
2
|
+
|
|
3
|
+
// 声明 Options 类型
|
|
4
|
+
export interface Props {
|
|
5
|
+
type?: MessageType;
|
|
6
|
+
title?: String;
|
|
7
|
+
message?: String;
|
|
8
|
+
confirmButtonText?: String;
|
|
9
|
+
cancelButtonText?: String;
|
|
10
|
+
dangerouslyUseHTMLString?: Boolean;
|
|
11
|
+
showCancelButton?: Boolean;
|
|
12
|
+
showCloseButton?: Boolean;
|
|
13
|
+
closeOnClickModal?: Boolean;
|
|
14
|
+
closeOnPressEscape?: Boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createApp } from "vue";
|
|
2
|
+
import Prompt from "./prompt.vue";
|
|
3
|
+
import type { ConfirmResult, Props } from "./types";
|
|
4
|
+
|
|
5
|
+
const createDialog = (message: string, title: string, options: Props = {}) => new Promise((resolve, reject) => {
|
|
6
|
+
const mountNode = document.createElement('div')
|
|
7
|
+
const Instance = createApp(Prompt, {
|
|
8
|
+
show: true,
|
|
9
|
+
message,
|
|
10
|
+
title,
|
|
11
|
+
...options,
|
|
12
|
+
onClose: (res: ConfirmResult) => {
|
|
13
|
+
if (res.type === 'confirm') {
|
|
14
|
+
resolve(res);
|
|
15
|
+
} else {
|
|
16
|
+
reject(res);
|
|
17
|
+
}
|
|
18
|
+
Instance.unmount();
|
|
19
|
+
document.body.removeChild(mountNode);
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
document.body.appendChild(mountNode)
|
|
24
|
+
Instance.mount(mountNode)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default createDialog;
|