设置快捷键界面

This commit is contained in:
xu_yanfeng 2025-03-08 13:56:53 +08:00
parent 0abd984998
commit 167816a1b9
2 changed files with 72 additions and 2 deletions

View File

@ -0,0 +1,63 @@
<template>
<div class="shortkeys">
<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>
</div>
</template>
<script lang="ts">
import ccui from "@xuyanfeng/cc-ui";
import { Option } from "@xuyanfeng/cc-ui/types/cc-select/const";
import { storeToRefs } from "pinia";
import { defineComponent, ref } from "vue";
import { appStore } from "./store";
const { CCButton, CCSelect, CCProp } = ccui.components;
export default defineComponent({
name: "shortkeys",
components: { CCButton, CCSelect, CCProp },
setup(props, { emit }) {
const { config } = storeToRefs(appStore());
const keyOptions = ref<Array<Option>>([
{ label: "None", value: "None" },
{ label: "Space", value: "Space" },
{ label: "Escape", value: "Escape" },
{ label: "F1", value: "F1" },
{ label: "F2", value: "F2" },
{ label: "F3", value: "F3" },
{ label: "F4", value: "F4" },
{ label: "F5", value: "F5" },
{ label: "F6", value: "F6" },
{ label: "F7", value: "F7" },
{ label: "F8", value: "F8" },
{ label: "F9", value: "F9" },
{ label: "F10", value: "F10" },
{ label: "F11", value: "F11" },
{ label: "F12", value: "F12" },
]);
return {
config,
keyOptions,
onChangePick(v: string) {
config.value.shortKeyPick = v;
appStore().save();
},
onChangeGameStep(v: string) {
config.value.shortKeyGameStep = v;
appStore().save();
},
onChangeGamePauseResume(v: string) {
config.value.shortKeyGamePauseResume = v;
appStore().save();
},
};
},
});
</script>
<style lang="less" scoped>
.shortkeys {
background-color: black;
display: flex;
flex-direction: column;
}
</style>

View File

@ -1,6 +1,6 @@
import { ref, toRaw } from "vue";
import { defineStore } from "pinia";
import profile from "cc-plugin/src/ccp/profile";
import { defineStore } from "pinia";
import { ref, toRaw } from "vue";
import pluginConfig from "../../../cc-plugin.config";
export class ConfigData {
/**
@ -15,6 +15,9 @@ export class ConfigData {
*
*/
pickTop: boolean = true;
shortKeyPick: string = "Escape";
shortKeyGameStep: string = "F8";
shortKeyGamePauseResume: string = "Space";
}
export const appStore = defineStore("app", () => {
@ -22,11 +25,15 @@ export const appStore = defineStore("app", () => {
return {
config,
init() {
profile.Adaptation.init(pluginConfig);
profile.init(new ConfigData(), pluginConfig);
const data = profile.load(`${pluginConfig.manifest.name}-assistant.json`) as ConfigData;
config.value.autoHide = data.autoHide;
config.value.pos = data.pos;
config.value.pickTop = data.pickTop;
config.value.shortKeyPick = data.shortKeyPick;
config.value.shortKeyGameStep = data.shortKeyGameStep;
config.value.shortKeyGamePauseResume = data.shortKeyGamePauseResume;
},
save() {
const cfg = toRaw(config.value);