feat(chat): migrate chat to backend API

This commit is contained in:
zetaloop
2026-03-01 17:03:30 +08:00
parent f189ec9846
commit e2671638e6
6 changed files with 223 additions and 76 deletions
+20 -2
View File
@@ -3,15 +3,33 @@
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import { Card, CardContent } from "@/components/ui/card"
import { listChatSessions } from "@/lib/api"
import { useAuthStore } from "@/store/auth"
import { useChatStore } from "@/store/chat"
import { Lock, MessageSquare } from "lucide-react"
import Link from "next/link"
import { useEffect, useState } from "react"
export default function ChatListPage() {
const sessions = useChatStore((state) => state.sessions)
const [sessions, setSessions] = useState<Awaited<ReturnType<typeof listChatSessions>>>([])
const userId = useAuthStore((state) => state.user?.id)
useEffect(() => {
let cancelled = false
void (async () => {
try {
const result = await Promise.resolve(listChatSessions())
if (!cancelled) setSessions(result)
} catch {
if (!cancelled) setSessions([])
}
})()
return () => {
cancelled = true
}
}, [])
return (
<div className="container mx-auto max-w-2xl px-4 py-8 space-y-6">
<h1 className="text-2xl font-bold"></h1>