mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
feat: 新增视频组件(支持混合模式视频背景透明)
This commit is contained in:
parent
5c5c0b02df
commit
25077b91ca
21
src/packages/components/Informations/Mores/Video/config.ts
Normal file
21
src/packages/components/Informations/Mores/Video/config.ts
Normal 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)
|
||||||
|
}
|
64
src/packages/components/Informations/Mores/Video/config.vue
Normal file
64
src/packages/components/Informations/Mores/Video/config.vue
Normal 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>
|
14
src/packages/components/Informations/Mores/Video/index.ts
Normal file
14
src/packages/components/Informations/Mores/Video/index.ts
Normal 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
|
||||||
|
}
|
69
src/packages/components/Informations/Mores/Video/index.vue
Normal file
69
src/packages/components/Informations/Mores/Video/index.vue
Normal 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>
|
@ -1,4 +1,5 @@
|
|||||||
import { TextCloudConfig } from './TextCloud/index'
|
import { TextCloudConfig } from './TextCloud/index'
|
||||||
import { ImageConfig } from './Image/index'
|
import { ImageConfig } from './Image/index'
|
||||||
|
import { VideoConfig } from './Video/index'
|
||||||
|
|
||||||
export default [ImageConfig, TextCloudConfig]
|
export default [ImageConfig, VideoConfig, TextCloudConfig]
|
||||||
|
@ -69,6 +69,10 @@ const select = computed(() => {
|
|||||||
@include go(shape-box) {
|
@include go(shape-box) {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
cursor: move;
|
cursor: move;
|
||||||
|
|
||||||
|
// 混合模式
|
||||||
|
mix-blend-mode: screen;
|
||||||
|
|
||||||
/* 锚点 */
|
/* 锚点 */
|
||||||
.shape-point {
|
.shape-point {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user