feat:【mall】video-player 优化

This commit is contained in:
YunaiV
2025-11-01 21:42:23 +08:00
parent 37afa49011
commit d7cea8be39
3 changed files with 13 additions and 27 deletions

View File

@@ -2,23 +2,18 @@ import type { ComponentStyle, DiyComponent } from '../../../util';
/** 视频播放属性 */ /** 视频播放属性 */
export interface VideoPlayerProperty { export interface VideoPlayerProperty {
// 视频链接 videoUrl: string; // 视频链接
videoUrl: string; posterUrl: string; // 封面链接
// 封面链接 autoplay: boolean; // 是否自动播放
posterUrl: string; style: VideoPlayerStyle; // 组件样式
// 是否自动播放
autoplay: boolean;
// 组件样式
style: VideoPlayerStyle;
} }
// 视频播放样式 /** 视频播放样式 */
export interface VideoPlayerStyle extends ComponentStyle { export interface VideoPlayerStyle extends ComponentStyle {
// 视频高度 height: number; // 视频高度
height: number;
} }
// 定义组件 /** 定义组件 */
export const component = { export const component = {
id: 'VideoPlayer', id: 'VideoPlayer',
name: '视频播放', name: '视频播放',

View File

@@ -11,13 +11,13 @@ defineProps<{ property: VideoPlayerProperty }>();
<template> <template>
<div class="w-full" :style="{ height: `${property.style.height}px` }"> <div class="w-full" :style="{ height: `${property.style.height}px` }">
<ElImage <ElImage
class="w-full" class="block h-full w-full"
:src="property.posterUrl" :src="property.posterUrl"
v-if="property.posterUrl" v-if="property.posterUrl"
/> />
<video <video
v-else v-else
class="w-full" class="h-full w-full"
:src="property.videoUrl" :src="property.videoUrl"
:poster="property.posterUrl" :poster="property.posterUrl"
:autoplay="property.autoplay" :autoplay="property.autoplay"
@@ -25,12 +25,3 @@ defineProps<{ property: VideoPlayerProperty }>();
></video> ></video>
</div> </div>
</template> </template>
<style scoped lang="scss">
/* 图片 */
img {
display: block;
width: 100%;
height: 100%;
}
</style>

View File

@@ -9,11 +9,13 @@ import UploadImg from '#/components/upload/image-upload.vue';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// 视频播放属性面板 /** 视频播放属性面板 */
defineOptions({ name: 'VideoPlayerProperty' }); defineOptions({ name: 'VideoPlayerProperty' });
const props = defineProps<{ modelValue: VideoPlayerProperty }>(); const props = defineProps<{ modelValue: VideoPlayerProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>
@@ -59,5 +61,3 @@ const formData = useVModel(props, 'modelValue', emit);
</ElForm> </ElForm>
</ComponentContainerProperty> </ComponentContainerProperty>
</template> </template>
<style scoped lang="scss"></style>