🐛 fix(im): conversation.messages 入 IDB 前用 toRaw 解 Proxy,否则 structuredClone 抛 DataCloneError 静默丢消息
parent
f1d44c8267
commit
9a4e79e4ef
|
|
@ -1,4 +1,5 @@
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
import { toRaw } from 'vue'
|
||||||
import { store } from '@/store'
|
import { store } from '@/store'
|
||||||
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
||||||
|
|
||||||
|
|
@ -168,10 +169,12 @@ export const useConversationStore = defineStore('imConversationStore', {
|
||||||
Array.isArray(target) ? target : target ? [target] : []
|
Array.isArray(target) ? target : target ? [target] : []
|
||||||
).filter((c) => !c.deleted)
|
).filter((c) => !c.deleted)
|
||||||
for (const conversation of conversationsToFlush) {
|
for (const conversation of conversationsToFlush) {
|
||||||
|
// toRaw 拆掉 Vue reactive Proxy:IDB 的 structuredClone 不接受 Proxy,
|
||||||
|
// 不拆会抛 DataCloneError 静默落盘失败(只 meta 写得进去,messages 永远丢)
|
||||||
tasks.push(
|
tasks.push(
|
||||||
imStorage.setItem(
|
imStorage.setItem(
|
||||||
StorageKeys.conversationMessage(userId, conversation.type, conversation.targetId),
|
StorageKeys.conversationMessage(userId, conversation.type, conversation.targetId),
|
||||||
conversation.messages
|
toRaw(conversation.messages)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue