-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92ca197
commit 4b679e0
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters