增加刷新游戏的快捷键

This commit is contained in:
xu_yanfeng 2025-04-05 11:17:17 +08:00
parent 6c5a6c84ce
commit dada072624
3 changed files with 22 additions and 1 deletions

View File

@ -283,7 +283,7 @@ export default defineComponent({
const picking = ref(false);
const keydownFunc = (e: KeyboardEvent) => {
const { shortKeyPick, shortKeyGameStep, shortKeyGamePauseResume } = config.value;
const { shortKeyPick, shortKeyGameFresh, shortKeyGameStep, shortKeyGamePauseResume } = config.value;
switch (e.code) {
case shortKeyPick: {
if (picking.value === false) {
@ -304,6 +304,20 @@ export default defineComponent({
showGameTip.value = !!cc.game.isPaused();
break;
}
case shortKeyGameFresh: {
const url = new URL(window.location.href);
const port = Number(url.port) || 7456;
fetch(`http://localhost:${port}/asset-db/refresh`)
.then((res) => {
res.text().then((a: string) => {
if (a === "success") {
window.location.reload();
}
});
})
.then((data) => {});
break;
}
}
};
/**是否显示游戏暂停的提示 */

View File

@ -3,6 +3,7 @@
<CCProp name="Node Pick"> <CCSelect @change="onChangePick" :value="config.shortKeyPick" :data="keyOptions"></CCSelect> </CCProp>
<CCProp name="Game Pause/Resume"> <CCSelect @change="onChangeGamePauseResume" :value="config.shortKeyGamePauseResume" :data="keyOptions"></CCSelect> </CCProp>
<CCProp name="Game Step"> <CCSelect @change="onChangeGameStep" :value="config.shortKeyGameStep" :data="keyOptions"></CCSelect> </CCProp>
<CCProp name="Game Fresh"> <CCSelect @change="onChangeGameFresh" :value="config.shortKeyGameFresh" :data="keyOptions"></CCSelect> </CCProp>
</div>
</template>
<script lang="ts">
@ -47,6 +48,10 @@ export default defineComponent({
config.value.shortKeyGameStep = v;
appStore().save();
},
onChangeGameFresh(v: string) {
config.value.shortKeyGameFresh = v;
appStore().save();
},
onChangeGamePauseResume(v: string) {
config.value.shortKeyGamePauseResume = v;
appStore().save();

View File

@ -18,6 +18,7 @@ export class ConfigData {
shortKeyPick: string = "Escape";
shortKeyGameStep: string = "F8";
shortKeyGamePauseResume: string = "Space";
shortKeyGameFresh: string = "F1";
}
export const appStore = defineStore("app", () => {
@ -34,6 +35,7 @@ export const appStore = defineStore("app", () => {
config.value.shortKeyPick = data.shortKeyPick;
config.value.shortKeyGameStep = data.shortKeyGameStep;
config.value.shortKeyGamePauseResume = data.shortKeyGamePauseResume;
config.value.shortKeyGameFresh = data.shortKeyGameFresh;
},
save() {
const cfg = toRaw(config.value);