Skip to content

Commit

Permalink
feat: 新增隐藏元素功能 (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchenguang1998 authored May 14, 2024
1 parent 92ca197 commit 4b679e0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
43 changes: 43 additions & 0 deletions src/components/hide.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--
* @Author: wuchenguang1998
* @Date: 2024-05-13 22:34:03
* @LastEditors: wuchenguang1998
* @LastEditTime: 2024-05-13 23:40:48
* @Description: 隐藏或显示元素
-->

<template>
<Tooltip :content="$t('quick.hide')" v-if="mixinState.mSelectMode === 'one'">
<Button v-if="isHide" @click="doHide(false)" icon="md-eye-off" type="text"></Button>
<Button v-else @click="doHide(true)" icon="md-eye" type="text"></Button>
</Tooltip>
</template>

<script setup name="Hide">
import useSelect from '@/hooks/select';
import { onBeforeUnmount, onMounted } from 'vue';
const { mixinState, canvasEditor } = useSelect();
const isHide = ref(false);
const doHide = (hide) => {
// 修改visible属性
const activeObject = canvasEditor.canvas.getActiveObject();
activeObject.set('visible', !hide);
canvasEditor.canvas.requestRenderAll();
isHide.value = hide;
};
const handleSelected = () => {
const activeObject = canvasEditor.canvas.getActiveObject();
isHide.value = !activeObject.visible;
};
onMounted(() => {
canvasEditor.on('selectOne', handleSelected);
});
onBeforeUnmount(() => {
canvasEditor.off('selectOne', handleSelected);
});
</script>
5 changes: 3 additions & 2 deletions src/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"quick": {
"del": "删除",
"copy": "复制",
"lock": "锁定"
"lock": "锁定",
"hide": "隐藏"
},
"flip": {
"x": "水平翻转",
Expand Down Expand Up @@ -214,4 +215,4 @@
"myMaterial": {
"uploadBtn": "上传素材"
}
}
}
2 changes: 2 additions & 0 deletions src/views/home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<imgStroke />
<div class="attr-item">
<lock></lock>
<hide></hide>
<dele></dele>
<clone></clone>
</div>
Expand Down Expand Up @@ -159,6 +160,7 @@ import group from '@/components/group.vue';
import zoom from '@/components/zoom.vue';
import dragMode from '@/components/dragMode.vue';
import lock from '@/components/lock.vue';
import hide from '@/components/hide.vue';
import dele from '@/components/del.vue';
import waterMark from '@/components/waterMark.vue';
import login from '@/components/login';
Expand Down

0 comments on commit 4b679e0

Please sign in to comment.