当设备未连接时,各页面默认显示英文语言的文本,并在标题追加 (Disconnect)
This commit is contained in:
@@ -12,8 +12,9 @@ import { ChevronLeft } from "lucide-react";
|
||||
import { useLocation } from "wouter";
|
||||
import { useMemo } from "react";
|
||||
import localeZh from "@/locales/data-zh.json";
|
||||
import localeZhHK from "@/locales/data-zh-HK.json";
|
||||
import localeEn from "@/locales/data-en.json";
|
||||
import { resolveLocalePack } from "@/locales/resolveLocale";
|
||||
import { usePageTitleWithConnection } from "@/hooks/usePageTitleWithConnection";
|
||||
|
||||
type SourceLocale = NonNullable<(typeof localeZh)["source"]>;
|
||||
|
||||
@@ -180,8 +181,7 @@ export default function IOPage() {
|
||||
const { deviceState, setInput, setOutput } = useDevice();
|
||||
|
||||
const sourceText = useMemo((): SourceLocale => {
|
||||
const lang = deviceState?.language;
|
||||
const pack = lang === 0 ? localeEn : lang === 1 ? localeZhHK : localeZh;
|
||||
const pack = resolveLocalePack(deviceState?.language);
|
||||
return (pack.source ?? {}) as SourceLocale;
|
||||
}, [deviceState?.language]);
|
||||
|
||||
@@ -195,7 +195,9 @@ export default function IOPage() {
|
||||
[sourceText.outputOptions],
|
||||
);
|
||||
|
||||
const ioPageTitle = sourceText.pageTitle ?? sourceText.label ?? "输入输出";
|
||||
const ioPageTitle = usePageTitleWithConnection(
|
||||
sourceText.pageTitle ?? sourceText.label ?? "I/O",
|
||||
);
|
||||
const inputSectionTitle = sourceText.inputSection ?? "输入";
|
||||
const outputSectionTitle = sourceText.outputSection ?? "输出";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user