fix: 道具栏和装备栏转换使按键失效

This commit is contained in:
unanmed 2023-11-20 20:05:01 +08:00
parent bd0205ff46
commit c423750885
4 changed files with 29 additions and 9 deletions

View File

@ -468,10 +468,22 @@ gameKey
}
})
.realize('special', () => {
mainUi.open('fixedDetail', { panel: 'special' });
if (hovered) {
const { x, y } = hovered;
const enemy = core.status.thisMap.enemy.list.find(v => {
return v.x === x && v.y === y;
});
if (enemy) mainUi.open('fixedDetail', { panel: 'special' });
}
})
.realize('critical', () => {
mainUi.open('fixedDetail', { panel: 'critical' });
if (hovered) {
const { x, y } = hovered;
const enemy = core.status.thisMap.enemy.list.find(v => {
return v.x === x && v.y === y;
});
if (enemy) mainUi.open('fixedDetail', { panel: 'critical' });
}
})
.realize('restart', () => {
core.confirmRestart();

View File

@ -438,7 +438,9 @@ function dragout(e: Event) {
function toTool() {
mota.ui.main.holdOn();
exit();
mota.ui.main.open('toolbox');
nextTick(() => {
mota.ui.main.open('toolbox');
});
}
gameKey.use(props.ui.symbol);

View File

@ -36,6 +36,8 @@ if (hovered) {
} else {
close();
}
} else {
close();
}
function close() {

View File

@ -108,7 +108,7 @@
<script lang="ts" setup>
import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue';
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import Scroll from '../components/scroll.vue';
import BoxAnimate from '../components/boxAnimate.vue';
import { getClsName, getItems } from '../plugin/ui/toolbox';
@ -180,10 +180,12 @@ function use(id: ShowItemIds) {
if (core.canUseItem(id)) {
const hold = mota.ui.main.holdOn();
exit();
core.useItem(id, false, () => {
if (mota.ui.main.stack.length === 0) {
hold.end();
}
nextTick(() => {
core.useItem(id, false, () => {
if (mota.ui.main.stack.length === 0) {
hold.end();
}
});
});
} else {
message.warn({
@ -196,7 +198,9 @@ function use(id: ShowItemIds) {
async function toEquip() {
mota.ui.main.holdOn();
exit();
mota.ui.main.open('equipbox');
nextTick(() => {
mota.ui.main.open('equipbox');
});
}
gameKey.use(props.ui.symbol);