diff --git a/desktop/app.go b/desktop/app.go
index 6e446c7..e888502 100644
--- a/desktop/app.go
+++ b/desktop/app.go
@@ -231,8 +231,19 @@ func (a *App) forceQuit() {
a.mu.Unlock()
a.emitLog("info", "正在停止代理并退出应用")
- if err := a.StopProxy(); err != nil {
- runtime.LogWarningf(a.ctx, "stop proxy before exit failed: %v", err)
+
+ done := make(chan struct{})
+ go func() {
+ if err := a.StopProxy(); err != nil {
+ runtime.LogWarningf(a.ctx, "stop proxy before exit failed: %v", err)
+ }
+ close(done)
+ }()
+
+ select {
+ case <-done:
+ case <-time.After(1200 * time.Millisecond):
+ runtime.LogWarning(a.ctx, "force quit continuing before proxy shutdown completed")
}
os.Exit(0)
}
diff --git a/desktop/frontend/src/App.vue b/desktop/frontend/src/App.vue
index 68060b0..8dc8ca1 100644
--- a/desktop/frontend/src/App.vue
+++ b/desktop/frontend/src/App.vue
@@ -15,6 +15,7 @@ const status = ref({ running: false, addr: '', models: 0 })
const toast = ref('')
const themeMode = ref(localStorage.getItem('lingma-theme-mode') || 'system')
const appliedTheme = ref('light')
+const forceQuitting = ref(false)
let systemThemeQuery = null
let toastTimer = null
@@ -106,12 +107,13 @@ async function copyEndpoint() {
}
async function forceQuitApp() {
- const confirmed = window.confirm('确定要停止代理并退出应用吗?')
- if (!confirmed) return
+ if (forceQuitting.value) return
+ forceQuitting.value = true
showToast('正在停止代理并退出应用...')
try {
await ForceQuitApp()
} catch (e) {
+ forceQuitting.value = false
addLog('error', '退出应用失败:' + (e.message || String(e)))
}
}
@@ -271,7 +273,7 @@ onUnmounted(() => {
-