Dockerfile打包使用pnpm

next.js打包忽略eslint和typescript报错导致打包失败的问题
ant-design引入兼容包,以兼容React19
eslint配置文件由json更换成js
反馈内容由写死的改为获取当前的conversationid会话ID,反馈的用户名称username从cookie里获取
反馈弹窗弹出时使用Promise异步等待如果没有点击确定,则不传递给dify已反馈成功请求
This commit is contained in:
2025-07-14 16:26:45 +08:00
parent d1a47297bf
commit d2d96ab315
18 changed files with 201 additions and 128 deletions
+15 -10
View File
@@ -1,12 +1,17 @@
import { type NextRequest } from 'next/server'
import { NextResponse } from 'next/server'
import { client, getInfo } from '@/app/api/utils/common'
import { type NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { client, getInfo } from "@/app/api/utils/common";
export async function POST(request: NextRequest, { params }: {
params: { taskId: string }
}) {
const { taskId } = await params
const { user } = getInfo(request)
const { data } = await client.stopChat(taskId, user)
return NextResponse.json(data)
export async function POST(
request: NextRequest,
{
params,
}: {
params: Promise<{ taskId: string }>;
}
) {
const { taskId } = await params;
const { user } = getInfo(request);
const { data } = await client.stopChat(taskId, user);
return NextResponse.json(data);
}
@@ -1,19 +1,26 @@
import { type NextRequest } from 'next/server'
import { NextResponse } from 'next/server'
import { client, getInfo } from '@/app/api/utils/common'
import { type NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { client, getInfo } from "@/app/api/utils/common";
export async function POST(request: NextRequest, { params }: {
params: { conversationId: string }
}) {
const body = await request.json()
const {
auto_generate,
name,
} = body
const { conversationId } = await params
const { user } = getInfo(request)
export async function POST(
request: NextRequest,
{
params,
}: {
params: Promise<{ conversationId: string }>;
}
) {
const body = await request.json();
const { auto_generate, name } = body;
const { conversationId } = await params;
const { user } = getInfo(request);
// auto generate name
const { data } = await client.renameConversation(conversationId, name, user, auto_generate)
return NextResponse.json(data)
const { data } = await client.renameConversation(
conversationId,
name,
user,
auto_generate
);
return NextResponse.json(data);
}
+16 -11
View File
@@ -1,13 +1,18 @@
import { type NextRequest } from 'next/server'
import { NextResponse } from 'next/server'
import { client, getInfo } from '@/app/api/utils/common'
import { type NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { client, getInfo } from "@/app/api/utils/common";
export async function DELETE(request: NextRequest, { params }: {
params: { conversationId: string }
}) {
const { conversationId } = await params
const { user } = await getInfo(request)
export async function DELETE(
request: NextRequest,
{
params,
}: {
params: Promise<{ conversationId: string }>;
}
) {
const { conversationId } = await params;
const { user } = await getInfo(request);
const { data } = await client.deleteConversation(conversationId, user)
return NextResponse.json(data)
}
const { data } = await client.deleteConversation(conversationId, user);
return NextResponse.json(data);
}
+17 -14
View File
@@ -1,16 +1,19 @@
import { type NextRequest } from 'next/server'
import { NextResponse } from 'next/server'
import { client, getInfo } from '@/app/api/utils/common'
import { type NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { client, getInfo } from "@/app/api/utils/common";
export async function POST(request: NextRequest, { params }: {
params: { messageId: string }
}) {
const body = await request.json()
const {
rating,
} = body
const { messageId } = await params
const { user } = getInfo(request)
const { data } = await client.messageFeedback(messageId, rating, user)
return NextResponse.json(data)
export async function POST(
request: NextRequest,
{
params,
}: {
params: Promise<{ messageId: string }>;
}
) {
const body = await request.json();
const { rating } = body;
const { messageId } = await params;
const { user } = getInfo(request);
const { data } = await client.messageFeedback(messageId, rating, user);
return NextResponse.json(data);
}
@@ -1,10 +1,17 @@
import { type NextRequest } from 'next/server'
import { NextResponse } from 'next/server'
import { client, getInfo } from '@/app/api/utils/common'
import { type NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { client, getInfo } from "@/app/api/utils/common";
export async function GET(request: NextRequest, params: { messageId: string }) {
const { messageId } = await params
const { user } = getInfo(request)
const { data }: any = await client.getSuggested(messageId, user,)
return NextResponse.json(data)
export async function GET(
request: NextRequest,
{
params,
}: {
params: Promise<{ messageId: string }>;
}
) {
const { messageId } = await params;
const { user } = getInfo(request);
const { data }: any = await client.getSuggested(messageId, user);
return NextResponse.json(data);
}
+22 -12
View File
@@ -1,20 +1,30 @@
import { type NextRequest } from 'next/server'
import { ChatClient } from 'dify-client-plus'
import { v4 } from 'uuid'
import { API_KEY, API_URL } from '@/config'
import { type NextRequest } from "next/server";
import { ChatClient } from "dify-client-plus";
import { v4 } from "uuid";
import { API_KEY, API_URL } from "@/config";
export const getInfo = (request: NextRequest) => {
const username = request.cookies.get('username')?.value || 'no-user'
const sessionId = request.cookies.get('session_id')?.value || v4()
const user = `${username}`
const username = request.cookies.get("username")?.value || "no-user";
const sessionId = request.cookies.get("session_id")?.value || v4();
const user = `${username}`;
return {
sessionId,
user,
}
}
};
};
export const setSession = (sessionId: string) => {
return { 'Set-Cookie': `session_id=${sessionId}` }
}
return { "Set-Cookie": `session_id=${sessionId}` };
};
export const client = new ChatClient(API_KEY, API_URL || undefined)
export const client = new ChatClient(API_KEY, API_URL || undefined);
export function getCookieValue(cookieName: string): string | null {
const cookies = document.cookie.split("; ").reduce((acc, cookie) => {
const [name, value] = cookie.split("=");
acc[name] = value;
return acc;
}, {} as Record<string, string>);
return cookies[cookieName] || null;
}