feat:前端

This commit is contained in:
2026-09-14 11:54:20 +08:00
parent 86b13c6484
commit e2e1d73b3d
46 changed files with 4477 additions and 128 deletions
+30
View File
@@ -0,0 +1,30 @@
"use client";
import { usePathname } from "next/navigation";
import { useEffect, useState } from "react";
import { apiFetch } from "@/lib/api";
import { AgentChat } from "@/components/agent-chat";
interface CurrentUser {
user_type?: string;
employee_role?: string | null;
}
export function AgentMount() {
const pathname = usePathname();
const [employee, setEmployee] = useState(false);
useEffect(() => {
if (!pathname.startsWith("/admin")) return;
void apiFetch<{ user: CurrentUser }>("/auth/me")
.then(({ user }) => {
const advisorRole = user.employee_role === "投顾" || user.employee_role === "投顾专员" || user.employee_role === "ADMIN";
setEmployee((user.user_type === "EMPLOYEE" || user.user_type === "ADMIN") && advisorRole);
})
.catch(() => setEmployee(false));
}, [pathname]);
if (pathname.startsWith("/admin") && employee) return <AgentChat employeeMode />;
if (pathname.startsWith("/admin")) return null;
return <AgentChat />;
}