next.js打包忽略eslint和typescript报错导致打包失败的问题 ant-design引入兼容包,以兼容React19 eslint配置文件由json更换成js 反馈内容由写死的改为获取当前的conversationid会话ID,反馈的用户名称username从cookie里获取 反馈弹窗弹出时使用Promise异步等待如果没有点击确定,则不传递给dify已反馈成功请求
31 lines
916 B
TypeScript
31 lines
916 B
TypeScript
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}`;
|
|
return {
|
|
sessionId,
|
|
user,
|
|
};
|
|
};
|
|
|
|
export const setSession = (sessionId: string) => {
|
|
return { "Set-Cookie": `session_id=${sessionId}` };
|
|
};
|
|
|
|
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;
|
|
}
|