From ecdda7b73f230679aba4093e0fa47560ee03d5cc Mon Sep 17 00:00:00 2001 From: Clansty Date: Tue, 1 Dec 2026 19:25:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ConfigEntry.tsx | 70 +- AquaMai.Config.Editor/src/index.ts | 2 + .../Mod/ConfigurationController.cs | 9 +- .../Controllers/Mod/ModConfigService.cs | 123 +++- MaiChartManager/Front/src/client/apiGen.ts | 53 +- MaiChartManager/Front/src/locales/en.yaml | 18 + MaiChartManager/Front/src/locales/zh-TW.yaml | 18 + MaiChartManager/Front/src/locales/zh.yaml | 18 + .../views/ModManager/BackupRestoreModal.tsx | 615 ++++++++++++++++++ .../src/views/ModManager/ConfigEditor.tsx | 13 + .../Front/src/views/ModManager/backupDiff.ts | 160 +++++ .../src/views/ModManager/editorAdapter.ts | 2 +- .../Front/src/views/ModManager/refs.ts | 2 + 13 files changed, 1079 insertions(+), 24 deletions(-) create mode 100644 MaiChartManager/Front/src/views/ModManager/BackupRestoreModal.tsx create mode 100644 MaiChartManager/Front/src/views/ModManager/backupDiff.ts diff --git a/AquaMai.Config.Editor/src/components/ConfigEntry.tsx b/AquaMai.Config.Editor/src/components/ConfigEntry.tsx index 3357fa7c..e9316cb3 100644 --- a/AquaMai.Config.Editor/src/components/ConfigEntry.tsx +++ b/AquaMai.Config.Editor/src/components/ConfigEntry.tsx @@ -3,7 +3,7 @@ import { computed, defineComponent, type PropType } from 'vue'; import { useI18n } from 'vue-i18n'; import { ENTRY_LABEL_CLASS } from '../constants'; import { modComments } from '../modComments'; -import type { ConfigEntry as ConfigEntryModel, EntryState } from '../types'; +import type { ConfigEntry as ConfigEntryModel, ConfigValue, EntryState } from '../types'; import { KeyCodeID } from '../types/KeyCodeID'; import { KeyCodeName } from '../types/KeyCodeName'; import { VKCode } from '../types/VKCode'; @@ -44,6 +44,57 @@ export function optionsVKCode(t: (key: string) => string): { label: string; valu }); } +export function optionsSoundChannel(t: (key: string) => string): { label: string; value: string }[] { + return [ + 'None', + 'P1SpeakerLeft', + 'P1SpeakerRight', + 'P1HeadphoneLeft', + 'P1HeadphoneRight', + 'P2SpeakerLeft', + 'P2SpeakerRight', + 'P2HeadphoneLeft', + 'P2HeadphoneRight', + ].map((channel) => ({ + label: t(`mod.soundChannel.${channel}`), + value: channel, + })); +} + +export function formatConfigEntryValue( + entry: ConfigEntryModel, + value: ConfigValue, + t: (key: string) => string, +): string { + if (value === null || value === undefined) { + return '-'; + } + + const stringValue = String(value); + const choices = modComments.options[entry.path]; + if (choices) { + return choices.find((item) => item.value === stringValue)?.label ?? stringValue; + } + + switch (entry.fieldType) { + case 'System.Boolean': + return value ? t('mod.on') : t('mod.off'); + case 'AquaMai.Config.Types.KeyCodeOrName': + return optionsKeyCodeOrName(t).find((item) => item.value === stringValue)?.label ?? stringValue; + case 'AquaMai.Config.Types.KeyCodeID': + return Object.entries(KeyCodeID).find(([, itemValue]) => itemValue === stringValue)?.[0] ?? stringValue; + case 'AquaMai.Config.Types.IOKeyMap': + case 'AquaMai.Config.Types.AdxKeyMap': + return optionsIoKeyMap(t).find((item) => item.value === stringValue)?.label ?? stringValue; + case 'AquaMai.Config.Types.VKCode': + return optionsVKCode(t).find((item) => item.value === stringValue)?.label ?? stringValue; + case 'AquaMai.Config.Types.SoundChannel': + return optionsSoundChannel(t).find((item) => item.value === stringValue)?.label ?? stringValue; + default: + return stringValue; + } +} + export const ConfigEntry = defineComponent({ props: { entry: { type: Object as PropType, required: true }, @@ -51,20 +102,7 @@ export const ConfigEntry = defineComponent({ }, setup(props) { const { t, te, locale } = useI18n(); - const optionsSoundChannel = [ - 'None', - 'P1SpeakerLeft', - 'P1SpeakerRight', - 'P1HeadphoneLeft', - 'P1HeadphoneRight', - 'P2SpeakerLeft', - 'P2SpeakerRight', - 'P2HeadphoneLeft', - 'P2HeadphoneRight', - ].map((channel) => ({ - label: t(`mod.soundChannel.${channel}`), - value: channel, - })); + const soundChannelOptions = optionsSoundChannel(t); const comment = computed(() => { const localeKey = `mod.commentOverrides.${props.entry.path.replace(/\./g, '_')}`; @@ -122,7 +160,7 @@ export const ConfigEntry = defineComponent({ case 'AquaMai.Config.Types.VKCode': return ; + return