fix(web): chat file delete bugfix
This commit is contained in:
@@ -50,7 +50,11 @@ const ChatInput: FC<ChatInputProps> = ({
|
||||
|
||||
|
||||
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(() => {
|
||||
|
||||
@@ -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}`
|
||||
|
||||
Reference in New Issue
Block a user