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
@@ -11,7 +11,7 @@ import { ToastContext } from '@/app/components/base/toast'
import Loading from '@/app/components/base/loading'
// import { fetchAgentLogDetail } from '@/service/log'
// TODO
const fetchAgentLogDetail = () => {
const fetchAgentLogDetail: any = (data: any) => {
console.log('TODO MARS')
}
+1 -2
View File
@@ -39,8 +39,7 @@ const AnswerIcon: FC<AnswerIconProps> = ({
>
{isValidImageIcon
? <img src={imageUrl} className="w-full h-full rounded-full" alt="answer icon" />
: (icon && icon !== '') ? <em-emoji id={icon} /> : <em-emoji id='🤖' />
}
: (icon && icon !== '') ? (<em-emoji id={icon} />) : (<em-emoji id='🤖' />) }
</div>
}
+2 -2
View File
@@ -46,7 +46,7 @@ export type ChatWithHistoryContextValue = {
isMobile: boolean
isInstalledApp: boolean
appId?: string
handleFeedback: (messageId: string, feedback: Feedback) => void
handleFeedback: (messageId: string, feedback: Feedback) => Promise<boolean>
currentChatInstanceRef: RefObject<{ handleStop: () => void }>
themeBuilder?: ThemeBuilder
}
@@ -73,7 +73,7 @@ export const ChatWithHistoryContext = createContext<ChatWithHistoryContextValue>
chatShouldReloadKey: '',
isMobile: false,
isInstalledApp: false,
handleFeedback: () => { },
handleFeedback: () => new Promise(() => { }),
currentChatInstanceRef: { current: { handleStop: () => { } } },
})
export const useChatWithHistoryContext = () => useContext(ChatWithHistoryContext)
+30 -12
View File
@@ -4,7 +4,7 @@ import useSWR from "swr";
import { useLocalStorageState } from "ahooks";
import { produce } from "immer";
import { message } from "antd";
import { client, getInfo } from "@/app/api/utils/common";
import { client, getCookieValue } from "@/app/api/utils/common";
import type { Callback, ChatConfig, ChatItem, Feedback } from "../types";
import { CONVERSATION_ID_INFO } from "../constants";
import { buildChatItemTree } from "../utils";
@@ -537,12 +537,19 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
setCurrentConversationIdForFeedback,
] = useState<string | null>(null);
const [resolveFeedback, setResolveFeedback] = useState<(value: boolean | PromiseLike<boolean>) => void | null>(null);
const handleFeedback = useCallback(
(messageId: string, feedback: Feedback, conversationId: string) => {
setCurrentMessageId(messageId);
setCurrentFeedback(feedback);
setCurrentConversationIdForFeedback(conversationId);
setIsFeedbackModalVisible(true);
return new Promise<boolean>((resolve) => {
console.log('handleFeedback', messageId, feedback, conversationId);
setCurrentMessageId(messageId);
setCurrentFeedback(feedback);
setCurrentConversationIdForFeedback(conversationId);
setIsFeedbackModalVisible(true);
setResolveFeedback(() => resolve);
})
},
[]
);
@@ -557,9 +564,9 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
const requestBody = {
operationType: selectedOption, // 0 或 1
feedbackText, // 用户反馈建议
conversationId: '89fba8a7-e4e2-4167-8b7c-b3c103797053', // 会话 ID
conversationId: currentConversationId, // 会话 ID
messageId: currentMessageId, // 消息 ID
username: "user_admin", // 用户名
username: getCookieValue('username'), // 用户名
};
// 调用 Java 接口
@@ -578,15 +585,20 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
await updateFeedback(
{
url: `/messages/${currentMessageId}/feedbacks`,
body: { rating: currentFeedback.rating },
body: { rating: currentFeedback!.rating },
},
isInstalledApp,
appId
// isInstalledApp,
// appId
);
// 显示成功通知
notify({ type: "success", message: t("common.api.success") });
if (resolveFeedback) {
resolveFeedback(true); // 用户取消了反馈
setResolveFeedback(null);
}
// 关闭对话框
setIsFeedbackModalVisible(false);
} catch (error) {
@@ -597,7 +609,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
[
currentMessageId,
currentFeedback,
currentConversationIdForFeedback,
currentConversationId,
isInstalledApp,
appId,
notify,
@@ -649,7 +661,13 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
<FeedbackModal
open={isFeedbackModalVisible}
onOk={handleFeedbackSubmit}
onCancel={() => setIsFeedbackModalVisible(false)}
onCancel={() => {
if (resolveFeedback) {
resolveFeedback(false); // 用户取消了反馈
setResolveFeedback(null);
}
setIsFeedbackModalVisible(false)
}}
/>
),
};
+4 -3
View File
@@ -75,8 +75,9 @@ const Operation: FC<OperationProps> = ({
if (!config?.supportFeedback || !onFeedback)
return
await onFeedback?.(id, { rating })
setLocalFeedback({ rating })
if (await onFeedback?.(id, { rating })) {
setLocalFeedback({ rating })
}
}
const operationWidth = useMemo(() => {
@@ -138,7 +139,7 @@ const Operation: FC<OperationProps> = ({
)}
</div>
)}
{/*
{/*
{(!isOpeningStatement && config?.supportAnnotation && config.annotation_reply?.enabled) && (
<AnnotationCtrlBtn
appId={config?.appId || ''}
+1 -1
View File
@@ -60,7 +60,7 @@ export type ChatProps = {
onAnnotationAdded?: (annotationId: string, authorName: string, question: string, answer: string, index: number) => void
onAnnotationRemoved?: (index: number) => void
chatNode?: ReactNode
onFeedback?: (messageId: string, feedback: Feedback) => void
onFeedback?: (messageId: string, feedback: Feedback) => Promise<boolean>
chatAnswerContainerInner?: string
hideProcessDetail?: boolean
hideLogModal?: boolean