Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turboAdapter.js Cannot destructure property 'x' of 'properties' as it is undefined. #4

Open
caspianchu opened this issue Sep 5, 2023 · 0 comments

Comments

@caspianchu
Copy link

Uncaught (in promise) TypeError: Cannot destructure property 'x' of 'properties' as it is undefined.
at convertFlowElementToNode (turboAdapter.js?t=1693904724052:157:5)
at turboAdapter.js?t=1693904724052:194:20
at Array.forEach ()
at toLogicflowData (turboAdapter.js?t=1693904724052:189:35)
at t2.adapterIn (turboAdapter.js?t=1693904724052:214:15)
at t2.value (logic-flow.js:15:481557)
at Proxy.mounted (FlowChart.vue:15:1)

// 将Turbo元素数据转换为LogicFlow中的Node数据
function convertFlowElementToNode(element) {
const { properties, key, type, bounds } = element;
let {
x, y, text,
} = properties;
if (x === undefined) {
const [{ x: x1, y: y1 }, { x: x2, y: y2 }] = bounds;
x = (x1 + x2) / 2
y = (y1 + y2) / 2
}
const node = {
id: key,
type: TurboTypeMap[type],
x,
y,
text,
properties: {},
};
// 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
const excludeProperties = ['x', 'y', 'text'];
Object.keys(element.properties).forEach(property => {
if (excludeProperties.indexOf(property) === -1) {
node.properties[property] = element.properties[property];
}
});
return node;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant