feat: 图片组件增加尺寸适应方式

This commit is contained in:
wangjiahao 2022-06-24 17:59:20 +08:00
parent b1b1e0f58e
commit 028c03733c
8 changed files with 104 additions and 22 deletions

View File

@ -105,7 +105,7 @@
</div> </div>
<div v-if="attrShow('borderColor')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrShow('borderColor')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<div style="width: 16px;height: 18px"> <div style="width: 16px;height: 18px">
<el-tooltip content="边框颜色"> <el-tooltip :content="$t('panel.border_color')">
<i class="iconfont icon-huabi" @click="goBoardColor" /> <i class="iconfont icon-huabi" @click="goBoardColor" />
</el-tooltip> </el-tooltip>
<div :style="boardDivColor" /> <div :style="boardDivColor" />
@ -115,7 +115,7 @@
<div v-if="attrShow('backgroundColor')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrShow('backgroundColor')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<div style="width: 16px;height: 18px"> <div style="width: 16px;height: 18px">
<el-tooltip content="背景颜色"> <el-tooltip :content="$t('panel.background_color')">
<i class="iconfont icon-beijingse1" @click="goBackgroundColor" /> <i class="iconfont icon-beijingse1" @click="goBackgroundColor" />
</el-tooltip> </el-tooltip>
<div :style="backgroundDivColor" /> <div :style="backgroundDivColor" />
@ -123,58 +123,70 @@
</div> </div>
</div> </div>
<div v-if="attrShow('videoLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('videoLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;">
<el-tooltip content="视频信息"> <el-tooltip :content="$t('panel.video_info')">
<VideoLinks :link-info="curComponent.videoLinks" /> <VideoLinks :link-info="curComponent.videoLinks" />
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="attrShow('streamMediaLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('streamMediaLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;">
<el-tooltip content="流媒体信息"> <el-tooltip :content="$t('panel.stream_media_info')">
<StreamMediaLinks :link-info="curComponent.streamMediaLinks" /> <StreamMediaLinks :link-info="curComponent.streamMediaLinks" />
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="attrShow('frameLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;"> <div v-if="attrShow('frameLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 2px;">
<el-tooltip content="网页地址"> <el-tooltip :content="$t('panel.web_addr')">
<FrameLinks :link-info="curComponent.frameLinks" /> <FrameLinks :link-info="curComponent.frameLinks" />
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="attrShow('date-format')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrShow('date-format')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<el-tooltip content="日期格式"> <el-tooltip :content="$t('panel.data_format')">
<date-format :format-info="curComponent.formatInfo" /> <date-format :format-info="curComponent.formatInfo" />
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="attrShow('deTabStyle')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrShow('deTabStyle')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<el-tooltip content="tab内部样式"> <el-tooltip :content="$t('panel.tab_inner_style')">
<tab-style :style-info="styleInfo" /> <tab-style :style-info="styleInfo" />
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="attrShow('titlePostion')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrShow('titlePostion')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<el-tooltip content="标题位置"> <el-tooltip :content="$t('panel.title_position')">
<title-postion :element-type="elementType" :show-vertical="showVertical" :style-info="styleInfo" /> <title-postion :element-type="elementType" :show-vertical="showVertical" :style-info="styleInfo" />
</el-tooltip> </el-tooltip>
</div> </div>
<!--tab 内部组件样式--> <!--tab 内部组件样式-->
<div v-if="attrTabShow('videoLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrTabShow('videoLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<el-tooltip content="视频信息"> <el-tooltip :content="$t('panel.video_info')">
<VideoLinks :attr-position="'tab'" :link-info="curActiveTabInner.videoLinks" /> <VideoLinks :attr-position="'tab'" :link-info="curActiveTabInner.videoLinks" />
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="attrTabShow('streamMediaLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrTabShow('streamMediaLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<el-tooltip content="流媒体信息"> <el-tooltip :content="$t('panel.stream_media_info')">
<StreamMediaLinks :attr-position="'tab'" :link-info="curActiveTabInner.streamMediaLinks" /> <StreamMediaLinks :attr-position="'tab'" :link-info="curActiveTabInner.streamMediaLinks" />
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="attrTabShow('frameLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;"> <div v-if="attrTabShow('frameLinks')" style="width: 20px;float: left;margin-top: 2px;margin-left: 10px;">
<el-tooltip content="网页地址"> <el-tooltip :content="$t('panel.web_addr')">
<FrameLinks :attr-position="'tab'" :link-info="curActiveTabInner.frameLinks" /> <FrameLinks :attr-position="'tab'" :link-info="curActiveTabInner.frameLinks" />
</el-tooltip> </el-tooltip>
</div> </div>
<div v-if="attrShow('adaptation')" style="width: 100px;margin-top: 2px;margin-right:2px;float: left">
<el-tooltip :content="$t('panel.pic_size')">
<el-select v-model="styleInfo.adaptation" size="mini" @change="styleChange">
<el-option
v-for="item in pictureAdaptation"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-tooltip>
</div>
</div> </div>
</el-card> </el-card>
</template> </template>
@ -257,12 +269,23 @@ export default {
value: '5', value: '5',
label: '5' label: '5'
}], }],
pictureAdaptation: [{
value: 'adaptation',
label: this.$t('panel.pic_adaptation')
}, {
value: 'equiratio',
label: this.$t('panel.pic_equiratio')
}, {
value: 'original',
label: this.$t('panel.pic_original')
}],
// //
'picture-add': [ 'picture-add': [
'borderStyle', 'borderStyle',
'borderWidth', 'borderWidth',
'borderColor', 'borderColor',
'hyperlinks' 'hyperlinks',
'adaptation'
], ],
// //
'custom': [ 'custom': [
@ -480,6 +503,7 @@ export default {
.el-card-main { .el-card-main {
height: 34px; height: 34px;
z-index: 10; z-index: 10;
padding-right: 2px;
position: absolute; position: absolute;
} }

View File

@ -1,8 +1,8 @@
<template> <template>
<div style="overflow: hidden;width: 100%;height: 100%;"> <div style="overflow: hidden;width: 100%;height: 100%;">
<img v-if="!showLink" :src="element.propValue"> <img v-if="!showLink" :style="imageAdapter" :src="element.propValue">
<a v-if="showLink" :title="element.hyperlinks.content " :target="element.hyperlinks.openMode " :href="element.hyperlinks.content "> <a v-if="showLink" :title="element.hyperlinks.content " :target="element.hyperlinks.openMode " :href="element.hyperlinks.content ">
<img :src="element.propValue"> <img :style="imageAdapter" :src="element.propValue">
</a> </a>
</div> </div>
</template> </template>
@ -23,14 +23,29 @@ export default {
computed: { computed: {
showLink() { showLink() {
return this.editMode === 'preview' && this.element && this.element.hyperlinks && this.element.hyperlinks.enable return this.editMode === 'preview' && this.element && this.element.hyperlinks && this.element.hyperlinks.enable
},
imageAdapter() {
const style = {
position: 'relative',
width: '100%',
height: '100%'
}
if (this.element.style.adaptation === 'original') {
style.width = 'auto'
style.height = 'auto'
} else if (this.element.style.adaptation === 'equiratio') {
style.height = 'auto'
}
return style
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
img { .pic-main{
width: 100%; overflow: hidden;
height: 100%; width: 100%;
height: 100%;
} }
</style> </style>

View File

@ -56,6 +56,11 @@ export const commonStyle = {
borderRadius: 0 borderRadius: 0
} }
export const PIC_STYLE = {
...commonStyle,
adaptation: 'adaptation'
}
export const commonAttr = { export const commonAttr = {
animations: [], animations: [],
events: {}, events: {},
@ -163,7 +168,7 @@ export const assistList = [
export const pictureList = [ export const pictureList = [
{ {
id: '20001', id: '20001',
component: 'picture-add', component: 'Picture',
type: 'picture-add', type: 'picture-add',
label: '图片', label: '图片',
icon: 'iconfont icon-picture', icon: 'iconfont icon-picture',
@ -457,7 +462,7 @@ const list = [
}, },
{ {
id: '20001', id: '20001',
component: 'picture-add', component: 'Picture',
type: 'picture-add', type: 'picture-add',
label: '图片', label: '图片',
icon: 'iconfont icon-picture', icon: 'iconfont icon-picture',
@ -466,7 +471,8 @@ const list = [
hyperlinks: HYPERLINKS, hyperlinks: HYPERLINKS,
style: { style: {
width: 400, width: 400,
height: 200 height: 200,
adaptation: 'adaptation'
}, },
x: 1, x: 1,
y: 1, y: 1,

View File

@ -123,6 +123,10 @@ export function panelDataPrepare(componentData, componentStyle, callback) {
item.commonBackground.enable = false item.commonBackground.enable = false
item.commonBackground.backgroundType = 'innerImage' item.commonBackground.backgroundType = 'innerImage'
} }
// picture component
if (item.component && item.component === 'Picture') {
item.style.adaptation = item.style.adaptation || 'adaptation'
}
}) })
// 初始化密度为最高密度 // 初始化密度为最高密度
componentStyle.aidedDesign.matrixBase = 4 componentStyle.aidedDesign.matrixBase = 4

View File

@ -1464,6 +1464,17 @@ export default {
sure_bt: 'Confirm' sure_bt: 'Confirm'
}, },
panel: { panel: {
pic_adaptation: 'Adaptation',
pic_equiratio: 'Equiratio',
pic_original: 'Original',
pic_size: 'Image Size',
web_addr: 'Web Address',
stream_media_info: 'Stream Media Info',
video_info: 'Video Info',
title_position: 'Title Position',
tab_inner_style: 'Tab Inner Style',
data_format: 'Data Format',
border_color: 'Border Color',
theme_change_warn: 'Subject Change', theme_change_warn: 'Subject Change',
theme_change_tips: 'Changing the theme will overwrite the view related theme attributes. It is recommended to back up in advance. Do you want to continue the replacement?', theme_change_tips: 'Changing the theme will overwrite the view related theme attributes. It is recommended to back up in advance. Do you want to continue the replacement?',
theme_color_change_warn: 'Theme Color Change', theme_color_change_warn: 'Theme Color Change',

View File

@ -1465,6 +1465,17 @@ export default {
sure_bt: '確定' sure_bt: '確定'
}, },
panel: { panel: {
pic_adaptation: '适应组件',
pic_equiratio: '等比适应',
pic_original: '原始尺寸',
pic_size: '图片尺寸',
web_addr: '网页地址',
stream_media_info: '流媒体信息',
video_info: '视频信息',
title_position: '标题位置',
tab_inner_style: 'tab内部样式',
data_format: '日期格式',
border_color: '边框颜色',
theme_change_warn: '主題更換', theme_change_warn: '主題更換',
theme_change_tips: '更換主題將會覆蓋視圖相關主題屬性建議提前備份,是否繼續更換?', theme_change_tips: '更換主題將會覆蓋視圖相關主題屬性建議提前備份,是否繼續更換?',
theme_color_change_warn: '主題色更換', theme_color_change_warn: '主題色更換',

View File

@ -1472,6 +1472,17 @@ export default {
sure_bt: '确定' sure_bt: '确定'
}, },
panel: { panel: {
pic_adaptation: '适应组件',
pic_equiratio: '等比适应',
pic_original: '原始尺寸',
pic_size: '图片尺寸',
web_addr: '网页地址',
stream_media_info: '流媒体信息',
video_info: '视频信息',
title_position: '标题位置',
tab_inner_style: 'tab内部样式',
data_format: '日期格式',
border_color: '边框颜色',
theme_change_warn: '主题更换', theme_change_warn: '主题更换',
theme_change_tips: '更换主题将会覆盖视图相关主题属性建议提前备份,是否继续更换?', theme_change_tips: '更换主题将会覆盖视图相关主题属性建议提前备份,是否继续更换?',
theme_color_change_warn: '主题色更换', theme_color_change_warn: '主题色更换',

View File

@ -341,7 +341,7 @@ import { deepCopy, matrixBaseChange } from '@/components/canvas/utils/utils'
import componentList, { import componentList, {
BASE_MOBILE_STYLE, BASE_MOBILE_STYLE,
COMMON_BACKGROUND, COMMON_BACKGROUND,
HYPERLINKS HYPERLINKS, PIC_STYLE
} from '@/components/canvas/custom-component/component-list' // } from '@/components/canvas/custom-component/component-list' //
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { uuid } from 'vue-uuid' import { uuid } from 'vue-uuid'
@ -967,7 +967,7 @@ export default {
propValue: fileResult, propValue: fileResult,
commonBackground: deepCopy(COMMON_BACKGROUND), commonBackground: deepCopy(COMMON_BACKGROUND),
style: { style: {
...commonStyle ...PIC_STYLE
} }
} }
component.auxiliaryMatrix = false component.auxiliaryMatrix = false