Skip to content

Commit

Permalink
fix: 绘制元素状态退出 (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchenguang1998 authored Jun 6, 2024
1 parent 61dc65b commit 4533e78
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/components/tools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ const state = reactive({
// let drawHandler = null;
const addText = (option) => {
cancelDraw();
const text = new fabric.IText(t('everything_is_fine'), {
...defaultPosition,
...option,
Expand All @@ -269,6 +270,7 @@ const addText = (option) => {
// };
const addTextBox = (option) => {
cancelDraw();
const text = new fabric.Textbox(t('everything_goes_well'), {
...defaultPosition,
...option,
Expand All @@ -286,6 +288,7 @@ const addTextBox = (option) => {
};
const addTriangle = (option) => {
cancelDraw();
const triangle = new fabric.Triangle({
...defaultPosition,
...option,
Expand All @@ -303,6 +306,7 @@ const addTriangle = (option) => {
};
const addPolygon = (option) => {
cancelDraw();
const polygon = new fabric.Polygon(getPolygonVertices(5, 200), {
...defaultPosition,
...option,
Expand All @@ -328,7 +332,7 @@ const addPolygon = (option) => {
};
const addCircle = (option) => {
console.log(canvasEditor);
cancelDraw();
const circle = new fabric.Circle({
...defaultPosition,
...option,
Expand All @@ -345,6 +349,7 @@ const addCircle = (option) => {
};
const addRect = (option) => {
cancelDraw();
const rect = new fabric.Rect({
...defaultPosition,
...option,
Expand Down Expand Up @@ -496,6 +501,20 @@ onMounted(() => {
});
});
});
// 退出绘制状态
const cancelDraw = () => {
if (!state.isDrawingLineMode) return;
state.isDrawingLineMode = false;
state.lineType = '';
canvasEditor.setMode(false);
endConflictTools();
ensureObjectSelEvStatus(true, true);
};
onDeactivated(() => {
cancelDraw();
});
</script>

<style scoped lang="less">
Expand Down

0 comments on commit 4533e78

Please sign in to comment.