@ebiz/designer-components 0.1.124 → 0.1.125
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/README.md +29 -29
- package/dist/designer-components.css +1 -1
- package/dist/index.mjs +35847 -33799
- package/dist/{pdf-C9oIcL2N.js → pdf-KomaE0u5.js} +891 -891
- package/package.json +1 -1
- package/src/App.vue +26 -26
- package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
- package/src/apiService/mockDataService.js +115 -115
- package/src/apiService/simpleDataService.js +312 -312
- package/src/assets/base.css +86 -86
- package/src/assets/logo.svg +1 -1
- package/src/components/Button.vue +149 -149
- package/src/components/DataContainer.vue +40 -40
- package/src/components/EbizApproval.vue +366 -366
- package/src/components/EbizApprovalDetail.vue +169 -169
- package/src/components/EbizApprovalForm.vue +534 -534
- package/src/components/EbizApprovalV2.vue +713 -713
- package/src/components/EbizAutoForm.vue +596 -596
- package/src/components/EbizAvatar.vue +115 -115
- package/src/components/EbizCheckbox.vue +93 -93
- package/src/components/EbizCheckboxGroup.vue +69 -69
- package/src/components/EbizDepartmentSelector.vue +148 -148
- package/src/components/EbizDescriptions.vue +340 -340
- package/src/components/EbizDescriptionsItem.vue +47 -47
- package/src/components/EbizDetailBlock.vue +81 -81
- package/src/components/EbizDetailItem.vue +559 -559
- package/src/components/EbizDetailView.md +438 -438
- package/src/components/EbizDetailView.vue +355 -355
- package/src/components/EbizDialog.vue +260 -260
- package/src/components/EbizDictionarySelect.vue +229 -229
- package/src/components/EbizDiv.vue +40 -40
- package/src/components/EbizDivider.vue +96 -96
- package/src/components/EbizDormDashboard.vue +314 -314
- package/src/components/EbizDropdown.vue +135 -135
- package/src/components/EbizDropdownItem.vue +85 -85
- package/src/components/EbizEmployeeInfo.vue +144 -144
- package/src/components/EbizEmployeeSelector.vue +1160 -1160
- package/src/components/EbizFileList.vue +502 -502
- package/src/components/EbizMap.vue +541 -541
- package/src/components/EbizMeetingRoomSelector.vue +1149 -1149
- package/src/components/EbizMobileMeetingRoomSelector.vue +727 -727
- package/src/components/EbizOkrTree.vue +99 -99
- package/src/components/EbizPageHeader.vue +98 -98
- package/src/components/EbizPagination.vue +162 -162
- package/src/components/EbizParkingDashboard.vue +152 -152
- package/src/components/EbizPdfViewer.vue +540 -540
- package/src/components/EbizPopconfirm.vue +47 -47
- package/src/components/EbizQrCode.vue +167 -167
- package/src/components/EbizRadio.vue +86 -86
- package/src/components/EbizRadioGroup.vue +83 -83
- package/src/components/EbizRemoteSelect.vue +232 -232
- package/src/components/EbizRichTextEditor.vue +338 -338
- package/src/components/EbizRouteBreadcrumb.vue +46 -46
- package/src/components/EbizSApprovalProcess.vue +1456 -1426
- package/src/components/EbizSelect.vue +85 -85
- package/src/components/EbizSpace.vue +100 -100
- package/src/components/EbizStatistic.vue +149 -149
- package/src/components/EbizStatsCard.vue +113 -113
- package/src/components/EbizSwiper.vue +113 -113
- package/src/components/EbizSwiperItem.vue +13 -13
- package/src/components/EbizSwitch.vue +85 -85
- package/src/components/EbizTabHeader.vue +132 -132
- package/src/components/EbizTabPanel.vue +22 -22
- package/src/components/EbizTable.vue +469 -469
- package/src/components/EbizTableColumn.vue +116 -116
- package/src/components/EbizTableSort.vue +179 -179
- package/src/components/EbizTabs.vue +142 -142
- package/src/components/EbizTdesignButtonDialog.vue +332 -332
- package/src/components/EbizTdesignLoading.vue +107 -107
- package/src/components/EbizTimePicker.vue +143 -143
- package/src/components/EbizTitle.vue +91 -91
- package/src/components/EbizTree.vue +141 -141
- package/src/components/EbizTreeMergeTable.vue +1494 -1494
- package/src/components/EbizTreeSelector.vue +469 -469
- package/src/components/EbizVideo.vue +553 -553
- package/src/components/EbizVxeTable.vue +290 -290
- package/src/components/Form.vue +28 -28
- package/src/components/Home.vue +7 -7
- package/src/components/LaunchInterview.vue +526 -526
- package/src/components/MyComponent.vue +39 -39
- package/src/components/Table.vue +45 -45
- package/src/components/TdesignAlert.vue +115 -115
- package/src/components/TdesignButton.vue +135 -135
- package/src/components/TdesignCalendar/index.vue +145 -145
- package/src/components/TdesignCard.vue +195 -195
- package/src/components/TdesignCol.vue +101 -101
- package/src/components/TdesignCollapse.vue +142 -142
- package/src/components/TdesignCollapsePanel.vue +79 -79
- package/src/components/TdesignDatePicker.vue +124 -124
- package/src/components/TdesignDescriptions.vue +74 -74
- package/src/components/TdesignDescriptionsItem.vue +50 -50
- package/src/components/TdesignDialog.vue +225 -225
- package/src/components/TdesignForm.vue +138 -138
- package/src/components/TdesignFormItem.vue +105 -105
- package/src/components/TdesignGrid.vue +55 -55
- package/src/components/TdesignIcon.vue +67 -67
- package/src/components/TdesignImage.vue +162 -162
- package/src/components/TdesignImageViewer.vue +200 -200
- package/src/components/TdesignInput.vue +242 -242
- package/src/components/TdesignSelect.vue +446 -446
- package/src/components/TdesignTag.vue +117 -117
- package/src/components/TdesignTextarea.vue +142 -142
- package/src/components/TdesignTimeline.vue +58 -58
- package/src/components/TdesignTimelineItem.vue +71 -71
- package/src/components/TdesignUpload.vue +414 -414
- package/src/components/TdesignWatermark.vue +107 -107
- package/src/components/ebiz-form/components/cascader.vue +61 -61
- package/src/components/ebiz-form/components/checkbox.vue +37 -37
- package/src/components/ebiz-form/components/city.vue +137 -137
- package/src/components/ebiz-form/components/date-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range.vue +56 -56
- package/src/components/ebiz-form/components/date.vue +52 -52
- package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/editor.vue +78 -78
- package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/file.vue +149 -149
- package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/images.vue +129 -129
- package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/img.vue +129 -129
- package/src/components/ebiz-form/components/number.vue +50 -50
- package/src/components/ebiz-form/components/radio.vue +28 -28
- package/src/components/ebiz-form/components/select.vue +119 -119
- package/src/components/ebiz-form/components/switch.vue +23 -23
- package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/text.vue +52 -52
- package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
- package/src/components/ebiz-form/components/textarea.vue +29 -29
- package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/video.vue +97 -97
- package/src/components/ebiz-form/index.vue +157 -157
- package/src/components/examples/PopconfirmExample.vue +149 -149
- package/src/components/icons/IconCommunity.vue +7 -7
- package/src/components/icons/IconDocumentation.vue +7 -7
- package/src/components/icons/IconEcosystem.vue +7 -7
- package/src/components/icons/IconSupport.vue +7 -7
- package/src/components/icons/IconTooling.vue +19 -19
- package/src/components/mItems/UserInfo.vue +349 -349
- package/src/components/senior/EbizApprovalList/ApprovalList.vue +127 -127
- package/src/components/senior/EbizSData/index.vue +280 -280
- package/src/components/senior/EbizSDialog/index.vue +776 -776
- package/src/components/senior/EbizSForm/README.md +157 -157
- package/src/components/senior/EbizSForm/index.vue +667 -667
- package/src/components/senior/EbizSForm/item.vue +1011 -1011
- package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
- package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
- package/src/index.js +327 -327
- package/src/main.js +55 -55
- package/src/router/index.js +436 -436
- package/src/utils/formatCode.js +24 -24
- package/src/utils/generateImportStatement.js +52 -52
- package/src/utils/hasJsx.js +25 -25
- package/src/utils/index.js +166 -166
- package/src/utils/mergeOptions.js +29 -29
- package/src/utils/parseRequiredBlocks.js +18 -18
- package/src/utils/vue-sfc-validator.js +155 -155
- package/src/views/Button.vue +23 -23
- package/src/views/CheckboxDemo.vue +104 -104
- package/src/views/DataContainer.vue +19 -19
- package/src/views/DialogDemo.vue +125 -125
- package/src/views/EbizApprovalDemo.vue +87 -87
- package/src/views/EbizApprovalFormDemo.vue +207 -207
- package/src/views/EbizAutoFormDemo.vue +129 -129
- package/src/views/EbizAvatar.vue +223 -223
- package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
- package/src/views/EbizDetailBlockDemo.vue +30 -30
- package/src/views/EbizDetailViewDemo.vue +412 -412
- package/src/views/EbizDormDashboardDemo.vue +87 -87
- package/src/views/EbizEmployeeInfo.vue +249 -249
- package/src/views/EbizEmployeeSelector.vue +85 -85
- package/src/views/EbizFileListDemo.vue +339 -339
- package/src/views/EbizMap.vue +201 -201
- package/src/views/EbizMeetingRoomSelectorDemo.vue +293 -293
- package/src/views/EbizMobileMeetingRoomSelectorDemo.vue +566 -566
- package/src/views/EbizParkingDashboardDemo.vue +28 -28
- package/src/views/EbizRadioDemo.vue +151 -151
- package/src/views/EbizSDataDemo.vue +136 -136
- package/src/views/EbizSDialogDemo.vue +303 -303
- package/src/views/EbizSForm/index.vue +352 -352
- package/src/views/EbizSFormDemo.vue +420 -420
- package/src/views/EbizSpace.vue +185 -185
- package/src/views/EbizSwiper.vue +157 -157
- package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
- package/src/views/Form.vue +19 -19
- package/src/views/GridDemo.vue +238 -238
- package/src/views/Home.vue +156 -156
- package/src/views/LaunchInterviewDemo.vue +111 -111
- package/src/views/Mindmap.vue +17 -17
- package/src/views/MyComponent.vue +19 -19
- package/src/views/OkrTree.vue +19 -19
- package/src/views/PageHeaderDemo.vue +104 -104
- package/src/views/PaginationDemo.vue +96 -96
- package/src/views/PdfViewerDemo.vue +433 -433
- package/src/views/PermissionBoxDemo.vue +85 -85
- package/src/views/PopconfirmDemo.vue +80 -80
- package/src/views/RemoteSelect.vue +350 -350
- package/src/views/StatisticDemo.vue +190 -190
- package/src/views/SwitchDemo.vue +79 -79
- package/src/views/Table.vue +19 -19
- package/src/views/TableDemo.vue +334 -334
- package/src/views/TableSortDemo.vue +143 -143
- package/src/views/TableView.vue +68 -68
- package/src/views/TabsDemo.vue +282 -282
- package/src/views/TagDemo.vue +101 -101
- package/src/views/TdesignAlert.vue +98 -98
- package/src/views/TdesignButton.vue +190 -190
- package/src/views/TdesignCalendar.vue +94 -94
- package/src/views/TdesignCard.vue +296 -296
- package/src/views/TdesignCollapse.vue +293 -293
- package/src/views/TdesignDatePicker.vue +187 -187
- package/src/views/TdesignDescriptions.vue +101 -101
- package/src/views/TdesignForm.vue +248 -248
- package/src/views/TdesignIcon.vue +203 -203
- package/src/views/TdesignImage.vue +215 -215
- package/src/views/TdesignImageViewer.vue +198 -198
- package/src/views/TdesignInput.vue +252 -252
- package/src/views/TdesignSelect.vue +473 -473
- package/src/views/TdesignSwiper.vue +157 -157
- package/src/views/TextareaDemo.vue +93 -93
- package/src/views/TimePickerDemo.vue +146 -146
- package/src/views/TimelineDemo.vue +160 -160
- package/src/views/Title.vue +19 -19
- package/src/views/TreeDemo.vue +254 -254
- package/src/views/TreeMergeTableDemo.vue +239 -239
- package/src/views/TreeSelectorDemo.vue +245 -245
- package/src/views/UploadDemo.vue +128 -128
- package/src/views/VideoDemo.vue +245 -245
- package/src/views/VxeTableDemo.vue +279 -279
- package/src/views/WatermarkDemo.vue +85 -85
|
@@ -1,554 +1,554 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="ebiz-video-player"
|
|
4
|
-
:style="{ height }"
|
|
5
|
-
@mouseenter="handleMouseEnter"
|
|
6
|
-
@mouseleave="handleMouseLeave"
|
|
7
|
-
@mousemove="handleMouseMove"
|
|
8
|
-
>
|
|
9
|
-
<video
|
|
10
|
-
ref="videoRef"
|
|
11
|
-
class="ebiz-video"
|
|
12
|
-
:src="src"
|
|
13
|
-
:poster="poster"
|
|
14
|
-
:autoplay="autoplay"
|
|
15
|
-
:loop="loop"
|
|
16
|
-
:muted="muted"
|
|
17
|
-
:preload="preload"
|
|
18
|
-
:controls="showNativeControls"
|
|
19
|
-
@click="handleClickOnVideo"
|
|
20
|
-
@timeupdate="handleTimeUpdate"
|
|
21
|
-
@loadedmetadata="handleLoadedMetadata"
|
|
22
|
-
@play="handlePlay"
|
|
23
|
-
@pause="handlePause"
|
|
24
|
-
@ended="handleEnded"
|
|
25
|
-
@error="handleError"
|
|
26
|
-
@progress="handleProgress"
|
|
27
|
-
@seeking="handleSeeking"
|
|
28
|
-
@seeked="handleSeeked"
|
|
29
|
-
></video>
|
|
30
|
-
|
|
31
|
-
<!-- 自定义控制器 -->
|
|
32
|
-
<div v-if="!showNativeControls" class="ebiz-video-controls" :class="{ 'controls-hidden': !controlsVisible }">
|
|
33
|
-
<!-- 顶部控制栏 -->
|
|
34
|
-
<div class="ebiz-video-header">
|
|
35
|
-
<div class="ebiz-video-title">{{ title }}</div>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<!-- 中间播放按钮 -->
|
|
39
|
-
<div v-if="!isPlaying" class="ebiz-video-center-play" @click="togglePlay">
|
|
40
|
-
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
41
|
-
<path d="M8 5V19L19 12L8 5Z" fill="currentColor" />
|
|
42
|
-
</svg>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
<!-- 底部控制栏 -->
|
|
46
|
-
<div class="ebiz-video-footer">
|
|
47
|
-
<!-- 进度条 -->
|
|
48
|
-
<div class="ebiz-video-progress">
|
|
49
|
-
<div
|
|
50
|
-
class="ebiz-video-progress-bar"
|
|
51
|
-
@mousedown="handleProgressMouseDown"
|
|
52
|
-
>
|
|
53
|
-
<div
|
|
54
|
-
class="ebiz-video-progress-loaded"
|
|
55
|
-
:style="{ width: loadedPercent + '%' }"
|
|
56
|
-
></div>
|
|
57
|
-
<div
|
|
58
|
-
class="ebiz-video-progress-played"
|
|
59
|
-
:style="{ width: playedPercent + '%' }"
|
|
60
|
-
></div>
|
|
61
|
-
<div
|
|
62
|
-
class="ebiz-video-progress-handle"
|
|
63
|
-
:style="{ left: playedPercent + '%' }"
|
|
64
|
-
></div>
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<!-- 控制按钮组 -->
|
|
69
|
-
<div class="ebiz-video-controls-buttons">
|
|
70
|
-
<div class="ebiz-video-control-button" @click="togglePlay">
|
|
71
|
-
<svg v-if="isPlaying" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
72
|
-
<path d="M6 4H10V20H6V4ZM14 4H18V20H14V4Z" fill="currentColor" />
|
|
73
|
-
</svg>
|
|
74
|
-
<svg v-else width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
75
|
-
<path d="M8 5V19L19 12L8 5Z" fill="currentColor" />
|
|
76
|
-
</svg>
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
<div class="ebiz-video-time">
|
|
80
|
-
{{ formatTime(currentTime) }} / {{ formatTime(duration) }}
|
|
81
|
-
</div>
|
|
82
|
-
|
|
83
|
-
<div class="ebiz-video-control-button" @click="toggleMute">
|
|
84
|
-
<svg v-if="isMuted" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
85
|
-
<path d="M5.889 16H2a1 1 0 01-1-1V9a1 1 0 011-1h3.889l5.294-4.332a.5.5 0 01.817.387v15.89a.5.5 0 01-.817.387L5.89 16zm14.525-4l3.536 3.536-1.414 1.414L19 13.414l-3.536 3.536-1.414-1.414L17.586 12 14.05 8.464l1.414-1.414L19 10.586l3.536-3.536 1.414 1.414L20.414 12z" fill="currentColor" />
|
|
86
|
-
</svg>
|
|
87
|
-
<svg v-else width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
88
|
-
<path d="M5.889 16H2a1 1 0 01-1-1V9a1 1 0 011-1h3.889l5.294-4.332a.5.5 0 01.817.387v15.89a.5.5 0 01-.817.387L5.89 16zm13.517-7.926a6 6 0 010 7.852l-1.386-1.336a4 4 0 000-5.18l1.386-1.336zm2.793-2.688a10 10 0 010 13.228l-1.387-1.336a8 8 0 000-10.556l1.387-1.336z" fill="currentColor" />
|
|
89
|
-
</svg>
|
|
90
|
-
</div>
|
|
91
|
-
|
|
92
|
-
<div class="ebiz-video-control-button" @click="toggleFullscreen">
|
|
93
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
94
|
-
<path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 18h-6v-2h4v-4h2v6zM4 21v-4H2v-2h6v6H4z" fill="currentColor" />
|
|
95
|
-
</svg>
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
|
|
101
|
-
<!-- 加载中状态 -->
|
|
102
|
-
<div v-if="isLoading && !hasError" class="ebiz-video-loading">
|
|
103
|
-
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
104
|
-
<path d="M12 2a10 10 0 110 20 10 10 0 010-20zm0 2a8 8 0 100 16 8 8 0 000-16z" fill="currentColor" opacity="0.3" />
|
|
105
|
-
<path d="M20 12a8 8 0 01-8 8V4a8 8 0 018 8z" fill="currentColor" />
|
|
106
|
-
</svg>
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
<!-- 错误状态 -->
|
|
110
|
-
<div v-if="hasError" class="ebiz-video-error">
|
|
111
|
-
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
112
|
-
<path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 100-16 8 8 0 000 16zm-1-5h2v2h-2v-2zm0-8h2v6h-2V7z" fill="currentColor" />
|
|
113
|
-
</svg>
|
|
114
|
-
<span>视频加载失败</span>
|
|
115
|
-
</div>
|
|
116
|
-
</div>
|
|
117
|
-
</template>
|
|
118
|
-
|
|
119
|
-
<script setup>
|
|
120
|
-
import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
|
|
121
|
-
|
|
122
|
-
const props = defineProps({
|
|
123
|
-
// 视频源URL
|
|
124
|
-
src: {
|
|
125
|
-
type: String,
|
|
126
|
-
required: true
|
|
127
|
-
},
|
|
128
|
-
// 封面图片URL
|
|
129
|
-
poster: {
|
|
130
|
-
type: String,
|
|
131
|
-
default: ''
|
|
132
|
-
},
|
|
133
|
-
// 视频标题
|
|
134
|
-
title: {
|
|
135
|
-
type: String,
|
|
136
|
-
default: ''
|
|
137
|
-
},
|
|
138
|
-
// 是否自动播放
|
|
139
|
-
autoplay: {
|
|
140
|
-
type: Boolean,
|
|
141
|
-
default: false
|
|
142
|
-
},
|
|
143
|
-
// 是否循环播放
|
|
144
|
-
loop: {
|
|
145
|
-
type: Boolean,
|
|
146
|
-
default: false
|
|
147
|
-
},
|
|
148
|
-
// 是否静音
|
|
149
|
-
muted: {
|
|
150
|
-
type: Boolean,
|
|
151
|
-
default: false
|
|
152
|
-
},
|
|
153
|
-
// 预加载模式
|
|
154
|
-
preload: {
|
|
155
|
-
type: String,
|
|
156
|
-
default: 'auto'
|
|
157
|
-
},
|
|
158
|
-
// 是否显示原生控制栏
|
|
159
|
-
showNativeControls: {
|
|
160
|
-
type: Boolean,
|
|
161
|
-
default: false
|
|
162
|
-
},
|
|
163
|
-
// 播放器高度
|
|
164
|
-
height: {
|
|
165
|
-
type: String,
|
|
166
|
-
default: '360px'
|
|
167
|
-
},
|
|
168
|
-
// 初始音量
|
|
169
|
-
volume: {
|
|
170
|
-
type: Number,
|
|
171
|
-
default: 1
|
|
172
|
-
},
|
|
173
|
-
// 当前播放时间(用于v-model)
|
|
174
|
-
modelValue: {
|
|
175
|
-
type: Number,
|
|
176
|
-
default: 0
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const emit = defineEmits([
|
|
181
|
-
'update:modelValue',
|
|
182
|
-
'play',
|
|
183
|
-
'pause',
|
|
184
|
-
'ended',
|
|
185
|
-
'timeupdate',
|
|
186
|
-
'error',
|
|
187
|
-
'progress',
|
|
188
|
-
'seeking',
|
|
189
|
-
'seeked',
|
|
190
|
-
'loadedmetadata'
|
|
191
|
-
]);
|
|
192
|
-
|
|
193
|
-
// 状态变量
|
|
194
|
-
const videoRef = ref(null);
|
|
195
|
-
const isPlaying = ref(false);
|
|
196
|
-
const isMuted = ref(props.muted);
|
|
197
|
-
const duration = ref(0);
|
|
198
|
-
const currentTime = ref(props.modelValue);
|
|
199
|
-
const buffered = ref(0);
|
|
200
|
-
const isLoading = ref(true);
|
|
201
|
-
const hasError = ref(false);
|
|
202
|
-
const controlsVisible = ref(true);
|
|
203
|
-
const controlsTimeout = ref(null);
|
|
204
|
-
|
|
205
|
-
// 计算属性
|
|
206
|
-
const playedPercent = computed(() => {
|
|
207
|
-
if (duration.value === 0) return 0;
|
|
208
|
-
return (currentTime.value / duration.value) * 100;
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
const loadedPercent = computed(() => {
|
|
212
|
-
if (duration.value === 0) return 0;
|
|
213
|
-
return (buffered.value / duration.value) * 100;
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// 方法
|
|
217
|
-
const togglePlay = () => {
|
|
218
|
-
if (videoRef.value.paused) {
|
|
219
|
-
videoRef.value.play();
|
|
220
|
-
} else {
|
|
221
|
-
videoRef.value.pause();
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const toggleMute = () => {
|
|
226
|
-
isMuted.value = !isMuted.value;
|
|
227
|
-
videoRef.value.muted = isMuted.value;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const toggleFullscreen = () => {
|
|
231
|
-
if (!document.fullscreenElement) {
|
|
232
|
-
videoRef.value.parentElement.requestFullscreen();
|
|
233
|
-
} else {
|
|
234
|
-
if (document.exitFullscreen) {
|
|
235
|
-
document.exitFullscreen();
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
const formatTime = (seconds) => {
|
|
241
|
-
if (isNaN(seconds) || seconds === Infinity) return '00:00';
|
|
242
|
-
seconds = Math.floor(seconds);
|
|
243
|
-
const minutes = Math.floor(seconds / 60);
|
|
244
|
-
seconds = seconds % 60;
|
|
245
|
-
return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const showControls = () => {
|
|
249
|
-
controlsVisible.value = true;
|
|
250
|
-
|
|
251
|
-
// 自动隐藏控制栏
|
|
252
|
-
if (controlsTimeout.value) {
|
|
253
|
-
clearTimeout(controlsTimeout.value);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (isPlaying.value) {
|
|
257
|
-
controlsTimeout.value = setTimeout(() => {
|
|
258
|
-
controlsVisible.value = false;
|
|
259
|
-
}, 3000);
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
// 进度条拖动事件处理
|
|
264
|
-
const handleProgressMouseDown = (e) => {
|
|
265
|
-
const progressBar = e.currentTarget;
|
|
266
|
-
const rect = progressBar.getBoundingClientRect();
|
|
267
|
-
const offsetX = e.clientX - rect.left;
|
|
268
|
-
const percent = offsetX / rect.width;
|
|
269
|
-
const newTime = percent * duration.value;
|
|
270
|
-
|
|
271
|
-
videoRef.value.currentTime = newTime;
|
|
272
|
-
|
|
273
|
-
const handleMouseMove = (e) => {
|
|
274
|
-
const offsetX = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
|
275
|
-
const percent = offsetX / rect.width;
|
|
276
|
-
const newTime = percent * duration.value;
|
|
277
|
-
videoRef.value.currentTime = newTime;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
const handleMouseUp = () => {
|
|
281
|
-
document.removeEventListener('mousemove', handleMouseMove);
|
|
282
|
-
document.removeEventListener('mouseup', handleMouseUp);
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
document.addEventListener('mousemove', handleMouseMove);
|
|
286
|
-
document.addEventListener('mouseup', handleMouseUp);
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
// 视频事件处理函数
|
|
290
|
-
const handleTimeUpdate = () => {
|
|
291
|
-
currentTime.value = videoRef.value.currentTime;
|
|
292
|
-
emit('update:modelValue', currentTime.value);
|
|
293
|
-
emit('timeupdate', {
|
|
294
|
-
currentTime: currentTime.value,
|
|
295
|
-
duration: duration.value,
|
|
296
|
-
percent: playedPercent.value
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
const handleLoadedMetadata = () => {
|
|
301
|
-
duration.value = videoRef.value.duration;
|
|
302
|
-
isLoading.value = false;
|
|
303
|
-
|
|
304
|
-
// 设置初始音量
|
|
305
|
-
videoRef.value.volume = props.volume;
|
|
306
|
-
|
|
307
|
-
// 如果有初始时间,设置播放位置
|
|
308
|
-
if (props.modelValue > 0) {
|
|
309
|
-
videoRef.value.currentTime = props.modelValue;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
emit('loadedmetadata', {
|
|
313
|
-
duration: duration.value
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
const handlePlay = () => {
|
|
318
|
-
isPlaying.value = true;
|
|
319
|
-
showControls(); // 显示控制栏,然后自动隐藏
|
|
320
|
-
emit('play');
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
const handlePause = () => {
|
|
324
|
-
isPlaying.value = false;
|
|
325
|
-
showControls(); // 显示控制栏
|
|
326
|
-
if (controlsTimeout.value) {
|
|
327
|
-
clearTimeout(controlsTimeout.value);
|
|
328
|
-
}
|
|
329
|
-
emit('pause');
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
const handleEnded = () => {
|
|
333
|
-
isPlaying.value = false;
|
|
334
|
-
showControls(); // 显示控制栏
|
|
335
|
-
emit('ended');
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
const handleError = (e) => {
|
|
339
|
-
hasError.value = true;
|
|
340
|
-
isLoading.value = false;
|
|
341
|
-
emit('error', e);
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
const handleProgress = () => {
|
|
345
|
-
if (!videoRef.value || !videoRef.value.buffered || videoRef.value.buffered.length === 0) return;
|
|
346
|
-
|
|
347
|
-
const bufferedEnd = videoRef.value.buffered.end(videoRef.value.buffered.length - 1);
|
|
348
|
-
buffered.value = bufferedEnd;
|
|
349
|
-
|
|
350
|
-
emit('progress', {
|
|
351
|
-
buffered: buffered.value,
|
|
352
|
-
percent: loadedPercent.value
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
const handleSeeking = () => {
|
|
357
|
-
isLoading.value = true;
|
|
358
|
-
emit('seeking', {
|
|
359
|
-
currentTime: currentTime.value
|
|
360
|
-
});
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const handleSeeked = () => {
|
|
364
|
-
isLoading.value = false;
|
|
365
|
-
emit('seeked', {
|
|
366
|
-
currentTime: currentTime.value
|
|
367
|
-
});
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
// 点击事件监听,用于显示/隐藏控制栏
|
|
371
|
-
const handleClickOnVideo = () => {
|
|
372
|
-
if (controlsVisible.value) {
|
|
373
|
-
controlsVisible.value = false;
|
|
374
|
-
} else {
|
|
375
|
-
showControls();
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
// 鼠标事件处理函数
|
|
380
|
-
const handleMouseEnter = () => {
|
|
381
|
-
// 鼠标移入时显示控制器
|
|
382
|
-
showControls();
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
const handleMouseLeave = () => {
|
|
386
|
-
// 鼠标移出时,如果视频正在播放,则隐藏控制器
|
|
387
|
-
if (isPlaying.value) {
|
|
388
|
-
controlsVisible.value = false;
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
const handleMouseMove = () => {
|
|
393
|
-
// 鼠标在视频上移动时显示控制器
|
|
394
|
-
showControls();
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
// 生命周期钩子
|
|
398
|
-
onMounted(() => {
|
|
399
|
-
// 初始化组件
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
onBeforeUnmount(() => {
|
|
403
|
-
if (controlsTimeout.value) {
|
|
404
|
-
clearTimeout(controlsTimeout.value);
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
</script>
|
|
408
|
-
|
|
409
|
-
<style scoped>
|
|
410
|
-
.ebiz-video-player {
|
|
411
|
-
position: relative;
|
|
412
|
-
width: 100%;
|
|
413
|
-
background-color: #000;
|
|
414
|
-
overflow: hidden;
|
|
415
|
-
border-radius: 4px;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
.ebiz-video {
|
|
419
|
-
width: 100%;
|
|
420
|
-
height: 100%;
|
|
421
|
-
object-fit: contain;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
.ebiz-video-controls {
|
|
425
|
-
position: absolute;
|
|
426
|
-
top: 0;
|
|
427
|
-
left: 0;
|
|
428
|
-
right: 0;
|
|
429
|
-
bottom: 0;
|
|
430
|
-
background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 70%, rgba(0,0,0,0.3) 100%);
|
|
431
|
-
display: flex;
|
|
432
|
-
flex-direction: column;
|
|
433
|
-
justify-content: space-between;
|
|
434
|
-
opacity: 1;
|
|
435
|
-
transition: opacity 0.3s ease;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
.controls-hidden {
|
|
439
|
-
opacity: 0;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
.ebiz-video-header {
|
|
443
|
-
padding: 16px;
|
|
444
|
-
display: flex;
|
|
445
|
-
align-items: center;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
.ebiz-video-title {
|
|
449
|
-
color: #fff;
|
|
450
|
-
font-size: 16px;
|
|
451
|
-
text-shadow: 0 0 2px rgba(0,0,0,0.5);
|
|
452
|
-
overflow: hidden;
|
|
453
|
-
text-overflow: ellipsis;
|
|
454
|
-
white-space: nowrap;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
.ebiz-video-center-play {
|
|
458
|
-
position: absolute;
|
|
459
|
-
top: 50%;
|
|
460
|
-
left: 50%;
|
|
461
|
-
transform: translate(-50%, -50%);
|
|
462
|
-
color: rgba(255, 255, 255, 0.8);
|
|
463
|
-
cursor: pointer;
|
|
464
|
-
z-index: 2;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
.ebiz-video-footer {
|
|
468
|
-
padding: 16px;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
.ebiz-video-progress {
|
|
472
|
-
margin-bottom: 16px;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
.ebiz-video-progress-bar {
|
|
476
|
-
position: relative;
|
|
477
|
-
height: 4px;
|
|
478
|
-
background-color: rgba(255, 255, 255, 0.3);
|
|
479
|
-
border-radius: 2px;
|
|
480
|
-
cursor: pointer;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
.ebiz-video-progress-loaded {
|
|
484
|
-
position: absolute;
|
|
485
|
-
top: 0;
|
|
486
|
-
left: 0;
|
|
487
|
-
height: 100%;
|
|
488
|
-
background-color: rgba(255, 255, 255, 0.5);
|
|
489
|
-
border-radius: 2px;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
.ebiz-video-progress-played {
|
|
493
|
-
position: absolute;
|
|
494
|
-
top: 0;
|
|
495
|
-
left: 0;
|
|
496
|
-
height: 100%;
|
|
497
|
-
background-color: #0052d9;
|
|
498
|
-
border-radius: 2px;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
.ebiz-video-progress-handle {
|
|
502
|
-
position: absolute;
|
|
503
|
-
top: 50%;
|
|
504
|
-
width: 12px;
|
|
505
|
-
height: 12px;
|
|
506
|
-
background-color: #fff;
|
|
507
|
-
border-radius: 50%;
|
|
508
|
-
transform: translate(-50%, -50%);
|
|
509
|
-
box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
.ebiz-video-controls-buttons {
|
|
513
|
-
display: flex;
|
|
514
|
-
align-items: center;
|
|
515
|
-
justify-content: space-between;
|
|
516
|
-
color: #fff;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
.ebiz-video-control-button {
|
|
520
|
-
padding: 8px;
|
|
521
|
-
cursor: pointer;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
.ebiz-video-time {
|
|
525
|
-
font-size: 14px;
|
|
526
|
-
color: #fff;
|
|
527
|
-
text-shadow: 0 0 2px rgba(0,0,0,0.5);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
.ebiz-video-loading {
|
|
531
|
-
position: absolute;
|
|
532
|
-
top: 50%;
|
|
533
|
-
left: 50%;
|
|
534
|
-
transform: translate(-50%, -50%);
|
|
535
|
-
color: #fff;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
.ebiz-video-error {
|
|
539
|
-
position: absolute;
|
|
540
|
-
top: 50%;
|
|
541
|
-
left: 50%;
|
|
542
|
-
transform: translate(-50%, -50%);
|
|
543
|
-
display: flex;
|
|
544
|
-
flex-direction: column;
|
|
545
|
-
align-items: center;
|
|
546
|
-
color: #ff4d4f;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
.ebiz-video-error span {
|
|
550
|
-
margin-top: 8px;
|
|
551
|
-
font-size: 14px;
|
|
552
|
-
color: #fff;
|
|
553
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="ebiz-video-player"
|
|
4
|
+
:style="{ height }"
|
|
5
|
+
@mouseenter="handleMouseEnter"
|
|
6
|
+
@mouseleave="handleMouseLeave"
|
|
7
|
+
@mousemove="handleMouseMove"
|
|
8
|
+
>
|
|
9
|
+
<video
|
|
10
|
+
ref="videoRef"
|
|
11
|
+
class="ebiz-video"
|
|
12
|
+
:src="src"
|
|
13
|
+
:poster="poster"
|
|
14
|
+
:autoplay="autoplay"
|
|
15
|
+
:loop="loop"
|
|
16
|
+
:muted="muted"
|
|
17
|
+
:preload="preload"
|
|
18
|
+
:controls="showNativeControls"
|
|
19
|
+
@click="handleClickOnVideo"
|
|
20
|
+
@timeupdate="handleTimeUpdate"
|
|
21
|
+
@loadedmetadata="handleLoadedMetadata"
|
|
22
|
+
@play="handlePlay"
|
|
23
|
+
@pause="handlePause"
|
|
24
|
+
@ended="handleEnded"
|
|
25
|
+
@error="handleError"
|
|
26
|
+
@progress="handleProgress"
|
|
27
|
+
@seeking="handleSeeking"
|
|
28
|
+
@seeked="handleSeeked"
|
|
29
|
+
></video>
|
|
30
|
+
|
|
31
|
+
<!-- 自定义控制器 -->
|
|
32
|
+
<div v-if="!showNativeControls" class="ebiz-video-controls" :class="{ 'controls-hidden': !controlsVisible }">
|
|
33
|
+
<!-- 顶部控制栏 -->
|
|
34
|
+
<div class="ebiz-video-header">
|
|
35
|
+
<div class="ebiz-video-title">{{ title }}</div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<!-- 中间播放按钮 -->
|
|
39
|
+
<div v-if="!isPlaying" class="ebiz-video-center-play" @click="togglePlay">
|
|
40
|
+
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
41
|
+
<path d="M8 5V19L19 12L8 5Z" fill="currentColor" />
|
|
42
|
+
</svg>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<!-- 底部控制栏 -->
|
|
46
|
+
<div class="ebiz-video-footer">
|
|
47
|
+
<!-- 进度条 -->
|
|
48
|
+
<div class="ebiz-video-progress">
|
|
49
|
+
<div
|
|
50
|
+
class="ebiz-video-progress-bar"
|
|
51
|
+
@mousedown="handleProgressMouseDown"
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
class="ebiz-video-progress-loaded"
|
|
55
|
+
:style="{ width: loadedPercent + '%' }"
|
|
56
|
+
></div>
|
|
57
|
+
<div
|
|
58
|
+
class="ebiz-video-progress-played"
|
|
59
|
+
:style="{ width: playedPercent + '%' }"
|
|
60
|
+
></div>
|
|
61
|
+
<div
|
|
62
|
+
class="ebiz-video-progress-handle"
|
|
63
|
+
:style="{ left: playedPercent + '%' }"
|
|
64
|
+
></div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<!-- 控制按钮组 -->
|
|
69
|
+
<div class="ebiz-video-controls-buttons">
|
|
70
|
+
<div class="ebiz-video-control-button" @click="togglePlay">
|
|
71
|
+
<svg v-if="isPlaying" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
72
|
+
<path d="M6 4H10V20H6V4ZM14 4H18V20H14V4Z" fill="currentColor" />
|
|
73
|
+
</svg>
|
|
74
|
+
<svg v-else width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
75
|
+
<path d="M8 5V19L19 12L8 5Z" fill="currentColor" />
|
|
76
|
+
</svg>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div class="ebiz-video-time">
|
|
80
|
+
{{ formatTime(currentTime) }} / {{ formatTime(duration) }}
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div class="ebiz-video-control-button" @click="toggleMute">
|
|
84
|
+
<svg v-if="isMuted" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
85
|
+
<path d="M5.889 16H2a1 1 0 01-1-1V9a1 1 0 011-1h3.889l5.294-4.332a.5.5 0 01.817.387v15.89a.5.5 0 01-.817.387L5.89 16zm14.525-4l3.536 3.536-1.414 1.414L19 13.414l-3.536 3.536-1.414-1.414L17.586 12 14.05 8.464l1.414-1.414L19 10.586l3.536-3.536 1.414 1.414L20.414 12z" fill="currentColor" />
|
|
86
|
+
</svg>
|
|
87
|
+
<svg v-else width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
88
|
+
<path d="M5.889 16H2a1 1 0 01-1-1V9a1 1 0 011-1h3.889l5.294-4.332a.5.5 0 01.817.387v15.89a.5.5 0 01-.817.387L5.89 16zm13.517-7.926a6 6 0 010 7.852l-1.386-1.336a4 4 0 000-5.18l1.386-1.336zm2.793-2.688a10 10 0 010 13.228l-1.387-1.336a8 8 0 000-10.556l1.387-1.336z" fill="currentColor" />
|
|
89
|
+
</svg>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div class="ebiz-video-control-button" @click="toggleFullscreen">
|
|
93
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
94
|
+
<path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 18h-6v-2h4v-4h2v6zM4 21v-4H2v-2h6v6H4z" fill="currentColor" />
|
|
95
|
+
</svg>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<!-- 加载中状态 -->
|
|
102
|
+
<div v-if="isLoading && !hasError" class="ebiz-video-loading">
|
|
103
|
+
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
104
|
+
<path d="M12 2a10 10 0 110 20 10 10 0 010-20zm0 2a8 8 0 100 16 8 8 0 000-16z" fill="currentColor" opacity="0.3" />
|
|
105
|
+
<path d="M20 12a8 8 0 01-8 8V4a8 8 0 018 8z" fill="currentColor" />
|
|
106
|
+
</svg>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<!-- 错误状态 -->
|
|
110
|
+
<div v-if="hasError" class="ebiz-video-error">
|
|
111
|
+
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
112
|
+
<path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 100-16 8 8 0 000 16zm-1-5h2v2h-2v-2zm0-8h2v6h-2V7z" fill="currentColor" />
|
|
113
|
+
</svg>
|
|
114
|
+
<span>视频加载失败</span>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</template>
|
|
118
|
+
|
|
119
|
+
<script setup>
|
|
120
|
+
import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
|
|
121
|
+
|
|
122
|
+
const props = defineProps({
|
|
123
|
+
// 视频源URL
|
|
124
|
+
src: {
|
|
125
|
+
type: String,
|
|
126
|
+
required: true
|
|
127
|
+
},
|
|
128
|
+
// 封面图片URL
|
|
129
|
+
poster: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: ''
|
|
132
|
+
},
|
|
133
|
+
// 视频标题
|
|
134
|
+
title: {
|
|
135
|
+
type: String,
|
|
136
|
+
default: ''
|
|
137
|
+
},
|
|
138
|
+
// 是否自动播放
|
|
139
|
+
autoplay: {
|
|
140
|
+
type: Boolean,
|
|
141
|
+
default: false
|
|
142
|
+
},
|
|
143
|
+
// 是否循环播放
|
|
144
|
+
loop: {
|
|
145
|
+
type: Boolean,
|
|
146
|
+
default: false
|
|
147
|
+
},
|
|
148
|
+
// 是否静音
|
|
149
|
+
muted: {
|
|
150
|
+
type: Boolean,
|
|
151
|
+
default: false
|
|
152
|
+
},
|
|
153
|
+
// 预加载模式
|
|
154
|
+
preload: {
|
|
155
|
+
type: String,
|
|
156
|
+
default: 'auto'
|
|
157
|
+
},
|
|
158
|
+
// 是否显示原生控制栏
|
|
159
|
+
showNativeControls: {
|
|
160
|
+
type: Boolean,
|
|
161
|
+
default: false
|
|
162
|
+
},
|
|
163
|
+
// 播放器高度
|
|
164
|
+
height: {
|
|
165
|
+
type: String,
|
|
166
|
+
default: '360px'
|
|
167
|
+
},
|
|
168
|
+
// 初始音量
|
|
169
|
+
volume: {
|
|
170
|
+
type: Number,
|
|
171
|
+
default: 1
|
|
172
|
+
},
|
|
173
|
+
// 当前播放时间(用于v-model)
|
|
174
|
+
modelValue: {
|
|
175
|
+
type: Number,
|
|
176
|
+
default: 0
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const emit = defineEmits([
|
|
181
|
+
'update:modelValue',
|
|
182
|
+
'play',
|
|
183
|
+
'pause',
|
|
184
|
+
'ended',
|
|
185
|
+
'timeupdate',
|
|
186
|
+
'error',
|
|
187
|
+
'progress',
|
|
188
|
+
'seeking',
|
|
189
|
+
'seeked',
|
|
190
|
+
'loadedmetadata'
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
// 状态变量
|
|
194
|
+
const videoRef = ref(null);
|
|
195
|
+
const isPlaying = ref(false);
|
|
196
|
+
const isMuted = ref(props.muted);
|
|
197
|
+
const duration = ref(0);
|
|
198
|
+
const currentTime = ref(props.modelValue);
|
|
199
|
+
const buffered = ref(0);
|
|
200
|
+
const isLoading = ref(true);
|
|
201
|
+
const hasError = ref(false);
|
|
202
|
+
const controlsVisible = ref(true);
|
|
203
|
+
const controlsTimeout = ref(null);
|
|
204
|
+
|
|
205
|
+
// 计算属性
|
|
206
|
+
const playedPercent = computed(() => {
|
|
207
|
+
if (duration.value === 0) return 0;
|
|
208
|
+
return (currentTime.value / duration.value) * 100;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const loadedPercent = computed(() => {
|
|
212
|
+
if (duration.value === 0) return 0;
|
|
213
|
+
return (buffered.value / duration.value) * 100;
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// 方法
|
|
217
|
+
const togglePlay = () => {
|
|
218
|
+
if (videoRef.value.paused) {
|
|
219
|
+
videoRef.value.play();
|
|
220
|
+
} else {
|
|
221
|
+
videoRef.value.pause();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const toggleMute = () => {
|
|
226
|
+
isMuted.value = !isMuted.value;
|
|
227
|
+
videoRef.value.muted = isMuted.value;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const toggleFullscreen = () => {
|
|
231
|
+
if (!document.fullscreenElement) {
|
|
232
|
+
videoRef.value.parentElement.requestFullscreen();
|
|
233
|
+
} else {
|
|
234
|
+
if (document.exitFullscreen) {
|
|
235
|
+
document.exitFullscreen();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const formatTime = (seconds) => {
|
|
241
|
+
if (isNaN(seconds) || seconds === Infinity) return '00:00';
|
|
242
|
+
seconds = Math.floor(seconds);
|
|
243
|
+
const minutes = Math.floor(seconds / 60);
|
|
244
|
+
seconds = seconds % 60;
|
|
245
|
+
return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const showControls = () => {
|
|
249
|
+
controlsVisible.value = true;
|
|
250
|
+
|
|
251
|
+
// 自动隐藏控制栏
|
|
252
|
+
if (controlsTimeout.value) {
|
|
253
|
+
clearTimeout(controlsTimeout.value);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (isPlaying.value) {
|
|
257
|
+
controlsTimeout.value = setTimeout(() => {
|
|
258
|
+
controlsVisible.value = false;
|
|
259
|
+
}, 3000);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// 进度条拖动事件处理
|
|
264
|
+
const handleProgressMouseDown = (e) => {
|
|
265
|
+
const progressBar = e.currentTarget;
|
|
266
|
+
const rect = progressBar.getBoundingClientRect();
|
|
267
|
+
const offsetX = e.clientX - rect.left;
|
|
268
|
+
const percent = offsetX / rect.width;
|
|
269
|
+
const newTime = percent * duration.value;
|
|
270
|
+
|
|
271
|
+
videoRef.value.currentTime = newTime;
|
|
272
|
+
|
|
273
|
+
const handleMouseMove = (e) => {
|
|
274
|
+
const offsetX = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
|
275
|
+
const percent = offsetX / rect.width;
|
|
276
|
+
const newTime = percent * duration.value;
|
|
277
|
+
videoRef.value.currentTime = newTime;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const handleMouseUp = () => {
|
|
281
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
282
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
286
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// 视频事件处理函数
|
|
290
|
+
const handleTimeUpdate = () => {
|
|
291
|
+
currentTime.value = videoRef.value.currentTime;
|
|
292
|
+
emit('update:modelValue', currentTime.value);
|
|
293
|
+
emit('timeupdate', {
|
|
294
|
+
currentTime: currentTime.value,
|
|
295
|
+
duration: duration.value,
|
|
296
|
+
percent: playedPercent.value
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const handleLoadedMetadata = () => {
|
|
301
|
+
duration.value = videoRef.value.duration;
|
|
302
|
+
isLoading.value = false;
|
|
303
|
+
|
|
304
|
+
// 设置初始音量
|
|
305
|
+
videoRef.value.volume = props.volume;
|
|
306
|
+
|
|
307
|
+
// 如果有初始时间,设置播放位置
|
|
308
|
+
if (props.modelValue > 0) {
|
|
309
|
+
videoRef.value.currentTime = props.modelValue;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
emit('loadedmetadata', {
|
|
313
|
+
duration: duration.value
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const handlePlay = () => {
|
|
318
|
+
isPlaying.value = true;
|
|
319
|
+
showControls(); // 显示控制栏,然后自动隐藏
|
|
320
|
+
emit('play');
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const handlePause = () => {
|
|
324
|
+
isPlaying.value = false;
|
|
325
|
+
showControls(); // 显示控制栏
|
|
326
|
+
if (controlsTimeout.value) {
|
|
327
|
+
clearTimeout(controlsTimeout.value);
|
|
328
|
+
}
|
|
329
|
+
emit('pause');
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const handleEnded = () => {
|
|
333
|
+
isPlaying.value = false;
|
|
334
|
+
showControls(); // 显示控制栏
|
|
335
|
+
emit('ended');
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const handleError = (e) => {
|
|
339
|
+
hasError.value = true;
|
|
340
|
+
isLoading.value = false;
|
|
341
|
+
emit('error', e);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const handleProgress = () => {
|
|
345
|
+
if (!videoRef.value || !videoRef.value.buffered || videoRef.value.buffered.length === 0) return;
|
|
346
|
+
|
|
347
|
+
const bufferedEnd = videoRef.value.buffered.end(videoRef.value.buffered.length - 1);
|
|
348
|
+
buffered.value = bufferedEnd;
|
|
349
|
+
|
|
350
|
+
emit('progress', {
|
|
351
|
+
buffered: buffered.value,
|
|
352
|
+
percent: loadedPercent.value
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const handleSeeking = () => {
|
|
357
|
+
isLoading.value = true;
|
|
358
|
+
emit('seeking', {
|
|
359
|
+
currentTime: currentTime.value
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const handleSeeked = () => {
|
|
364
|
+
isLoading.value = false;
|
|
365
|
+
emit('seeked', {
|
|
366
|
+
currentTime: currentTime.value
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// 点击事件监听,用于显示/隐藏控制栏
|
|
371
|
+
const handleClickOnVideo = () => {
|
|
372
|
+
if (controlsVisible.value) {
|
|
373
|
+
controlsVisible.value = false;
|
|
374
|
+
} else {
|
|
375
|
+
showControls();
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
// 鼠标事件处理函数
|
|
380
|
+
const handleMouseEnter = () => {
|
|
381
|
+
// 鼠标移入时显示控制器
|
|
382
|
+
showControls();
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const handleMouseLeave = () => {
|
|
386
|
+
// 鼠标移出时,如果视频正在播放,则隐藏控制器
|
|
387
|
+
if (isPlaying.value) {
|
|
388
|
+
controlsVisible.value = false;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const handleMouseMove = () => {
|
|
393
|
+
// 鼠标在视频上移动时显示控制器
|
|
394
|
+
showControls();
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// 生命周期钩子
|
|
398
|
+
onMounted(() => {
|
|
399
|
+
// 初始化组件
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
onBeforeUnmount(() => {
|
|
403
|
+
if (controlsTimeout.value) {
|
|
404
|
+
clearTimeout(controlsTimeout.value);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
</script>
|
|
408
|
+
|
|
409
|
+
<style scoped>
|
|
410
|
+
.ebiz-video-player {
|
|
411
|
+
position: relative;
|
|
412
|
+
width: 100%;
|
|
413
|
+
background-color: #000;
|
|
414
|
+
overflow: hidden;
|
|
415
|
+
border-radius: 4px;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.ebiz-video {
|
|
419
|
+
width: 100%;
|
|
420
|
+
height: 100%;
|
|
421
|
+
object-fit: contain;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.ebiz-video-controls {
|
|
425
|
+
position: absolute;
|
|
426
|
+
top: 0;
|
|
427
|
+
left: 0;
|
|
428
|
+
right: 0;
|
|
429
|
+
bottom: 0;
|
|
430
|
+
background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 70%, rgba(0,0,0,0.3) 100%);
|
|
431
|
+
display: flex;
|
|
432
|
+
flex-direction: column;
|
|
433
|
+
justify-content: space-between;
|
|
434
|
+
opacity: 1;
|
|
435
|
+
transition: opacity 0.3s ease;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.controls-hidden {
|
|
439
|
+
opacity: 0;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.ebiz-video-header {
|
|
443
|
+
padding: 16px;
|
|
444
|
+
display: flex;
|
|
445
|
+
align-items: center;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.ebiz-video-title {
|
|
449
|
+
color: #fff;
|
|
450
|
+
font-size: 16px;
|
|
451
|
+
text-shadow: 0 0 2px rgba(0,0,0,0.5);
|
|
452
|
+
overflow: hidden;
|
|
453
|
+
text-overflow: ellipsis;
|
|
454
|
+
white-space: nowrap;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.ebiz-video-center-play {
|
|
458
|
+
position: absolute;
|
|
459
|
+
top: 50%;
|
|
460
|
+
left: 50%;
|
|
461
|
+
transform: translate(-50%, -50%);
|
|
462
|
+
color: rgba(255, 255, 255, 0.8);
|
|
463
|
+
cursor: pointer;
|
|
464
|
+
z-index: 2;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.ebiz-video-footer {
|
|
468
|
+
padding: 16px;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
.ebiz-video-progress {
|
|
472
|
+
margin-bottom: 16px;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.ebiz-video-progress-bar {
|
|
476
|
+
position: relative;
|
|
477
|
+
height: 4px;
|
|
478
|
+
background-color: rgba(255, 255, 255, 0.3);
|
|
479
|
+
border-radius: 2px;
|
|
480
|
+
cursor: pointer;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.ebiz-video-progress-loaded {
|
|
484
|
+
position: absolute;
|
|
485
|
+
top: 0;
|
|
486
|
+
left: 0;
|
|
487
|
+
height: 100%;
|
|
488
|
+
background-color: rgba(255, 255, 255, 0.5);
|
|
489
|
+
border-radius: 2px;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.ebiz-video-progress-played {
|
|
493
|
+
position: absolute;
|
|
494
|
+
top: 0;
|
|
495
|
+
left: 0;
|
|
496
|
+
height: 100%;
|
|
497
|
+
background-color: #0052d9;
|
|
498
|
+
border-radius: 2px;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.ebiz-video-progress-handle {
|
|
502
|
+
position: absolute;
|
|
503
|
+
top: 50%;
|
|
504
|
+
width: 12px;
|
|
505
|
+
height: 12px;
|
|
506
|
+
background-color: #fff;
|
|
507
|
+
border-radius: 50%;
|
|
508
|
+
transform: translate(-50%, -50%);
|
|
509
|
+
box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.ebiz-video-controls-buttons {
|
|
513
|
+
display: flex;
|
|
514
|
+
align-items: center;
|
|
515
|
+
justify-content: space-between;
|
|
516
|
+
color: #fff;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.ebiz-video-control-button {
|
|
520
|
+
padding: 8px;
|
|
521
|
+
cursor: pointer;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.ebiz-video-time {
|
|
525
|
+
font-size: 14px;
|
|
526
|
+
color: #fff;
|
|
527
|
+
text-shadow: 0 0 2px rgba(0,0,0,0.5);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.ebiz-video-loading {
|
|
531
|
+
position: absolute;
|
|
532
|
+
top: 50%;
|
|
533
|
+
left: 50%;
|
|
534
|
+
transform: translate(-50%, -50%);
|
|
535
|
+
color: #fff;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.ebiz-video-error {
|
|
539
|
+
position: absolute;
|
|
540
|
+
top: 50%;
|
|
541
|
+
left: 50%;
|
|
542
|
+
transform: translate(-50%, -50%);
|
|
543
|
+
display: flex;
|
|
544
|
+
flex-direction: column;
|
|
545
|
+
align-items: center;
|
|
546
|
+
color: #ff4d4f;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.ebiz-video-error span {
|
|
550
|
+
margin-top: 8px;
|
|
551
|
+
font-size: 14px;
|
|
552
|
+
color: #fff;
|
|
553
|
+
}
|
|
554
554
|
</style>
|