feat(仪表板): 增加粘贴复制保存放大等快捷键

This commit is contained in:
wangjiahao 2022-11-21 11:29:25 +08:00
parent f29a905fbe
commit 0cb98bd6c1
3 changed files with 34 additions and 4 deletions

View File

@ -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
},

View File

@ -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
},

View File

@ -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')
}