|
@@ -207,6 +207,7 @@ import { AlignEnum } from "@/enum/alignEnum";
|
|
|
import { LayerEnum } from "@/enum/layerEnum";
|
|
|
import { useAcionStore } from "@/store/modules/action";
|
|
|
import { useProjectStore } from "@/store/modules/project";
|
|
|
+import { useKeyPress } from 'vue-hooks-plus';
|
|
|
|
|
|
const actionStore = useAcionStore();
|
|
|
const projectStore = useProjectStore();
|
|
@@ -226,6 +227,24 @@ const handleDeleteElements = () => {
|
|
|
projectStore.removeElement(key);
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
+/* =========================快捷键=========================== */
|
|
|
+// 撤销/重做
|
|
|
+useKeyPress('ctrl.z', () => !actionStore.undoDisabled && actionStore.actionUndo(), { exactMatch: true });
|
|
|
+useKeyPress('ctrl.shift.z', () => !actionStore.redoDisabled && actionStore.actionRedo(), { exactMatch: true });
|
|
|
+// 组合/取消组合
|
|
|
+useKeyPress('ctrl.g', () => projectStore.selectedElementKeys.length > 1 && actionStore.actionGroup(), { exactMatch: true });
|
|
|
+useKeyPress('ctrl.shift.g', () => !ungroupDisabled.value && actionStore.actionUngroup(), { exactMatch: true });
|
|
|
+// 删除
|
|
|
+useKeyPress('del', () => projectStore.selectedElementKeys.length && handleDeleteElements(), { exactMatch: true });
|
|
|
+// 调整层级
|
|
|
+useKeyPress('ctrl.up', () => projectStore.selectedElementKeys.length && actionStore.actionLayer(LayerEnum.UP), { exactMatch: true });
|
|
|
+useKeyPress('ctrl.down', () => projectStore.selectedElementKeys.length && actionStore.actionLayer(LayerEnum.DOWN), { exactMatch: true });
|
|
|
+useKeyPress('ctrl.shift.up', () => projectStore.selectedElementKeys.length && actionStore.actionLayer(LayerEnum.TOP), { exactMatch: true });
|
|
|
+useKeyPress('ctrl.shift.down', () => projectStore.selectedElementKeys.length && actionStore.actionLayer(LayerEnum.BOTTOM), { exactMatch: true });
|
|
|
+// 复制/粘贴
|
|
|
+useKeyPress('ctrl.c', () => projectStore.selectedElementKeys.length && actionStore.actionCopy(), { exactMatch: true });
|
|
|
+useKeyPress('ctrl.v', () => actionStore.actionPaste(), { exactMatch: true });
|
|
|
</script>
|
|
|
|
|
|
<style scoped></style>
|