Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrongding committed Apr 22, 2024
2 parents f84ea42 + 73083fd commit 53e7886
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/player/CanvasPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let clipboard: fabric.Object | null = null
const menuList = [
{ key: 'flipX', shortkey: '⌘+C', text: '复制', callback: onCopy },
{ key: 'flipX', shortkey: '⌘+V', text: '粘贴', callback: onPaste },
{ key: 'flipX', shortkey: '⌘+X', text: '剪切', callback: onCut },
{ key: 'flipX', shortkey: 'Del', text: '删除', callback: onDelete },
{ key: 'flipY', shortkey: '⌘+]', text: '上移一层', callback: () => setElementLayer('up') },
{ key: 'flipY', shortkey: '⌘+[', text: '下移一层', callback: () => setElementLayer('down') },
Expand Down Expand Up @@ -94,9 +95,8 @@ async function drawElements() {
}
// 删除元素
// BUG 为啥删不了
function onDelete(obj: fabric.Object) {
const activeObject = obj || canvas.getActiveObject()
const activeObject = obj instanceof fabric.Object ? obj : canvas.getActiveObject()
if (!activeObject) return
canvas.remove(activeObject)
canvas.requestRenderAll()
Expand Down Expand Up @@ -539,8 +539,10 @@ onMounted((): void => {
ref="contextMenu"
:menuList="menuList"
:style="{
top: contextMenuPosition.y + 'px',
left: contextMenuPosition.x + 'px'
top: Math.max(0, contextMenuPosition.y) + 'px',
left: contextMenuPosition.x + 'px',
maxHeight: '100%',
overflow: 'auto'
}"
class="context-menu"
/>
Expand Down

0 comments on commit 53e7886

Please sign in to comment.