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

feat: 新增隐藏元素功能 #388

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading