Lang Impl, Dialog[Char][Languge]

This commit is contained in:
fufu-girl-meow 2025-06-23 14:06:09 +07:00
parent c772d02c3b
commit f92feef474
3 changed files with 4 additions and 4 deletions

View file

@ -20,7 +20,7 @@ createRoot(document.getElementById('root')).render(
<Route path="/name" element={<NamePage />} /> <Route path="/name" element={<NamePage />} />
<Route path='/video' element={<PlayVideo />} /> <Route path='/video' element={<PlayVideo />} />
<Route path="/introduction" element={<IntroductionPage />} /> <Route path="/introduction" element={<IntroductionPage />} />
<Route path='/vs/:char/:step' element={<VitualNovelHandler />} /> <Route path='/vs/:char/:lang/:step' element={<VitualNovelHandler />} />
<Route path='/end' element={<EndPage />} /> <Route path='/end' element={<EndPage />} />
<Route path="*" element={<Navigate to="/" replace />} /> <Route path="*" element={<Navigate to="/" replace />} />

View file

@ -14,12 +14,12 @@ function VitualNovelHandler() {
const [error, setError] = useState(null); const [error, setError] = useState(null);
const [currentStep, setCurrentStep] = useState(0); const [currentStep, setCurrentStep] = useState(0);
const navigate = useNavigate(); const navigate = useNavigate();
const { char, step } = useParams(); const { char, lang, step } = useParams();
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
try { try {
const yamlPath = `/yml/Dialog${char}.yml`; const yamlPath = `/yml/Dialog${char}${lang}.yml`;
const parsedData = await fetchYamlData({ src: yamlPath }); const parsedData = await fetchYamlData({ src: yamlPath });
if (!Array.isArray(parsedData)) { if (!Array.isArray(parsedData)) {
throw new Error('YAML data is not an array'); throw new Error('YAML data is not an array');
@ -57,7 +57,7 @@ function VitualNovelHandler() {
} }
else{ else{
setCurrentStep(nextstep); setCurrentStep(nextstep);
navigate(`/vs/${char}/${nextstep}`); navigate(`/vs/${char}/${lang}/${nextstep}`);
// console.log("currentStep:", currentStep); // console.log("currentStep:", currentStep);
// console.log("data at currentStep:", data[currentStep]); // console.log("data at currentStep:", data[currentStep]);
} }