From 865ad31f2fda10ce0bf26da3b2afc54b8453b18f Mon Sep 17 00:00:00 2001 From: zhaoying Date: Fri, 6 Mar 2026 19:44:34 +0800 Subject: [PATCH] fix(web): chat file delete bugfix --- web/src/components/Chat/ChatInput.tsx | 6 +++++- web/src/utils/request.ts | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/web/src/components/Chat/ChatInput.tsx b/web/src/components/Chat/ChatInput.tsx index 8c8dce1a..508b0d0c 100644 --- a/web/src/components/Chat/ChatInput.tsx +++ b/web/src/components/Chat/ChatInput.tsx @@ -50,7 +50,11 @@ const ChatInput: FC = ({ const handleDelete = (file: any) => { - fileChange?.(fileList?.filter(item => file.url ? item.url !== file.url : item.uid !== file.uid) || []) + fileChange?.(fileList?.filter(item => { + return item.thumbUrl && file.thumbUrl ? item.thumbUrl !== file.thumbUrl + : item.url && file.url ? item.url !== file.url + : item.uid !== file.uid + }) || []) } // Convert file object to preview URL const previewFileList = useMemo(() => { diff --git a/web/src/utils/request.ts b/web/src/utils/request.ts index 03941960..3f81d4ab 100644 --- a/web/src/utils/request.ts +++ b/web/src/utils/request.ts @@ -356,12 +356,11 @@ export const request = { * Get parent domain for cookie setting * @returns Parent domain or IP address */ +const isIp = (hostname: string) => /^\d+\.\d+\.\d+\.\d+$/.test(hostname) + const getParentDomain = () => { const hostname = window.location.hostname - // Check if it's an IP address - if (/^\d+\.\d+\.\d+\.\d+$/.test(hostname)) { - return hostname - } + if (isIp(hostname)) return hostname const parts = hostname.split('.') return parts.length > 2 ? `.${parts.slice(-2).join('.')}` : hostname } @@ -371,7 +370,10 @@ const getParentDomain = () => { */ export const cookieUtils = { set: (name: string, value: string, domain = getParentDomain()) => { - document.cookie = `${name}=${value}; domain=${domain}; path=/; secure; samesite=strict` + const ip = isIp(window.location.hostname) + const domainPart = ip ? '' : `; domain=${domain}` + const securePart = window.location.protocol === 'https:' ? '; secure' : '' + document.cookie = `${name}=${value}${domainPart}; path=/${securePart}; samesite=strict` }, get: (name: string) => { const value = `; ${document.cookie}`