feat: 优化语言切换下拉交互并支持玩法规则多语言内容
This commit is contained in:
@@ -26,8 +26,8 @@ export function HallScreen() {
|
||||
|
||||
return (
|
||||
<div className="mx-auto w-full max-w-[480px]">
|
||||
<section className={cn("overflow-hidden bg-white text-slate-900", playerPageInset)}>
|
||||
<header className="mb-2 flex min-h-9 items-center gap-2">
|
||||
<section className={cn("bg-white text-slate-900", playerPageInset)}>
|
||||
<header className="relative z-20 mb-2 flex min-h-9 items-center gap-2 overflow-visible">
|
||||
<div className="flex min-w-0 flex-1 items-center">
|
||||
<Image
|
||||
src="/logo.png"
|
||||
@@ -41,6 +41,7 @@ export function HallScreen() {
|
||||
<div className="flex shrink-0 items-center gap-1">
|
||||
<LanguageSwitcher
|
||||
variant="minimal"
|
||||
menuAlign="end"
|
||||
showFlag={false}
|
||||
className={cn(
|
||||
playerHeaderControl,
|
||||
|
||||
@@ -6,10 +6,11 @@ import { Loader2 } from "lucide-react";
|
||||
|
||||
import { getPublicSettings } from "@/api";
|
||||
import { PlayerPanel } from "@/components/layout/player-panel";
|
||||
import { resolvePlayRulesHtml } from "@/lib/play-rules-html";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
export function PlayRulesScreen() {
|
||||
const { t } = useTranslation("player");
|
||||
const { t, i18n } = useTranslation("player");
|
||||
const [htmlContent, setHtmlContent] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
@@ -17,9 +18,9 @@ export function PlayRulesScreen() {
|
||||
async function loadRules() {
|
||||
try {
|
||||
const res = await getPublicSettings("frontend");
|
||||
const ruleItem = res.items.find((item) => item.key === "frontend.play_rules_html");
|
||||
if (ruleItem && typeof ruleItem.value === "string" && ruleItem.value.trim() !== "") {
|
||||
setHtmlContent(ruleItem.value);
|
||||
const html = resolvePlayRulesHtml(res.items, i18n.language);
|
||||
if (html) {
|
||||
setHtmlContent(html);
|
||||
} else {
|
||||
setHtmlContent(`<div style="text-align:center;padding:2rem;color:#64748b;">${t("rules.empty", { defaultValue: "暂无玩法规则说明" })}</div>`);
|
||||
}
|
||||
@@ -30,7 +31,7 @@ export function PlayRulesScreen() {
|
||||
}
|
||||
}
|
||||
void loadRules();
|
||||
}, [t]);
|
||||
}, [i18n.language, t]);
|
||||
|
||||
return (
|
||||
<PlayerPanel
|
||||
|
||||
Reference in New Issue
Block a user