Skip to content

Commit

Permalink
fix: 修改右侧背景色框回填 (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchenguang1998 authored May 7, 2024
1 parent cbf8b53 commit 63a889c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/core/ServersPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class ServersPlugin {
this.editor.hooksEntity.hookImportAfter.callAsync(jsonFile, () => {
this.canvas.renderAll();
callback && callback();
this.editor.emit('loadJson');
});
});
});
Expand Down
19 changes: 17 additions & 2 deletions src/components/bgBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,26 @@ const setThisColor = () => {
setColor(color.value);
};
// 背景颜色设置
function setColor(color) {
function setColor(c) {
const workspace = canvasEditor.canvas.getObjects().find((item) => item.id === 'workspace');
workspace.set('fill', color);
workspace.set('fill', c);
canvasEditor.canvas.renderAll();
color.value = c;
}
// 加载模板时回显颜色值
const handleChangeColor = () => {
const workspace = canvasEditor.canvas.getObjects().find((item) => item.id === 'workspace');
color.value = workspace.fill;
};
onMounted(() => {
canvasEditor.on('loadJson', handleChangeColor);
});
onUnmounted(() => {
canvasEditor.off('loadJson', handleChangeColor);
});
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
Expand Down

0 comments on commit 63a889c

Please sign in to comment.