mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
perf: 画笔交互方式优化
This commit is contained in:
parent
be5daf4e07
commit
60b74013d1
@ -5,16 +5,13 @@
|
|||||||
ref="writingBoardRef"
|
ref="writingBoardRef"
|
||||||
:color="writingBoardColor"
|
:color="writingBoardColor"
|
||||||
:model="writingBoardModel"
|
:model="writingBoardModel"
|
||||||
v-if="writingBoardVisible"
|
|
||||||
v-contextmenu="contextmenus"
|
|
||||||
/>
|
/>
|
||||||
</teleport>
|
</teleport>
|
||||||
|
|
||||||
<div class="tools">
|
<div class="tools">
|
||||||
<div class="btn" @click="changePen()">画笔</div>
|
<div class="btn" :class="{ 'active': writingBoardModel === 'pen' }" @click="changePen()">画笔</div>
|
||||||
<div class="btn" @click="changeEraser()">橡皮擦</div>
|
<div class="btn" :class="{ 'active': writingBoardModel === 'eraser' }" @click="changeEraser()">橡皮</div>
|
||||||
<div class="btn" @click="clearCanvas()">擦除所有墨迹</div>
|
<div class="btn" @click="clearCanvas()">清除墨迹</div>
|
||||||
<div class="btn" @click="closeWritingBoard()">退出画笔</div>
|
|
||||||
<div class="colors">
|
<div class="colors">
|
||||||
<div
|
<div
|
||||||
class="color"
|
class="color"
|
||||||
@ -25,6 +22,7 @@
|
|||||||
@click="changeColor(color)"
|
@click="changeColor(color)"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="btn" @click="closeWritingBoard()">退出画笔</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -32,7 +30,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref } from 'vue'
|
import { defineComponent, ref } from 'vue'
|
||||||
import WritingBoard from '@/components/WritingBoard.vue'
|
import WritingBoard from '@/components/WritingBoard.vue'
|
||||||
import { ContextmenuItem } from '@/components/Contextmenu/types'
|
|
||||||
|
|
||||||
const writingBoardColors = ['#000000', '#ffffff', '#1e497b', '#4e81bb', '#e2534d', '#9aba60', '#8165a0', '#47acc5', '#f9974c']
|
const writingBoardColors = ['#000000', '#ffffff', '#1e497b', '#4e81bb', '#e2534d', '#9aba60', '#8165a0', '#47acc5', '#f9974c']
|
||||||
|
|
||||||
@ -43,68 +40,37 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const writingBoardRef = ref()
|
const writingBoardRef = ref()
|
||||||
const writingBoardVisible = ref(false)
|
|
||||||
const writingBoardColor = ref('#e2534d')
|
const writingBoardColor = ref('#e2534d')
|
||||||
const writingBoardModel = ref('pen')
|
const writingBoardModel = ref('pen')
|
||||||
|
|
||||||
// 切换到画笔状态
|
// 切换到画笔状态
|
||||||
const changePen = () => {
|
const changePen = () => {
|
||||||
if (!writingBoardVisible.value) writingBoardVisible.value = true
|
|
||||||
writingBoardModel.value = 'pen'
|
writingBoardModel.value = 'pen'
|
||||||
emit('close')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换到橡皮状态
|
// 切换到橡皮状态
|
||||||
const changeEraser = () => {
|
const changeEraser = () => {
|
||||||
writingBoardModel.value = 'eraser'
|
writingBoardModel.value = 'eraser'
|
||||||
emit('close')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清除画布上的墨迹
|
// 清除画布上的墨迹
|
||||||
const clearCanvas = () => {
|
const clearCanvas = () => {
|
||||||
writingBoardRef.value.clearCanvas()
|
writingBoardRef.value.clearCanvas()
|
||||||
emit('close')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改画笔颜色,如果当前不处于画笔状态则先切换到画笔状态
|
// 修改画笔颜色,如果当前不处于画笔状态则先切换到画笔状态
|
||||||
const changeColor = (color: string) => {
|
const changeColor = (color: string) => {
|
||||||
if (writingBoardModel.value !== 'pen') writingBoardModel.value = 'pen'
|
if (writingBoardModel.value !== 'pen') writingBoardModel.value = 'pen'
|
||||||
writingBoardColor.value = color
|
writingBoardColor.value = color
|
||||||
emit('close')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭写字板
|
// 关闭写字板
|
||||||
const closeWritingBoard = () => {
|
const closeWritingBoard = () => {
|
||||||
writingBoardVisible.value = false
|
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
const contextmenus = (): ContextmenuItem[] => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
text: '画笔',
|
|
||||||
handler: changePen,
|
|
||||||
disable: writingBoardModel.value === 'pen',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '橡皮擦',
|
|
||||||
handler: changeEraser,
|
|
||||||
disable: writingBoardModel.value === 'eraser',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '擦除所有墨迹',
|
|
||||||
handler: clearCanvas,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '退出画笔',
|
|
||||||
handler: closeWritingBoard,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
writingBoardRef,
|
writingBoardRef,
|
||||||
writingBoardVisible,
|
|
||||||
writingBoardColors,
|
writingBoardColors,
|
||||||
writingBoardColor,
|
writingBoardColor,
|
||||||
writingBoardModel,
|
writingBoardModel,
|
||||||
@ -113,7 +79,6 @@ export default defineComponent({
|
|||||||
clearCanvas,
|
clearCanvas,
|
||||||
changeColor,
|
changeColor,
|
||||||
closeWritingBoard,
|
closeWritingBoard,
|
||||||
contextmenus,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -123,19 +88,28 @@ export default defineComponent({
|
|||||||
.writing-board-tool {
|
.writing-board-tool {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
||||||
|
.tools {
|
||||||
|
height: 50px;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 11;
|
||||||
|
padding: 12px;
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
.btn {
|
.btn {
|
||||||
padding: 3px 10px;
|
padding: 6px 10px;
|
||||||
margin: 0 -10px;
|
|
||||||
margin-bottom: 3px;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
&:hover, &.active {
|
||||||
background-color: rgba($color: $themeColor, $alpha: .2);
|
background-color: rgba($color: $themeColor, $alpha: .2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.colors {
|
.colors {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: 8px;
|
padding: 0 10px;
|
||||||
}
|
}
|
||||||
.color {
|
.color {
|
||||||
width: 15px;
|
width: 15px;
|
||||||
|
@ -41,15 +41,12 @@
|
|||||||
@close="slideThumbnailModelVisible = false"
|
@close="slideThumbnailModelVisible = false"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<WritingBoardTool v-if="writingBoardToolVisible" @close="writingBoardToolVisible = false" />
|
||||||
|
|
||||||
<div class="tools">
|
<div class="tools">
|
||||||
<IconLeftTwo class="tool-btn" theme="two-tone" :fill="['#111', '#fff']" @click="execPrev()" />
|
<IconLeftTwo class="tool-btn" theme="two-tone" :fill="['#111', '#fff']" @click="execPrev()" />
|
||||||
<IconRightTwo class="tool-btn" theme="two-tone" :fill="['#111', '#fff']" @click="execNext()" />
|
<IconRightTwo class="tool-btn" theme="two-tone" :fill="['#111', '#fff']" @click="execNext()" />
|
||||||
<Popover trigger="click" v-model:visible="writingBoardToolVisible">
|
<IconWrite class="tool-btn" theme="two-tone" :fill="['#111', '#fff']" @click="writingBoardToolVisible = true" />
|
||||||
<template #content>
|
|
||||||
<WritingBoardTool @close="writingBoardToolVisible = false" />
|
|
||||||
</template>
|
|
||||||
<IconWrite class="tool-btn" theme="two-tone" :fill="['#111', '#fff']" />
|
|
||||||
</Popover>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="page-number" @click="slideThumbnailModelVisible = true" v-if="showPageNumber">
|
<div class="page-number" @click="slideThumbnailModelVisible = true" v-if="showPageNumber">
|
||||||
@ -283,6 +280,10 @@ export default defineComponent({
|
|||||||
text: '查看所有幻灯片',
|
text: '查看所有幻灯片',
|
||||||
handler: () => slideThumbnailModelVisible.value = true,
|
handler: () => slideThumbnailModelVisible.value = true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: '画笔',
|
||||||
|
handler: () => writingBoardToolVisible.value = true,
|
||||||
|
},
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
{
|
{
|
||||||
text: autoPlayTimer.value ? '取消自动放映' : '自动放映',
|
text: autoPlayTimer.value ? '取消自动放映' : '自动放映',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user