fix: ScriptView loadMessages 对临时 conversationId 正则短路保护
This commit is contained in:
@@ -661,11 +661,21 @@ const continueCurrentVersion = () => {
|
||||
}
|
||||
|
||||
const loadMessages = async () => {
|
||||
// 短路保护:conversationId 为空时不请求接口,显示友好提示
|
||||
if (!conversationId.value) {
|
||||
uni.showToast({ title: '暂无对话记录', icon: 'none' })
|
||||
if (!conversationId.value) return
|
||||
|
||||
// 临时 ID 短路保护:
|
||||
// 当 conversationId 是 ensureConversationId() 在前端自造的 `conv-<ts>-<rand>` 形式,
|
||||
// 且没有 script.conversationId 背书(即后端还没通过 createWithDialogue 落库),
|
||||
// 此时去查 listByConversation 必然是空且会产生 5xx 噪音。
|
||||
// 在 streamScriptChat 第一次成功落库前,直接跳过查询。
|
||||
const looksLikeTempId = /^conv-\d+-[a-z0-9]{6}$/.test(conversationId.value)
|
||||
const backedByScript = Boolean(currentResult.value?.conversationId)
|
||||
if (looksLikeTempId && !backedByScript) {
|
||||
messages.value = []
|
||||
versions.value = []
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await listMessagesByConversation({ conversationId: conversationId.value, includeVersions: false })
|
||||
messages.value = res.data || []
|
||||
|
||||
Reference in New Issue
Block a user