Skip to content

Commit 48c7487

Browse files
authored
🐛 fix: fix chat stream in desktop and update shortcut (#8520)
* disable nginx chunk buffering * make setting keep alive * update shortcut * update shortcut * fix lint
1 parent da47317 commit 48c7487

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

apps/desktop/src/main/appBrowsers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const appBrowsers = {
3636
autoHideMenuBar: true,
3737
height: 800,
3838
identifier: 'settings',
39-
// keepAlive: true,
39+
keepAlive: true,
4040
minWidth: 600,
4141
parentIdentifier: 'chat',
4242
path: '/settings',

apps/desktop/src/main/controllers/BrowserWindowsCtr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { IpcClientEventSender } from '@/types/ipcClientEvent';
77
import { ControllerModule, ipcClientEvent, shortcut } from './index';
88

99
export default class BrowserWindowsCtr extends ControllerModule {
10-
@shortcut('toggleMainWindow')
10+
@shortcut('showMainWindow')
1111
async toggleMainWindow() {
1212
const mainWindow = this.app.browserManager.getMainWindow();
1313
mainWindow.toggleVisible();

apps/desktop/src/main/controllers/TrayMenuCtr.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class TrayMenuCtr extends ControllerModule {
1515
/**
1616
* 使用快捷键切换窗口可见性
1717
*/
18-
@shortcut('toggleMainWindow')
18+
@shortcut('showMainWindow')
1919
async toggleMainWindow() {
2020
logger.debug('通过快捷键切换主窗口可见性');
2121
const mainWindow = this.app.browserManager.getMainWindow();
@@ -47,7 +47,7 @@ export default class TrayMenuCtr extends ControllerModule {
4747

4848
return {
4949
error: '托盘通知仅在 Windows 平台支持',
50-
success: false
50+
success: false,
5151
};
5252
}
5353

@@ -71,15 +71,15 @@ export default class TrayMenuCtr extends ControllerModule {
7171
logger.error('更新托盘图标失败:', error);
7272
return {
7373
error: String(error),
74-
success: false
74+
success: false,
7575
};
7676
}
7777
}
7878
}
7979

8080
return {
8181
error: '托盘功能仅在 Windows 平台支持',
82-
success: false
82+
success: false,
8383
};
8484
}
8585

@@ -103,7 +103,7 @@ export default class TrayMenuCtr extends ControllerModule {
103103

104104
return {
105105
error: '托盘功能仅在 Windows 平台支持',
106-
success: false
106+
success: false,
107107
};
108108
}
109109
}

apps/desktop/src/main/core/ui/ShortcutManager.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ export class ShortcutManager {
164164
Object.entries(this.shortcutsConfig).forEach(([id, accelerator]) => {
165165
logger.debug(`Registering shortcut '${id}' with ${accelerator}`);
166166

167+
// 只注册在 DEFAULT_SHORTCUTS_CONFIG 中存在的快捷键
168+
if (!DEFAULT_SHORTCUTS_CONFIG[id]) {
169+
logger.debug(`Skipping shortcut '${id}' - not found in DEFAULT_SHORTCUTS_CONFIG`);
170+
return;
171+
}
172+
167173
const method = this.shortcuts.get(id);
168174
if (accelerator && method) {
169175
this.registerShortcut(accelerator, method);

apps/desktop/src/main/shortcuts/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const ShortcutActionEnum = {
55
/**
66
* 显示/隐藏主窗口
77
*/
8-
toggleMainWindow: 'toggleMainWindow',
8+
showMainWindow: 'showMainWindow',
99
} as const;
1010

1111
export type ShortcutActionType = (typeof ShortcutActionEnum)[keyof typeof ShortcutActionEnum];
@@ -14,5 +14,5 @@ export type ShortcutActionType = (typeof ShortcutActionEnum)[keyof typeof Shortc
1414
* 默认快捷键配置
1515
*/
1616
export const DEFAULT_SHORTCUTS_CONFIG: Record<ShortcutActionType, string> = {
17-
[ShortcutActionEnum.toggleMainWindow]: 'CommandOrControl+E',
17+
[ShortcutActionEnum.showMainWindow]: 'Control+E',
1818
};

src/libs/model-runtime/utils/response.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const StreamingResponse = (
66
headers: {
77
'Cache-Control': 'no-cache',
88
'Content-Type': 'text/event-stream',
9+
// for Nginx: disable chunk buffering
10+
'X-Accel-Buffering': 'no',
911
...options?.headers,
1012
},
1113
});

0 commit comments

Comments
 (0)