Skip to content

Commit

Permalink
feat: update SimpleNode
Browse files Browse the repository at this point in the history
  • Loading branch information
pomelo-nwu committed Oct 26, 2023
1 parent 89064df commit 3a88c8d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ const registerMeta = context => {
label: $i18n.get({ id: 'basic.elements.SimpleNode.registerMeta.FontIcon', dm: '字体图标' }),
value: 'font',
},
{
label: '图片地址',
value: 'image',
},
],
default: icon.type,
},
Expand Down Expand Up @@ -184,10 +188,10 @@ const registerMeta = context => {
label: '方形',
value: 'rect-node',
},
{
label: '菱形',
value: 'diamond-node',
},
// {
// label: '菱形',
// value: 'diamond-node',
// },
],
default: keyshape.type,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,27 @@ const getIconStyleByConfig = (style, data) => {
if (icon.type === 'image') {
return {
fill: 'transparent',
size: [keyshape.size, keyshape.size],
type: 'image',
r: [keyshape.size, keyshape.size],
clip: { r: keyshape.size / 2 },
value: value,
img: value,
visible: true,
};
}

if (icon.type === 'font') {
return {
...icon,
size: keyshape.size / 2,
type: 'font',
fontSize: keyshape.size / 2,
fontFamily: 'iconfont',
value: icons[value] || '',
text: icons[value] || '',
fill: icon.fill || keyshape.fill,
visible: true,
};
}
if (icon.type === 'text') {
return {
...icon,
fontSize: keyshape.size / 4,
fontSize: keyshape.size / 2,
fill: '#fff',
value: value,
text: value,
visible: true,
};
}
return {
Expand All @@ -69,7 +67,7 @@ const getIconStyleByConfig = (style, data) => {
return {
...icon,
visible: false,
value: '',
text: '',
};
};

Expand Down Expand Up @@ -208,6 +206,7 @@ const transform = (nodeConfig: GINodeConfig, reset?: boolean) => {
};
advanced.keyshape = keyshape;
const LABEL_VALUE = getLabel(data, LABEL_KEYS);

const icon = getIconStyleByConfig(advanced, data);
const badges = getBadgesStyleByConfig(advanced, data);

Expand Down Expand Up @@ -263,7 +262,7 @@ const transform = (nodeConfig: GINodeConfig, reset?: boolean) => {
},
},
};
// console.log('keyshape', node.id);

return {
id: node.id,
data: {
Expand All @@ -273,13 +272,23 @@ const transform = (nodeConfig: GINodeConfig, reset?: boolean) => {
labelShape: {
text: label.value || '',
position: label.position || 'bottom',
maxWidth: '400%',
maxLines: LABEL_KEYS.length,
fill: label.fill,
fontSize: label.fontSize,
},
keyShape: {
r: keyshape.size / 2 || 10,
fill: keyshape.fill || 'red',
stroke: keyshape.stroke || 'red',
strokeOpacity: keyshape.strokeOpacity || 1,
fillOpacity: keyshape.fillOpacity,
},
...(icon.visible
? {
iconShape: icon,
}
: {}),
animates: {
update: [
{
Expand Down

0 comments on commit 3a88c8d

Please sign in to comment.