refactor(router): introduce app navigation manager

This commit is contained in:
2026-07-03 14:09:13 +08:00
parent 8a586e4471
commit 91dde42f92
23 changed files with 669 additions and 277 deletions
@@ -16,9 +16,7 @@
* 不做的事:
* - 不直接管理 state machinechat 机器不感知 UI 层)
*/
import { useRouter } from "next/navigation";
import { ROUTE_BUILDERS } from "@/router/routes";
import { useAppNavigator } from "@/router/use-app-navigator";
import styles from "./chat-insufficient-credits-banner.module.css";
@@ -26,7 +24,7 @@ export interface ChatInsufficientCreditsBannerProps {
title?: string;
ctaLabel?: string;
/**
* 自定义点击回调(不传则默认 router.push(topup subscription)
* 自定义点击回调(不传则默认走统一订阅导航
* - 测试时可传 mock
* - 嵌入其他场景时(如 nested overlay)可传自定义
*/
@@ -38,7 +36,7 @@ export function ChatInsufficientCreditsBanner({
ctaLabel = "Top up credits to continue",
onUnlock,
}: ChatInsufficientCreditsBannerProps) {
const router = useRouter();
const navigator = useAppNavigator();
const titleLines = title.split("\n");
const handleClick = () => {
@@ -46,7 +44,7 @@ export function ChatInsufficientCreditsBanner({
onUnlock();
return;
}
router.push(ROUTE_BUILDERS.subscription("topup"));
navigator.openSubscription({ type: "topup", returnTo: "chat" });
};
return (