fix: remove scene. prefix from textKey, add fallback to choice.text when locale key missing
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
"choices": [
|
||||
{
|
||||
"text": "走向左边那扇发光的门",
|
||||
"textKey": "scene.intro.choice.left_door",
|
||||
"textKey": "intro.choice.left_door",
|
||||
"targetScene": "left_door",
|
||||
"effects": [
|
||||
{ "type": "add", "target": "courage", "value": 10 }
|
||||
@@ -89,7 +89,7 @@
|
||||
},
|
||||
{
|
||||
"text": "走向右边那扇普通的门",
|
||||
"textKey": "scene.intro.choice.right_door",
|
||||
"textKey": "intro.choice.right_door",
|
||||
"targetScene": "right_door",
|
||||
"effects": [
|
||||
{ "type": "add", "target": "courage", "value": -5 }
|
||||
@@ -97,12 +97,12 @@
|
||||
},
|
||||
{
|
||||
"text": "仔细搜索房间",
|
||||
"textKey": "scene.intro.choice.search",
|
||||
"textKey": "intro.choice.search",
|
||||
"targetScene": "investigation_site"
|
||||
},
|
||||
{
|
||||
"text": "留在原地,什么也不做",
|
||||
"textKey": "scene.intro.choice.stay",
|
||||
"textKey": "intro.choice.stay",
|
||||
"targetScene": "stay"
|
||||
}
|
||||
]
|
||||
@@ -193,7 +193,7 @@
|
||||
"choices": [
|
||||
{
|
||||
"text": "与陌生人握手",
|
||||
"textKey": "scene.left_door.choice.handshake",
|
||||
"textKey": "left_door.choice.handshake",
|
||||
"prompt": "陌生人会记住你的善意",
|
||||
"targetScene": "trust_ending",
|
||||
"effects": [
|
||||
@@ -296,7 +296,7 @@
|
||||
"choices": [
|
||||
{
|
||||
"text": "开启信任的旅程(需要 trust >= 80)",
|
||||
"textKey": "scene.trust_ending.choice.journey",
|
||||
"textKey": "trust_ending.choice.journey",
|
||||
"prompt": "你们的羁绊将改变一切",
|
||||
"targetScene": "secret_ending",
|
||||
"conditions": [
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user