diff --git a/src/components/keyboard/KeyBoard.vue b/src/components/keyboard/KeyBoard.vue index d62edfd..116bd6a 100644 --- a/src/components/keyboard/KeyBoard.vue +++ b/src/components/keyboard/KeyBoard.vue @@ -18,8 +18,6 @@ import { DropdownOption, NDropdown, useDialog, useMessage } from "naive-ui"; import { onBeforeRouteLeave } from "vue-router"; import { useKeyboardStore } from "../../store/keyboard"; -// TODO 缺少pointer_id的编辑,注意所有按键包括技能取消都有这个内容 -// TODO 设置界面添加本地数据编辑器(类似utools) // TODO 添加开发者工具打开按钮 // TODO 添加息屏按键 // TODO 添加无线调试(rust加一条指令connet即可) diff --git a/src/components/keyboard/KeySetting.vue b/src/components/keyboard/KeySetting.vue index 02b8361..d7a6186 100644 --- a/src/components/keyboard/KeySetting.vue +++ b/src/components/keyboard/KeySetting.vue @@ -421,7 +421,7 @@ function resetKeyMappingConfig() { 提示:右键空白区域可添加按键 - + import { Store } from "@tauri-apps/plugin-store"; -import { NH4, NForm, FormInst, NButton } from "naive-ui"; +import { Refresh, TrashBinOutline } from "@vicons/ionicons5"; +import { + NH4, + NP, + NButton, + NFlex, + NList, + NListItem, + NModal, + NInput, + useDialog, + NCard, + NIcon, +} from "naive-ui"; -import { ref } from "vue"; +import { onMounted, ref } from "vue"; -const formRef = ref(null); const localStore = new Store("store.bin"); +const dialog = useDialog(); + +const localStoreEntries = ref<[string, unknown][]>([]); +const showDataModal = ref(false); +const dataModalInputVal = ref(""); +let curDataIndex = -1; + +onMounted(() => { + refreshLocalData(); +}); + +async function refreshLocalData() { + localStoreEntries.value = await localStore.entries(); +} + +function showLocalStore(index: number) { + curDataIndex = index; + dataModalInputVal.value = JSON.stringify( + localStoreEntries.value[index][1], + null, + 2 + ); + showDataModal.value = true; +} + +function delLocalStore(key?: string) { + if (key) { + dialog.warning({ + title: "Warning", + content: `即将删除数据"${key}",删除操作不可撤回,是否继续?`, + positiveText: "删除", + negativeText: "取消", + onPositiveClick: () => { + localStore.delete(key); + localStoreEntries.value.splice(curDataIndex, 1); + showDataModal.value = false; + }, + }); + } else { + dialog.warning({ + title: "Warning", + content: "即将清空数据,操作不可撤回,且清空后将重启软件,是否继续?", + positiveText: "删除", + negativeText: "取消", + onPositiveClick: () => { + localStore.clear(); + }, + }); + } +} - +