Skip to content

Commit 1cfaf5c

Browse files
authored
Merge pull request #87 from heshengtao/dev
Dev
2 parents 86a880c + 2e23b11 commit 1cfaf5c

15 files changed

+1320
-137
lines changed

config/locales.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"tool_result":"工具结果",
1515
"KB_search":"知识库搜索中,请稍候...",
1616
"enter_search_stage":"进入搜索阶段",
17+
"enter_answer_stage":"进入回答阶段",
1718
"need_more_search":"需要更多搜索"
1819
},
1920
"en-US":{
@@ -31,6 +32,7 @@
3132
"tool_result":"Tool result",
3233
"KB_search":"Knowledge base search, please wait...",
3334
"enter_search_stage":"Enter the search stage",
35+
"enter_answer_stage":"Enter the answer stage",
3436
"need_more_search":"Need more search"
3537
}
3638
}

config/settings_template.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,12 @@
9696
"e2b_api_key": "",
9797
"sandbox_url":"http://127.0.0.1:8080"
9898
},
99-
"custom_http":[]
99+
"custom_http":[],
100+
"qqBotConfig": {
101+
"QQAgent":"super-model",
102+
"memoryLimit":30,
103+
"appid": "",
104+
"secret": "",
105+
"separators": ["", "\n", "", ""]
106+
}
100107
}

main.js

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const fs = require('fs')
77
const os = require('os');
88

99
let pythonExec;
10+
let isQuitting = false;
1011

1112
// 判断操作系统
1213
if (os.platform() === 'win32') {
@@ -436,6 +437,16 @@ app.whenReady().then(async () => {
436437
y: arg.y
437438
});
438439
});
440+
// 监听关闭事件
441+
ipcMain.handle('request-stop-qqbot', async (event) => {
442+
const win = BrowserWindow.getAllWindows()[0]; // 获取主窗口
443+
if (win && !win.isDestroyed()) {
444+
// 通过webContents执行渲染进程方法
445+
await win.webContents.executeJavaScript(`
446+
window.stopQQBotHandler && window.stopQQBotHandler()
447+
`);
448+
}
449+
});
439450
// 其他IPC处理...
440451
ipcMain.on('open-external', (event, url) => {
441452
shell.openExternal(url)
@@ -481,17 +492,48 @@ app.whenReady().then(async () => {
481492
}
482493
})
483494

495+
496+
484497
// 应用退出处理
485-
app.on('before-quit', () => {
486-
app.isQuitting = true
487-
if (backendProcess) {
488-
if (process.platform === 'win32') {
489-
spawn('taskkill', ['/pid', backendProcess.pid, '/f', '/t'])
490-
} else {
491-
backendProcess.kill('SIGKILL')
498+
app.on('before-quit', async (event) => {
499+
// 防止重复处理退出事件
500+
if (isQuitting) return;
501+
502+
// 标记退出状态并阻止默认退出行为
503+
isQuitting = true;
504+
event.preventDefault();
505+
506+
try {
507+
const mainWindow = BrowserWindow.getAllWindows()[0];
508+
509+
// 1. 尝试停止QQ机器人
510+
if (mainWindow && !mainWindow.isDestroyed()) {
511+
await mainWindow.webContents.executeJavaScript(`
512+
if (window.stopQQBotHandler) {
513+
window.stopQQBotHandler();
514+
}
515+
`);
516+
517+
// 等待机器人停止(最多1秒)
518+
await new Promise(resolve => setTimeout(resolve, 1000));
519+
}
520+
521+
// 2. 停止后端进程
522+
if (backendProcess) {
523+
if (process.platform === 'win32') {
524+
spawn('taskkill', ['/pid', backendProcess.pid, '/f', '/t']);
525+
} else {
526+
backendProcess.kill('SIGKILL');
527+
}
528+
backendProcess = null;
492529
}
530+
} catch (error) {
531+
console.error('退出时发生错误:', error);
532+
} finally {
533+
// 3. 最终退出应用
534+
app.exit(0);
493535
}
494-
})
536+
});
495537

496538
// 自动退出处理
497539
app.on('window-all-closed', () => {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "super-agent-party",
3-
"version": "v0.1.7",
3+
"version": "v0.1.8",
44
"description": "超级智能体派对 | 链接一切模型、知识库、搜索引擎、MCP服务器、A2A服务器;可以web端、桌面端、API等多种方式使用",
55
"main": "main.js",
66
"asar": false,

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "super-agent-party"
3-
version = "v0.1.7"
3+
version = "v0.1.8"
44
description = "超级智能体派对 | 链接一切模型、知识库、搜索引擎、MCP服务器、A2A服务器;可以web端、桌面端、API等多种方式使用"
55
readme = "README.md"
66
requires-python = ">=3.12"
@@ -38,4 +38,5 @@ dependencies = [
3838
"uvicorn[standard]>=0.34.2",
3939
"mem0ai>=0.1.101",
4040
"e2b-code-interpreter>=1.5.0",
41+
"botpy",
4142
]

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ rank_bm25
3131
fastapi_mcp
3232
mem0ai
3333
pyinstaller
34-
e2b-code-interpreter
34+
e2b-code-interpreter
35+
qq-botpy

0 commit comments

Comments
 (0)