diff --git a/frontend/src/components/canvas/components/Toolbar.vue b/frontend/src/components/canvas/components/Toolbar.vue index 1ab2995f04..994cbac5d7 100644 --- a/frontend/src/components/canvas/components/Toolbar.vue +++ b/frontend/src/components/canvas/components/Toolbar.vue @@ -294,7 +294,7 @@ export default { created() { eventBus.$on('editPanelInitReady', this.editPanelInit) eventBus.$on('preview', this.preview) - eventBus.$on('save', this.save) + eventBus.$on('checkAndSave', this.checkAndSave) eventBus.$on('clearCanvas', this.clearCanvas) this.scale = this.canvasStyleData.scale this.mobileLayoutInitStatus = this.mobileLayoutStatus @@ -303,13 +303,18 @@ export default { }, beforeDestroy() { eventBus.$off('preview', this.preview) - eventBus.$off('save', this.save) + eventBus.$off('checkAndSave', this.checkAndSave) eventBus.$off('clearCanvas', this.clearCanvas) eventBus.$off('editPanelInitReady', this.editPanelInit) clearInterval(this.timer) this.timer = null }, methods: { + checkAndSave() { + if (!this.saveButtonDisabled) { + this.save(false) + } + }, editPanelInit() { this.showGridSwitch = this.canvasStyleData.aidedDesign.showGrid }, diff --git a/frontend/src/components/canvas/components/editor/EditBar.vue b/frontend/src/components/canvas/components/editor/EditBar.vue index 6a4d7bd3c2..3f2c726998 100644 --- a/frontend/src/components/canvas/components/editor/EditBar.vue +++ b/frontend/src/components/canvas/components/editor/EditBar.vue @@ -193,6 +193,7 @@ import LinkJumpSet from '@/views/panel/linkJumpSet' import Background from '@/views/background/index' import MapLayerController from '@/views/chart/components/map/MapLayerController' import { uploadFileResult } from '@/api/staticResource/staticResource' +import eventBus from '@/components/canvas/utils/eventBus' export default { components: { Background, LinkJumpSet, FieldsList, SettingMenu, LinkageField, MapLayerController }, @@ -364,9 +365,16 @@ export default { this.initCurFields() if (this.element.type === 'view') { bus.$on('initCurFields-' + this.element.id, this.initCurFields) + eventBus.$on('viewEnlarge', this.viewEnlarge) } }, + beforeDestroy() { + eventBus.$off('preview', this.showViewDetails) + }, methods: { + viewEnlarge() { + this.showViewDetails('enlarge') + }, backgroundSetClose() { this.boardSetVisible = false }, diff --git a/frontend/src/components/canvas/utils/shortcutKey.js b/frontend/src/components/canvas/utils/shortcutKey.js index 2c1cba10e6..3e1dd16b7f 100644 --- a/frontend/src/components/canvas/utils/shortcutKey.js +++ b/frontend/src/components/canvas/utils/shortcutKey.js @@ -1,4 +1,5 @@ import store from '@/store' +import eventBus from '@/components/canvas/utils/eventBus' const ctrlKey = 17 const commandKey = 91 // mac command @@ -15,8 +16,13 @@ const bKey = 66 // 拆分 const lKey = 76 // 锁定 const dKey = 68 // 删除 + const deleteKey = 46 // 删除 +const sKey = 83 // 保存 + +const enlargeKey = 190 // command + . + export const keycodes = [66, 67, 68, 69, 71, 76, 80, 83, 85, 86, 88, 89, 90] // 与组件状态无关的操作 @@ -35,10 +41,13 @@ const unlockMap = { [bKey]: decompose, [dKey]: deleteComponent, [deleteKey]: deleteComponent, - [lKey]: lock + [lKey]: lock, + [sKey]: save, + [enlargeKey]: viewEnlarge } let isCtrlOrCommandDown = false + // Monitor key operations globally and execute corresponding commands export function listenGlobalKeyDown() { window.onkeydown = (e) => { @@ -47,7 +56,7 @@ export function listenGlobalKeyDown() { if (keyCode === ctrlKey || keyCode === commandKey) { isCtrlOrCommandDown = true } else if (isCtrlOrCommandDown) { - if (keyCode === zKey || keyCode === yKey) { + if (keyCode === zKey || keyCode === yKey || keyCode === vKey || keyCode === cKey || keyCode === sKey || keyCode === enlargeKey) { e.preventDefault() unlockMap[keyCode]() } @@ -107,3 +116,11 @@ function deleteComponent() { function lock() { store.commit('lock') } + +function save() { + eventBus.$emit('checkAndSave') +} + +function viewEnlarge() { + eventBus.$emit('viewEnlarge') +}