feat: add thread status read views
This commit is contained in:
34
src/app/api/v1/projects/[projectId]/thread-status/route.ts
Normal file
34
src/app/api/v1/projects/[projectId]/thread-status/route.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { requireRequestSession } from "@/lib/boss-auth";
|
||||
import { readState } from "@/lib/boss-data";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ projectId: string }> },
|
||||
) {
|
||||
const session = await requireRequestSession(request);
|
||||
if (!session) {
|
||||
return NextResponse.json({ ok: false, message: "UNAUTHORIZED" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { projectId } = await context.params;
|
||||
const state = await readState();
|
||||
const project = state.projects.find((item) => item.id === projectId);
|
||||
if (!project) {
|
||||
return NextResponse.json({ ok: false, message: "PROJECT_NOT_FOUND" }, { status: 404 });
|
||||
}
|
||||
|
||||
const threadStatusDocument =
|
||||
state.threadStatusDocuments.find((item) => item.projectId === projectId) ?? null;
|
||||
const recentProgressEvents = state.threadProgressEvents
|
||||
.filter((item) => item.projectId === projectId)
|
||||
.sort((a, b) => b.createdAt.localeCompare(a.createdAt))
|
||||
.slice(0, 5);
|
||||
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
projectId,
|
||||
threadStatusDocument,
|
||||
recentProgressEvents,
|
||||
});
|
||||
}
|
||||
@@ -762,7 +762,7 @@ export function ChatBubble({ message }: { message: Message }) {
|
||||
|
||||
export function ProjectHeaderActions({ projectId }: { projectId: string }) {
|
||||
return (
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||
<Link
|
||||
href={`/conversations/${projectId}/goals`}
|
||||
className="flex h-11 items-center justify-center rounded-2xl bg-[#EAF7F0] text-[14px] font-semibold text-[#215B39]"
|
||||
@@ -781,6 +781,14 @@ export function ProjectHeaderActions({ projectId }: { projectId: string }) {
|
||||
>
|
||||
转发
|
||||
</Link>
|
||||
<Link
|
||||
href={`/api/v1/projects/${projectId}/thread-status`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="flex h-11 items-center justify-center rounded-2xl bg-white text-[14px] font-semibold text-[#111111]"
|
||||
>
|
||||
线程状态
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user