feat: 新增视频组件(支持混合模式视频背景透明)

This commit is contained in:
tnt group 2022-09-18 13:07:44 +08:00
parent 5c5c0b02df
commit 25077b91ca
6 changed files with 174 additions and 1 deletions

View File

@ -0,0 +1,21 @@
import { PublicConfigClass } from '@/packages/public'
import { CreateComponentType } from '@/packages/index.d'
import { VideoConfig } from './index'
import cloneDeep from 'lodash/cloneDeep'
export const option = {
// 视频路径
dataset: '',
// 适应方式
fit: 'contain',
// 圆角
borderRadius: 0,
// 透明度
opacity: 1
}
export default class Config extends PublicConfigClass implements CreateComponentType {
public key = VideoConfig.key
public chartConfig = cloneDeep(VideoConfig)
public option = cloneDeep(option)
}

View File

@ -0,0 +1,64 @@
<template>
<collapse-item name="属性" :expanded="true">
<setting-item-box name="路径" :alone="true">
<setting-item>
<n-input v-model:value="optionData.dataset" size="small"></n-input>
</setting-item>
<setting-item>
<n-upload action="https://www.mocky.io/v2/5e4bafc63100007100d8b70f" @finish="handleFinish">
<n-button size="small">本地上传</n-button>
</n-upload>
</setting-item>
</setting-item-box>
<setting-item-box name="样式">
<setting-item name="类型">
<n-select v-model:value="optionData.fit" size="small" :options="fitList"></n-select>
</setting-item>
<setting-item name="圆角">
<n-input-number
v-model:value="optionData.borderRadius"
size="small"
:min="0"
placeholder="圆角"
></n-input-number>
</setting-item>
</setting-item-box>
</collapse-item>
</template>
<script setup lang="ts">
import { PropType } from 'vue'
import { option } from './config'
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
required: true
}
})
//
const fitList = [
{
value: 'fill',
label: 'fill'
},
{
value: 'contain',
label: 'contain'
},
{
value: 'cover',
label: 'cover'
},
{
value: 'scale-down',
label: 'scale-down'
},
{
value: 'none',
label: 'none'
}
]
</script>

View File

@ -0,0 +1,14 @@
import image from '@/assets/images/chart/informations/photo.png'
import { ConfigType, PackagesCategoryEnum } from '@/packages/index.d'
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
export const VideoConfig: ConfigType = {
key: 'Video',
chartKey: 'VVideo',
conKey: 'VCVideo',
title: '视频',
category: ChatCategoryEnum.MORE,
categoryName: ChatCategoryEnumName.MORE,
package: PackagesCategoryEnum.INFORMATIONS,
image
}

View File

@ -0,0 +1,69 @@
<template>
<div :style="getStyle(borderRadius)">
<video
class="video-background"
preload="auto"
loop
playsinline
autoplay
muted
src="https://video.699pic.com/videos/76/09/36/b_D4DKnb48qdCI1631760936.mp4"
:width="w"
:height="h"
></video>
</div>
</template>
<script setup lang="ts">
import { PropType, shallowReactive, watch, toRefs } from 'vue'
import { useChartDataFetch } from '@/hooks'
import { CreateComponentType } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { option } from './config'
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true
}
})
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)
const option = shallowReactive({
dataset: ''
})
const getStyle = (radius: number) => {
return {
borderRadius: `${radius}px`,
overflow: 'hidden'
}
}
//
watch(
() => props.chartConfig.option.dataset,
(newData: any) => {
option.dataset = newData
},
{
immediate: true,
deep: false
}
)
//
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
option.dataset = newData
})
</script>
<style lang="scss" scoped>
.video-background {
object-fit: cover;
mix-blend-mode: screen;
opacity: 1;
}
</style>

View File

@ -1,4 +1,5 @@
import { TextCloudConfig } from './TextCloud/index'
import { ImageConfig } from './Image/index'
import { VideoConfig } from './Video/index'
export default [ImageConfig, TextCloudConfig]
export default [ImageConfig, VideoConfig, TextCloudConfig]

View File

@ -69,6 +69,10 @@ const select = computed(() => {
@include go(shape-box) {
position: absolute;
cursor: move;
//
mix-blend-mode: screen;
/* 锚点 */
.shape-point {
z-index: 1;