"use client" import { useState } from "react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { login, getUserInfo } from "@/lib/api/auth" export function ApiTester() { const [testAccount, setTestAccount] = useState("13800138000") const [testPassword, setTestPassword] = useState("123456") const [testResult, setTestResult] = useState(null) const [isLoading, setIsLoading] = useState(false) const testLogin = async () => { setIsLoading(true) try { const result = await login({ account: testAccount, password: testPassword, typeid: 1, }) setTestResult(result) } catch (error) { setTestResult({ error: error instanceof Error ? error.message : "测试失败" }) } finally { setIsLoading(false) } } const testUserInfo = async () => { setIsLoading(true) try { const result = await getUserInfo() setTestResult(result) } catch (error) { setTestResult({ error: error instanceof Error ? error.message : "测试失败" }) } finally { setIsLoading(false) } } return ( API测试工具 开发模式
setTestAccount(e.target.value)} /> setTestPassword(e.target.value)} />
{testResult && (
{JSON.stringify(testResult, null, 2)}
)}
) }