| | |
| | | |
| | | // ============ 知识库问答相关 ============ |
| | | |
| | | // 生成UUID的fallback方案 |
| | | const generateUUID = () => { |
| | | if (typeof crypto !== 'undefined' && crypto.randomUUID) { |
| | | return crypto.randomUUID(); |
| | | } |
| | | // fallback: 兼容不支持 crypto.randomUUID 的环境 |
| | | return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { |
| | | const r = Math.random() * 16 | 0; |
| | | const v = c === 'x' ? r : (r & 0x3 | 0x8); |
| | | return v.toString(16); |
| | | }); |
| | | }; |
| | | |
| | | // 打开问答弹窗 |
| | | const openChatDialog = (row) => { |
| | | currentKnowledgeBase.value = row; |
| | | chatDialogVisible.value = true; |
| | | memoryId.value = crypto.randomUUID(); |
| | | memoryId.value = generateUUID(); |
| | | messages.value = []; |
| | | inputQuestion.value = ""; |
| | | }; |
| | |
| | | } |
| | | ).then(() => { |
| | | messages.value = []; |
| | | memoryId.value = crypto.randomUUID(); // 重新生成会话ID |
| | | memoryId.value = generateUUID(); // 重新生成会话ID |
| | | ElMessage.success("对话已清空"); |
| | | }).catch(() => { |
| | | // 用户取消 |