增加空格跳到下一个位置

This commit is contained in:
joylink_zhaoerwei 2024-06-26 15:25:44 +08:00
parent 7e62e88ac0
commit 4373cb7dc2
4 changed files with 65 additions and 29 deletions

View File

@ -137,20 +137,7 @@ watch(
relayCabinetStore.currentPressKey == PressKeyForCiCjQd.alt relayCabinetStore.currentPressKey == PressKeyForCiCjQd.alt
) { ) {
onSubmit(); onSubmit();
let nestPos = { handleNextPosition();
row: click.row + 1,
col: click.col,
};
if (click.row + 1 <= CiCjListRows) {
relayCabinetStore.editCiCjConfigIndex = nestPos;
}
if (click.row + 1 > CiCjListRows && click.col < CiCjListCols) {
nestPos = {
row: 1,
col: click.col + 1,
};
relayCabinetStore.editCiCjConfigIndex = nestPos;
}
} }
} }
} }
@ -167,6 +154,16 @@ watch(
} }
); );
//
watch(
() => relayCabinetStore.currentPressKey,
(val) => {
if (val == PressKeyForCiCjQd.space1 || val == PressKeyForCiCjQd.space2) {
handleNextPosition();
}
}
);
let CiCjListRows = 0; let CiCjListRows = 0;
let CiCjListCols = 0; let CiCjListCols = 0;
onMounted(() => { onMounted(() => {
@ -286,6 +283,24 @@ function deletePosition() {
relayCabinetStore.updateCiCjList = true; relayCabinetStore.updateCiCjList = true;
} }
function handleNextPosition() {
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil;
let nestPos = {
row: click.row + 1,
col: click.col,
};
if (click.row + 1 <= CiCjListRows) {
relayCabinetStore.editCiCjConfigIndex = nestPos;
}
if (click.row + 1 > CiCjListRows && click.col < CiCjListCols) {
nestPos = {
row: 1,
col: click.col + 1,
};
relayCabinetStore.editCiCjConfigIndex = nestPos;
}
}
onUnmounted(() => { onUnmounted(() => {
relayCabinetStore.showCiCjConfig = false; relayCabinetStore.showCiCjConfig = false;
}); });

View File

@ -114,21 +114,7 @@ watch(
relayCabinetStore.currentPressKey == PressKeyForCiCjQd.alt relayCabinetStore.currentPressKey == PressKeyForCiCjQd.alt
) { ) {
onSubmit(); onSubmit();
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil; handleNextPosition();
let nestPos = {
row: click.row + 1,
col: click.col,
};
if (click.row + 1 <= CiQdListRows) {
relayCabinetStore.editCiCjConfigIndex = nestPos;
}
if (click.row + 1 > CiQdListRows && click.col < CiQdListCols) {
nestPos = {
row: 1,
col: click.col + 1,
};
relayCabinetStore.editCiCjConfigIndex = nestPos;
}
} }
} }
} }
@ -144,6 +130,16 @@ watch(
} }
); );
//
watch(
() => relayCabinetStore.currentPressKey,
(val) => {
if (val == PressKeyForCiCjQd.space1 || val == PressKeyForCiCjQd.space2) {
handleNextPosition();
}
}
);
let CiQdListRows = 0; let CiQdListRows = 0;
let CiQdListCols = 0; let CiQdListCols = 0;
onMounted(() => { onMounted(() => {
@ -242,6 +238,24 @@ function deletePosition() {
relayCabinetStore.updateCiCjList = true; relayCabinetStore.updateCiCjList = true;
} }
function handleNextPosition() {
const click = relayCabinetStore.editCiCjConfigIndex as CiCjConfigCeil;
let nestPos = {
row: click.row + 1,
col: click.col,
};
if (click.row + 1 <= CiQdListRows) {
relayCabinetStore.editCiCjConfigIndex = nestPos;
}
if (click.row + 1 > CiQdListRows && click.col < CiQdListCols) {
nestPos = {
row: 1,
col: click.col + 1,
};
relayCabinetStore.editCiCjConfigIndex = nestPos;
}
}
onUnmounted(() => { onUnmounted(() => {
relayCabinetStore.showCiCjConfig = false; relayCabinetStore.showCiCjConfig = false;
}); });

View File

@ -1225,6 +1225,11 @@ function handleKeyDown(event: KeyboardEvent) {
} else if (event.altKey) { } else if (event.altKey) {
relayCabinetStore.currentPressKey = PressKeyForCiCjQd.alt; relayCabinetStore.currentPressKey = PressKeyForCiCjQd.alt;
event.preventDefault(); event.preventDefault();
} else if (event.code == 'Space') {
relayCabinetStore.currentPressKey =
relayCabinetStore.currentPressKey == PressKeyForCiCjQd.space1
? PressKeyForCiCjQd.space2
: PressKeyForCiCjQd.space1;
} }
} }
} }

View File

@ -19,6 +19,8 @@ export enum PressKeyForCiCjQd {
alt, alt,
shiftCtrl, shiftCtrl,
shiftAlt, shiftAlt,
space1,
space2,
} }
export const useRelayCabinetStore = defineStore('relayCabinet', { export const useRelayCabinetStore = defineStore('relayCabinet', {