feat: 退出应用时自动释放模型显存

This commit is contained in:
thzxx
2026-04-07 10:50:35 +08:00
parent 5cde0fab6e
commit 4e11bd549c
4 changed files with 15 additions and 0 deletions
+9
View File
@@ -77,6 +77,15 @@ function setupDesktopIntegration(): void {
}
}) as EventListener);
// 退出时释放显存
bridge.onAppQuit(() => {
const api = state.get<OllamaAPI | null>(KEYS.API);
const model = state.get<string>('_defaultModel', '');
if (api && model) {
api.chat({ model, messages: [], keep_alive: 0 } as any).catch(() => {});
}
});
// 桌面端快捷键
document.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key === 'n') {