fix(editor): 画布右键菜单中粘贴按钮显示条件修改

This commit is contained in:
roymondchen 2022-08-09 19:49:42 +08:00 committed by jia000
parent 23617a63e9
commit beee67b3eb

View File

@ -3,7 +3,7 @@
</template>
<script lang="ts" setup>
import { computed, inject, markRaw, onMounted, reactive, ref, watch } from 'vue';
import { computed, inject, markRaw, reactive, ref, watch } from 'vue';
import { Bottom, Delete, DocumentCopy, Top } from '@element-plus/icons-vue';
import { MNode, NodeType } from '@tmagic/schema';
@ -133,11 +133,6 @@ const menuData = reactive<MenuItem[]>([
...stageContentMenu,
]);
onMounted(async () => {
const data = await storageService.getItem(COPY_STORAGE_KEY);
canPaste.value = data !== 'undefined' && !!data;
});
watch(
parent,
async () => {
@ -152,8 +147,10 @@ watch(
{ immediate: true },
);
const show = (e: MouseEvent) => {
const show = async (e: MouseEvent) => {
menu.value?.show(e);
const data = await storageService.getItem(COPY_STORAGE_KEY);
canPaste.value = data !== 'undefined' && !!data;
};
defineExpose({ show });