"use client" import { useState, useEffect } from "react" import { useRouter } from "next/navigation" import Link from "next/link" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { ArrowLeft, Edit } from "lucide-react" import { toast } from "sonner" import { use } from "react" interface ProjectProfile { id: number name: string memo: string companyId: number createTime: string account: string phone: string | null deviceCount: number friendCount: number userCount: number } interface Device { id: number memo: string phone: string model: string brand: string alive: number deviceId: number wechatId: string friendCount: number wAlive: number imei: string } export default function ProjectDetailPage({ params }: { params: { id: string } }) { const router = useRouter() const [isLoading, setIsLoading] = useState(true) const [profile, setProfile] = useState(null) const [devices, setDevices] = useState([]) const [activeTab, setActiveTab] = useState("overview") const { id } = use(params) useEffect(() => { const fetchProjectProfile = async () => { try { const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/company/profile/${id}`) const data = await response.json() if (data.code === 200) { setProfile(data.data) } else { toast.error(data.msg || "获取项目信息失败") } } catch (error) { toast.error("网络错误,请稍后重试") } finally { setIsLoading(false) } } fetchProjectProfile() }, [id]) useEffect(() => { const fetchDevices = async () => { if (activeTab === "devices") { try { const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/company/devices?companyId=${id}`) const data = await response.json() if (data.code === 200) { setDevices(data.data) } else { toast.error(data.msg || "获取设备列表失败") } } catch (error) { toast.error("网络错误,请稍后重试") } } } fetchDevices() }, [activeTab, id]) if (isLoading) { return
加载中...
} if (!profile) { return
未找到项目信息
} return (

{profile.name}

项目概览 关联设备 子账号 基本信息
项目名称
{profile.name}
手机号
{profile.phone || "未设置"}
账号
{profile.account}
创建时间
{profile.createTime}
项目介绍
{profile.memo}
关联设备数
{profile.deviceCount}
子账号数
{profile.userCount}
微信好友总数
{profile.friendCount}
关联设备列表 项目关联的所有设备及其微信好友数量 设备名称 设备型号 品牌 IMEI 设备状态 微信状态 微信好友数量 {devices.map((device) => ( {device.memo} {device.model} {device.brand} {device.imei} {device.alive === 1 ? "在线" : "离线"} {device.wAlive === 1 ? "在线" : device.wAlive === 0 ? "离线" : "未登录微信"} {device.friendCount || 0} ))}
子账号列表 项目下的所有子账号 账号名称 创建时间 {/* Assuming subAccounts are fetched from the profile */} {/* Replace with actual subAccounts data */} {/* {profile.subAccounts.map((account) => ( {account.username} {account.createdAt} ))} */}
) }