refactor: 重构奖池配置页面,移除冗余组件,优化加载体验与国际化支持
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
/**
|
||||
* Single source of truth for config sub-navigation and breadcrumb routes.
|
||||
* Add new config pages here and create the matching `app/admin/(shell)/config/.../page.tsx`.
|
||||
*
|
||||
* ## 导航层级约定(避免「侧栏 + 顶栏 + 页内 Tab」叠三层)
|
||||
* 1. **侧栏**:模块入口(如「运营配置」)— 全站唯一一级。
|
||||
* 2. **本文件顶栏(ConfigSubNav)**:运营配置下的「业务子域」切换(玩法、赔率、奖池…)— 最多一层。
|
||||
* 3. **页面内**:默认 **禁止再建 Tab/子路由**;改参数与查流水用 **同页分区(ConfigSection)** 或锚点 `#records`。
|
||||
* 仅当子域体量极大、且与配置完全无关时再考虑独立路由,且不得与顶栏同名。
|
||||
*/
|
||||
|
||||
export type ConfigNavGroup = {
|
||||
|
||||
@@ -8,6 +8,8 @@ type ConfigSectionProps = {
|
||||
actions?: ReactNode;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
/** 页内锚点,供旧链接跳转(如 #records) */
|
||||
id?: string;
|
||||
};
|
||||
|
||||
export function ConfigSection({
|
||||
@@ -16,9 +18,10 @@ export function ConfigSection({
|
||||
actions,
|
||||
children,
|
||||
className,
|
||||
id,
|
||||
}: ConfigSectionProps) {
|
||||
return (
|
||||
<section className={cn("space-y-4", className)}>
|
||||
<section id={id} className={cn("scroll-mt-24 space-y-4", className)}>
|
||||
<div className="flex flex-wrap items-start justify-between gap-3 border-b border-border/60 pb-3">
|
||||
<div className="min-w-0 space-y-1">
|
||||
<h3 className="text-base font-semibold text-foreground">{title}</h3>
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
import { AdminStatusBadge } from "@/components/admin/admin-status-badge";
|
||||
import { resolveAdminStatusTone } from "@/lib/admin-status-tone";
|
||||
|
||||
export function ConfigStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation("config");
|
||||
const label = t(`versionStatus.${status}`, { defaultValue: status });
|
||||
const className =
|
||||
status === "active"
|
||||
? "border-primary/30 bg-primary/10 text-primary"
|
||||
: status === "draft"
|
||||
? "border-border bg-secondary text-secondary-foreground"
|
||||
: "border-border/80 bg-muted text-muted-foreground";
|
||||
|
||||
return (
|
||||
<Badge variant="outline" className={cn("font-medium tabular-nums", className)}>
|
||||
<AdminStatusBadge status={status} tone={resolveAdminStatusTone(status)}>
|
||||
{label}
|
||||
</Badge>
|
||||
</AdminStatusBadge>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { AdminStatusBadge } from "@/components/admin/admin-status-badge";
|
||||
import { ConfigReadonlyValue } from "@/modules/config/config-readonly-value";
|
||||
import { ConfigVersionActions } from "@/modules/config/config-version-actions";
|
||||
import { ConfigVersionSwitcher } from "@/modules/config/config-version-switcher";
|
||||
@@ -499,11 +500,13 @@ export function PlayConfigDocScreen() {
|
||||
aria-label={t("play.aria.enablePlay", { ns: "config", playCode: row.play_code })}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue className="justify-center">
|
||||
{row.is_enabled
|
||||
? t("play.states.enabled", { ns: "config" })
|
||||
: t("play.states.disabled", { ns: "config" })}
|
||||
</ConfigReadonlyValue>
|
||||
<div className="flex justify-center">
|
||||
<AdminStatusBadge status={row.is_enabled ? "enabled" : "disabled"}>
|
||||
{row.is_enabled
|
||||
? t("play.states.enabled", { ns: "config" })
|
||||
: t("play.states.disabled", { ns: "config" })}
|
||||
</AdminStatusBadge>
|
||||
</div>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
@@ -595,7 +598,9 @@ export function PlayConfigDocScreen() {
|
||||
{t("play.actions.ruleText", { ns: "config" })}
|
||||
</Button>
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">{t("play.states.readOnly", { ns: "config" })}</span>
|
||||
<AdminStatusBadge status="disabled" className="mx-auto w-fit">
|
||||
{t("play.states.readOnly", { ns: "config" })}
|
||||
</AdminStatusBadge>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user