Skip to content

Commit 9e73e4e

Browse files
committed
修复 iframe 加载旧会话的问题
问题分析: - Dify WebApp 尝试加载不存在的 conversation_id - 导致显示"Conversation Not Exists"错误 解决方案: 1. 添加时间戳参数确保每次加载都是新会话 2. 添加 key 属性强制 React 重新渲染 iframe 3. 避免 iframe 读取旧的缓存数据
1 parent b822293 commit 9e73e4e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/App.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,9 @@ export default function App() {
955955
setAiLoading(false);
956956
setShowAiModal(true);
957957

958-
// 由于浏览器 CORS 限制,直接使用 iframe 嵌入 Dify WebApp
959-
// 用户需要在 iframe 中手动输入或粘贴题目
960-
setAiIframeUrl(`https://udify.app/chatbot/xg0maoDg7kzrcGT0`);
958+
// 添加时间戳参数,确保每次都是新会话,避免加载旧的 conversation_id
959+
const timestamp = Date.now();
960+
setAiIframeUrl(`https://udify.app/chatbot/xg0maoDg7kzrcGT0?t=${timestamp}`);
961961
}, []);
962962

963963
const closeAiModal = useCallback(() => {
@@ -1765,6 +1765,7 @@ export default function App() {
17651765
style={{ width: '100%', height: '100%', border: 'none' }}
17661766
title="AI 解析助手"
17671767
allow="microphone"
1768+
key={aiIframeUrl}
17681769
/>
17691770
</div>
17701771
</>

0 commit comments

Comments
 (0)