feat: 优化追问功能 - LLM智能生成 + 显示位置修复
- 修复 AuthLoader 组件中 router.push 在渲染期间调用的 React 警告
- 追问问题改为只在最新 AI 回复下方显示(修复多处显示问题)
- 新增 LLM 生成追问 API:POST /api/v1/apps/{id}/suggestions
- 前端调用 LLM API 生成智能追问,失败时降级到规则生成
- 登录页填入默认测试账号 kj-admin@govai.gov.cn
This commit is contained in:
@@ -24,22 +24,20 @@ function AuthLoader({ children }: { children: React.ReactNode }) {
|
||||
}
|
||||
}, [fetchUser, isPublic]);
|
||||
|
||||
// 鉴权路由:未登录则跳转(useEffect 中执行,避免渲染期间调用 router)
|
||||
useEffect(() => {
|
||||
if (!isLoading && !isAuthenticated && !isPublic) {
|
||||
router.push("/login");
|
||||
}
|
||||
}, [isLoading, isAuthenticated, isPublic, router]);
|
||||
|
||||
// 公开路由:直接渲染,不阻塞
|
||||
if (isPublic) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
// 鉴权路由:未登录则跳转
|
||||
if (!isLoading && !isAuthenticated) {
|
||||
router.push("/login");
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
// 加载中或未认证
|
||||
if (isLoading || !isAuthenticated) {
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary" />
|
||||
|
||||
Reference in New Issue
Block a user