Skip to content

Commit

Permalink
Merge pull request #11 from suwubee/dev-split
Browse files Browse the repository at this point in the history
修复messages保存bug
  • Loading branch information
suwubee authored Jan 21, 2025
2 parents b995509 + c23551e commit 31caf85
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 10 deletions.
6 changes: 3 additions & 3 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "./static/css/main.5c16e056.css",
"main.js": "./static/js/main.217e6868.js",
"main.js": "./static/js/main.c8786bd5.js",
"static/js/139.cdc23c38.chunk.js": "./static/js/139.cdc23c38.chunk.js",
"index.html": "./index.html",
"main.5c16e056.css.map": "./static/css/main.5c16e056.css.map",
"main.217e6868.js.map": "./static/js/main.217e6868.js.map",
"main.c8786bd5.js.map": "./static/js/main.c8786bd5.js.map",
"139.cdc23c38.chunk.js.map": "./static/js/139.cdc23c38.chunk.js.map"
},
"entrypoints": [
"static/css/main.5c16e056.css",
"static/js/main.217e6868.js"
"static/js/main.c8786bd5.js"
]
}
2 changes: 1 addition & 1 deletion build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="./logo192.png"/><link rel="manifest" href="./manifest.json"/><title>React App</title><script defer="defer" src="./static/js/main.217e6868.js"></script><link href="./static/css/main.5c16e056.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="基于多模型的思维链生成器,支持流程设计、大纲生成和详细内容编写"/><link rel="apple-touch-icon" href="./logo192.png"/><link rel="manifest" href="./manifest.json"/><title>AI Chain of Thought Generator</title><script defer="defer" src="./static/js/main.c8786bd5.js"></script><link href="./static/css/main.5c16e056.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1 change: 0 additions & 1 deletion build/static/js/main.217e6868.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/static/js/main.c8786bd5.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="基于多模型的思维链生成器,支持流程设计、大纲生成和详细内容编写"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
Expand All @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>AI Chain of Thought Generator</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
34 changes: 34 additions & 0 deletions src/ChatInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,26 @@ export default function ChatInterface() {

// 统一的消息和聊天历史同步
useEffect(() => {
// 如果消息为空且有当前聊天索引,创建新的空聊天
if (messages.length === 0 && currentChatIndex !== null) {
const newHistory = saveChatHistory([], null, {
node1: 1,
node2: 1,
node3: 1,
node4: 1,
}, selectedConfig);

setChatHistories((prev) => {
const updated = [...prev];
updated[currentChatIndex] = newHistory;
return updated;
});

// 清除本地存储的消息
localStorage.removeItem('messages');
return;
}

if (messages.length > 0) {
// 更新本地存储中的消息
localStorage.setItem('messages', JSON.stringify(messages));
Expand All @@ -338,6 +358,20 @@ export default function ChatInterface() {
if (chatHistories.length > 0 && currentChatIndex !== null) {
saveChatHistoriesToStorage(chatHistories);
saveCurrentChatIndex(currentChatIndex);
} else if (chatHistories.length === 0) {
// 如果没有聊天历史,清除所有相关存储
localStorage.removeItem('chatHistories');
localStorage.removeItem('currentChatIndex');
localStorage.removeItem('messages');
// 重置当前状态
setMessages([]);
setMainStructure(null);
setCurrentNodeIndexes({
node1: 1,
node2: 1,
node3: 1,
node4: 1,
});
}
}, [chatHistories, currentChatIndex]);

Expand Down

0 comments on commit 31caf85

Please sign in to comment.