perf: 优化视频组件

This commit is contained in:
奔跑的面条 2022-09-22 19:38:35 +08:00
parent a48bdd08ff
commit b9e3053fe3
6 changed files with 5 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -9,8 +9,6 @@ export const option = {
dataset: video, dataset: video,
// 循环播放 // 循环播放
loop: true, loop: true,
// 自动播放
autoplay: true,
// 静音 // 静音
muted: true, muted: true,
// 适应方式 // 适应方式

View File

@ -9,9 +9,6 @@
</setting-item-box> </setting-item-box>
<setting-item-box name="控制"> <setting-item-box name="控制">
<setting-item>
<n-checkbox v-model:checked="optionData.autoplay" size="small">自动播放</n-checkbox>
</setting-item>
<setting-item> <setting-item>
<n-checkbox v-model:checked="optionData.loop" size="small">循环播放</n-checkbox> <n-checkbox v-model:checked="optionData.loop" size="small">循环播放</n-checkbox>
</setting-item> </setting-item>

View File

@ -1,5 +1,5 @@
import image from '@/assets/images/chart/informations/photo.png' import image from '@/assets/images/chart/informations/video.png'
import { ConfigType, PackagesCategoryEnum } from '@/packages/index.d' import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
export const VideoConfig: ConfigType = { export const VideoConfig: ConfigType = {
@ -10,5 +10,6 @@ export const VideoConfig: ConfigType = {
category: ChatCategoryEnum.MORE, category: ChatCategoryEnum.MORE,
categoryName: ChatCategoryEnumName.MORE, categoryName: ChatCategoryEnumName.MORE,
package: PackagesCategoryEnum.INFORMATIONS, package: PackagesCategoryEnum.INFORMATIONS,
chartFrame: ChartFrameEnum.ECHARTS,
image image
} }

View File

@ -7,8 +7,8 @@
preload="auto" preload="auto"
crossOrigin="anonymous" crossOrigin="anonymous"
playsinline playsinline
autoplay
:loop="option.loop" :loop="option.loop"
:autoplay="option.autoplay"
:muted="option.muted" :muted="option.muted"
:width="w" :width="w"
:height="h" :height="h"
@ -47,12 +47,8 @@ watch(
if (!vVideoRef.value) return if (!vVideoRef.value) return
const video: any = vVideoRef.value const video: any = vVideoRef.value
video.loop = option.loop video.loop = option.loop
video.autoplay = option.autoplay
video.muted = option.muted video.muted = option.muted
video.play()
//
!option.autoplay && (video.pause(), (video.currentTime = 0))
option.autoplay && video.play()
}, },
{ {
immediate: true, immediate: true,