5 小时以前 74f94cbb16aae6a16da39f5f38b3ac7daf0b4bbe
feat(knowledgeBase): 添加知识库问答UUID生成兼容性支持

- 实现generateUUID函数作为crypto.randomUUID的fallback方案
- 在不支持crypto.randomUUID的环境中使用自定义UUID生成算法
- 确保知识库问答功能在各种浏览器环境下的正常运行
已修改1个文件
17 ■■■■ 文件已修改
src/views/collaborativeApproval/knowledgeBase/index.vue 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/collaborativeApproval/knowledgeBase/index.vue
@@ -1142,11 +1142,24 @@
// ============ 知识库问答相关 ============
// 生成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 = "";
};
@@ -1240,7 +1253,7 @@
    }
  ).then(() => {
    messages.value = [];
    memoryId.value = crypto.randomUUID(); // 重新生成会话ID
    memoryId.value = generateUUID(); // 重新生成会话ID
    ElMessage.success("对话已清空");
  }).catch(() => {
    // 用户取消