feat: 增加管理端多语言与多模块界面国际化支持

This commit is contained in:
2026-05-19 09:11:55 +08:00
parent 49a4caf01e
commit 1b1dfc92ab
110 changed files with 4053 additions and 1308 deletions

View File

@@ -1,6 +1,7 @@
"use client";
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { getAdminRiskPoolLockLogs } from "@/api/admin-risk";
import { AdminListPaginationFooter } from "@/components/admin/admin-list-pagination-footer";
@@ -31,6 +32,7 @@ import type { AdminRiskLockLogListData, AdminRiskLockLogRow } from "@/types/api/
const ACTION_ALL = "__all__";
export function RiskLockLogsConsole({ drawId }: { drawId: number }) {
const { t } = useTranslation(["risk", "common"]);
const formatDt = useAdminDateTimeFormatter();
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
@@ -59,13 +61,13 @@ export function RiskLockLogsConsole({ drawId }: { drawId: number }) {
setData(d);
} catch (e) {
const msg =
e instanceof LotteryApiBizError ? e.message : "加载占用流水失败";
e instanceof LotteryApiBizError ? e.message : t("loadLogsFailed");
setError(msg);
setData(null);
} finally {
setLoading(false);
}
}, [drawId, page, perPage, appliedAction, appliedNumber]);
}, [drawId, page, perPage, appliedAction, appliedNumber, t]);
useEffect(() => {
queueMicrotask(() => {
@@ -76,23 +78,23 @@ export function RiskLockLogsConsole({ drawId }: { drawId: number }) {
return (
<Card>
<CardHeader>
<CardTitle className="text-lg"></CardTitle>
<CardTitle className="text-lg">{t("lockLogsTitle")}</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="grid max-w-full gap-3 sm:grid-cols-[minmax(0,8rem)_minmax(0,10rem)_auto] sm:items-end">
<div className="space-y-1.5">
<Label htmlFor="risk-log-number">4 </Label>
<Label htmlFor="risk-log-number">{t("number4d")}</Label>
<Input
id="risk-log-number"
inputMode="numeric"
maxLength={4}
value={draftNumber}
onChange={(e) => setDraftNumber(e.target.value.replace(/\D/g, "").slice(0, 4))}
placeholder="可选"
placeholder={t("optional")}
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="risk-log-action"></Label>
<Label htmlFor="risk-log-action">{t("actionFilter")}</Label>
<Select
modal={false}
value={draftAction}
@@ -104,9 +106,9 @@ export function RiskLockLogsConsole({ drawId }: { drawId: number }) {
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value={ACTION_ALL}></SelectItem>
<SelectItem value="lock"> lock</SelectItem>
<SelectItem value="release"> release</SelectItem>
<SelectItem value={ACTION_ALL}>{t("noLimit")}</SelectItem>
<SelectItem value="lock">{t("lock")}</SelectItem>
<SelectItem value="release">{t("release")}</SelectItem>
</SelectContent>
</Select>
</div>
@@ -120,7 +122,7 @@ export function RiskLockLogsConsole({ drawId }: { drawId: number }) {
setPage(1);
}}
>
{t("applyFilter")}
</Button>
</div>
</div>
@@ -128,20 +130,20 @@ export function RiskLockLogsConsole({ drawId }: { drawId: number }) {
{error ? <p className="text-sm text-destructive">{error}</p> : null}
{loading && !data ? (
<p className="text-sm text-muted-foreground"></p>
<p className="text-sm text-muted-foreground">{t("states.loading", { ns: "common" })}</p>
) : (
<>
<div className="overflow-x-auto rounded-md border">
<Table>
<TableHeader>
<TableRow>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead className="text-right"></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead>{t("time")}</TableHead>
<TableHead>{t("searchNumber")}</TableHead>
<TableHead>{t("action")}</TableHead>
<TableHead className="text-right">{t("amount")}</TableHead>
<TableHead>{t("source")}</TableHead>
<TableHead>{t("ticketNo")}</TableHead>
<TableHead>{t("playCode")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>