From a5ef8a940cf7427570b55b336e6a613b7a8d28fd Mon Sep 17 00:00:00 2001 From: pipipi-pikachu <1171051090@qq.com> Date: Thu, 14 Jan 2021 09:42:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=BB=E7=AC=94=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/WritingBoard.vue | 18 ++++-- src/views/Screen/WritingBoardTool.vue | 82 ++++++++++++++++----------- src/views/Screen/index.vue | 9 +-- 3 files changed, 66 insertions(+), 43 deletions(-) diff --git a/src/components/WritingBoard.vue b/src/components/WritingBoard.vue index 2e2606c..b8df4aa 100644 --- a/src/components/WritingBoard.vue +++ b/src/components/WritingBoard.vue @@ -12,20 +12,22 @@ class="pen" :style="{ left: mouse.x - penSize / 2 + 'px', - top: mouse.y - 50 + penSize / 2 + 'px', + top: mouse.y - 36 + penSize / 2 + 'px', color: color, }" v-if="mouseInCanvas && model === 'pen'" - > + >
+ > @@ -239,7 +241,15 @@ export default defineComponent({ z-index: 9; .icon { - filter: drop-shadow(2px 2px 2px #999); + filter: drop-shadow(2px 2px 2px #555); } } +.eraser { + display: flex; + justify-content: center; + align-items: center; + border-radius: 50%; + border: 4px solid rgba($color: #555, $alpha: .15); + color: rgba($color: #555, $alpha: .75); +} \ No newline at end of file diff --git a/src/views/Screen/WritingBoardTool.vue b/src/views/Screen/WritingBoardTool.vue index e6f632e..45b3e2d 100644 --- a/src/views/Screen/WritingBoardTool.vue +++ b/src/views/Screen/WritingBoardTool.vue @@ -1,27 +1,29 @@ @@ -34,37 +36,53 @@ const writingBoardColors = ['#000000', '#ffffff', '#1e497b', '#4e81bb', '#e2534d export default defineComponent({ name: 'writing-board-tool', - emits: ['close', 'update:visible'], components: { WritingBoard, }, - props: { - visible: { - type: Boolean, - default: false, - }, - }, setup(props, { emit }) { const writingBoardRef = ref() + const writingBoardVisible = ref(false) const writingBoardColor = ref('#e2534d') const writingBoardModel = ref('pen') - const close = () => { + const changePen = () => { + if(!writingBoardVisible.value) writingBoardVisible.value = true + writingBoardModel.value = 'pen' + emit('close') + } + + const changeEraser = () => { + writingBoardModel.value = 'eraser' + emit('close') + } + + const clearCanvas = () => { + writingBoardRef.value.clearCanvas() + emit('close') + } + + const changeColor = (color: string) => { + if(writingBoardModel.value !== 'pen') writingBoardModel.value = 'pen' + writingBoardColor.value = color emit('close') } const closeWritingBoard = () => { - emit('update:visible', false) + writingBoardVisible.value = false emit('close') } return { writingBoardRef, + writingBoardVisible, writingBoardColors, writingBoardColor, writingBoardModel, + changePen, + changeEraser, + clearCanvas, + changeColor, closeWritingBoard, - close, } }, }) diff --git a/src/views/Screen/index.vue b/src/views/Screen/index.vue index b553be6..cfbe12b 100644 --- a/src/views/Screen/index.vue +++ b/src/views/Screen/index.vue @@ -50,12 +50,9 @@ - + @@ -95,7 +92,6 @@ export default defineComponent({ const slideThumbnailModelVisible = ref(false) - const writingBoardVisible = ref(false) const writingBoardToolVisible = ref(false) const setSlideContentSize = () => { @@ -233,7 +229,6 @@ export default defineComponent({ execNext, slideThumbnailModelVisible, turnSlideToIndex, - writingBoardVisible, writingBoardToolVisible, } },