fix: remove scene. prefix from textKey, add fallback to choice.text when locale key missing

This commit is contained in:
2026-06-10 12:29:01 +08:00
parent 86a0aebdc8
commit 8f6138f97e
2 changed files with 15 additions and 7 deletions

View File

@@ -17,6 +17,14 @@ const emit = defineEmits<{
const { t } = useI18n()
const store = useGameStore()
function choiceText(choice: Choice): string {
if (choice.textKey) {
const translated = t(choice.textKey)
if (translated !== choice.textKey) return translated
}
return choice.text.trim() || choice.textKey || ''
}
const focusIndex = ref(0)
const btnRefs = ref<(HTMLButtonElement | null)[]>([])
const choiceEnabled = ref(!store.antiMistap)
@@ -96,7 +104,7 @@ function handleChoose(index: number) {
@click="handleChoose(index)"
@keydown="onKeydown($event, index)"
>
{{ t(choice.textKey || choice.text) }}
{{ choiceText(choice) }}
</button>
</div>
</div>