Commit 16b753e0 authored by 张晨辰's avatar 张晨辰

feat: image类型节点增加原图高宽度属性

parent c0c6b795
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
placement="top" placement="top"
trigger="hover" trigger="hover"
width="auto" width="auto"
:disabled="!legalUrl"
:content="url" :content="url"
> >
<img style="max-width: 200px;" v-if="url" :src="url" alt="" /> <img style="max-width: 200px;" v-if="url" :src="url" alt="" />
...@@ -51,6 +52,9 @@ export default { ...@@ -51,6 +52,9 @@ export default {
} else { } else {
return ''; return '';
} }
},
legalUrl: function() {
return (this.swvalue + '').indexOf('//') > -1;
} }
} }
}; };
......
...@@ -495,7 +495,9 @@ export const projectStore = { ...@@ -495,7 +495,9 @@ export const projectStore = {
}); });
if (_props.source) { if (_props.source) {
if (!_props.width || !_props.height) { // imageWidth imageHeight
// 设置image类型节点的原图高宽度
if (!_props.imageWidth || !_props.imageHeight) {
let _url = _props.source; //_source.value; let _url = _props.source; //_source.value;
if (_url.indexOf('asset://') === 0) { if (_url.indexOf('asset://') === 0) {
let uuid = _url.split('//')[1]; let uuid = _url.split('//')[1];
...@@ -505,8 +507,8 @@ export const projectStore = { ...@@ -505,8 +507,8 @@ export const projectStore = {
let _img = new Image(); let _img = new Image();
_img.src = _url; _img.src = _url;
_img.onload = function () { _img.onload = function () {
_props.width = _img.width; _props.imageWidth = _img.width;
_props.height = _img.height; _props.imageHeight = _img.height;
commit('modifyActiveView', { commit('modifyActiveView', {
properties: _props properties: _props
}); });
......
...@@ -265,6 +265,11 @@ export const styles = { ...@@ -265,6 +265,11 @@ export const styles = {
}); });
} }
if (component.type === 'image') {
cmpSelfProps.width = cmpSelfProps.width || cmpSelfProps.imageWidth;
cmpSelfProps.height = cmpSelfProps.height || cmpSelfProps.imageHeight;
}
// 获取拖拽组件的样式,只生成operatProps中的属性 // 获取拖拽组件的样式,只生成operatProps中的属性
if (onlyOpera) { if (onlyOpera) {
_.forIn(cmpSelfProps, (val, key) => { _.forIn(cmpSelfProps, (val, key) => {
......
...@@ -194,6 +194,24 @@ export default { ...@@ -194,6 +194,24 @@ export default {
title: '来源', title: '来源',
type: 'source', type: 'source',
value: '' value: ''
},
imageWidth: {
title: '原图宽度',
type: 'input',
value: '',
desc: '原图片的宽度',
props: {
disabled: true
}
},
imageHeight: {
title: '原图高度',
type: 'input',
value: '',
desc: '原图片的高度',
props: {
disabled: true
}
} }
}, },
rect: { rect: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment