refactor: 优化管理端配置页加载与导航,更新本地端口说明

This commit is contained in:
2026-05-18 11:28:19 +08:00
parent fae8c1ae01
commit afffa4e508
6 changed files with 11 additions and 24 deletions

View File

@@ -9,10 +9,11 @@ function pad2(n: number): string {
*/
export function formatAdminInstant(
iso: string | null | undefined,
_options: {
options: {
locale: AdminApiLocale;
},
): string {
void options;
if (iso == null || iso === "") {
return "—";
}

View File

@@ -1,13 +1,11 @@
"use client";
import { useMemo } from "react";
import type { ReactNode } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { cn } from "@/lib/utils";
import { CONFIG_NAV_GROUPS } from "@/modules/config/config-nav-model";
import { configHubMeta } from "@/modules/config/meta";
function navLinkActive(pathname: string, href: string): boolean {
return pathname === href || pathname.startsWith(`${href}/`);
@@ -15,20 +13,6 @@ function navLinkActive(pathname: string, href: string): boolean {
export function ConfigWorkspaceShell({ children }: { children: ReactNode }) {
const pathname = usePathname() ?? "";
const activeNav = useMemo(() => {
for (const group of CONFIG_NAV_GROUPS) {
for (const item of group.items) {
if (navLinkActive(pathname, item.href)) {
return { group, item };
}
}
}
return null;
}, [pathname]);
const title = activeNav?.item.title ?? configHubMeta.title;
const description = activeNav?.item.description || configHubMeta.description;
const groupLabel = activeNav?.group.label ?? "总览";
return (
<div className="mx-auto flex w-full max-w-7xl flex-col gap-6">

View File

@@ -70,7 +70,7 @@ export function WalletConfigDocScreen() {
setDraft(d);
setSaved(d);
setDirty(false);
} catch (e) {
} catch {
toast.error("加载失败");
} finally {
setLoading(false);
@@ -78,7 +78,9 @@ export function WalletConfigDocScreen() {
}, []);
useEffect(() => {
void load();
queueMicrotask(() => {
void load();
});
}, [load]);
const handleChange = (field: keyof Draft, value: string) => {
@@ -96,8 +98,8 @@ export function WalletConfigDocScreen() {
toast.success("保存成功");
setSaved(draft);
setDirty(false);
} catch (e) {
toast.error(e instanceof LotteryApiBizError ? e.message : "保存失败");
} catch (error) {
toast.error(error instanceof LotteryApiBizError ? error.message : "保存失败");
} finally {
setSaving(false);
}