refactor: 优化管理端配置页加载与导航,更新本地端口说明
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user