feat: 生成sketch时插入到前方
This commit is contained in:
@@ -227,7 +227,7 @@
|
||||
configParams: JSON.stringify(params.configParams)
|
||||
})
|
||||
const BASEURL = import.meta.env.VITE_APP_URL
|
||||
|
||||
|
||||
const response = await fetch(`${BASEURL}${chatUrl}?${urlParams.toString()}`, {
|
||||
method: 'GET',
|
||||
signal: abortController.signal
|
||||
@@ -668,14 +668,14 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 防止插入重复图片
|
||||
const mergeUniqueKeys = (targetArr, newData) => {
|
||||
// 提取现有数组中所有的 key,存入 Set 以实现 O(1) 查询
|
||||
const existingKeys = new Set(targetArr.flatMap((item) => Object.keys(item)))
|
||||
|
||||
Object.entries(newData).forEach(([key, value]) => {
|
||||
if (!existingKeys.has(key)) {
|
||||
targetArr.push({ [key]: value })
|
||||
existingKeys.add(key) // 防止 newData 内部有重复 key 时重复插入
|
||||
targetArr.unshift({ [key]: value })
|
||||
existingKeys.add(key)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user