fix: show uninstall failure notification in WebUI
Previous behavior: when an uninstall operation failed, the system did not provide any error feedback to the user and would simply reconnect during a polling check. Fixed behavior: if an uninstall fails, a failure notification is now displayed in the WebUI, informing the user that the uninstall has failed.
This commit is contained in:
1 parent
6aa067f495
commit
64178893e4
2 files changed
+43
-1
No files matched your search
@@ -204,11 +204,24 @@ export class HookManager {
|
|||||||
log.info('SnowLuma unloaded from PID=%d via unloadModuleManual', pid);
|
log.info('SnowLuma unloaded from PID=%d via unloadModuleManual', pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear injection state first
|
||||||
state.injected = false;
|
state.injected = false;
|
||||||
state.injectResult = null;
|
state.injectResult = null;
|
||||||
state.method = '';
|
state.method = '';
|
||||||
state.uin = '0';
|
state.uin = '0';
|
||||||
|
|
||||||
|
// Verify unload succeeded by checking if pipe still exists
|
||||||
|
const livePipes = await QqHookClient.listLivePipes();
|
||||||
|
if (livePipes.has(pid)) {
|
||||||
|
// Pipe still exists - unload failed, but let watcher handle reconnection
|
||||||
|
state.error = 'DLL卸载失败:命名管道仍然存在,watcher将自动重连';
|
||||||
|
state.status = 'connecting'; // Let watcher pick it up and reconnect
|
||||||
|
log.warn('unload verification failed: PID=%d pipe still exists after unloadModuleManual, watcher will reconnect', pid);
|
||||||
|
} else {
|
||||||
|
// Successfully unloaded
|
||||||
state.status = 'available';
|
state.status = 'available';
|
||||||
|
state.error = '';
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
state.status = 'error';
|
state.status = 'error';
|
||||||
state.error = error instanceof Error ? error.message : String(error);
|
state.error = error instanceof Error ? error.message : String(error);
|
||||||
@@ -311,7 +324,7 @@ export class HookManager {
|
|||||||
state.name = proc.name || state.name;
|
state.name = proc.name || state.name;
|
||||||
state.path = proc.path || state.path;
|
state.path = proc.path || state.path;
|
||||||
}
|
}
|
||||||
// Auto-detect hooks that survived a SnowLuma restart.
|
// Auto-detect hooks that survived a SnowLuma restart or failed unload.
|
||||||
for (const pid of livePipes) {
|
for (const pid of livePipes) {
|
||||||
const state = this.ensureState(pid);
|
const state = this.ensureState(pid);
|
||||||
if (!state.injected) {
|
if (!state.injected) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ConfigPage } from '@/components/pages/config-page';
|
|||||||
import { LogsPage } from '@/components/pages/logs-page';
|
import { LogsPage } from '@/components/pages/logs-page';
|
||||||
import { SettingsPage } from '@/components/pages/settings-page';
|
import { SettingsPage } from '@/components/pages/settings-page';
|
||||||
import { ChangePasswordPage, type PasswordRule } from '@/components/pages/change-password-page';
|
import { ChangePasswordPage, type PasswordRule } from '@/components/pages/change-password-page';
|
||||||
|
import { ConfirmDialog } from '@/components/confirm-dialog';
|
||||||
import type { Page } from '@/components/layout/sidebar';
|
import type { Page } from '@/components/layout/sidebar';
|
||||||
import type { HookProcessInfo, OneBotConfig, QQInfo, SystemInfo } from '@/types';
|
import type { HookProcessInfo, OneBotConfig, QQInfo, SystemInfo } from '@/types';
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ function AppInner() {
|
|||||||
const [processUnloadingPid, setProcessUnloadingPid] = useState<number | null>(null);
|
const [processUnloadingPid, setProcessUnloadingPid] = useState<number | null>(null);
|
||||||
const [processRefreshingPid, setProcessRefreshingPid] = useState<number | null>(null);
|
const [processRefreshingPid, setProcessRefreshingPid] = useState<number | null>(null);
|
||||||
const [processActionStatus, setProcessActionStatus] = useState('');
|
const [processActionStatus, setProcessActionStatus] = useState('');
|
||||||
|
const [unloadFailedAlert, setUnloadFailedAlert] = useState<{ pid: number; error: string } | null>(null);
|
||||||
// Tracks PIDs with an in-flight load/unload/refresh request so the UI can
|
// Tracks PIDs with an in-flight load/unload/refresh request so the UI can
|
||||||
// collapse spam-clicks instead of firing a second concurrent request.
|
// collapse spam-clicks instead of firing a second concurrent request.
|
||||||
const inflightProcessOps = useRef(new Set<number>());
|
const inflightProcessOps = useRef(new Set<number>());
|
||||||
@@ -256,7 +258,15 @@ function AppInner() {
|
|||||||
const res = await fetchApi(`/api/processes/${pid}/unload`, { method: 'POST' });
|
const res = await fetchApi(`/api/processes/${pid}/unload`, { method: 'POST' });
|
||||||
const data = await res.json().catch(() => ({}));
|
const data = await res.json().catch(() => ({}));
|
||||||
if (!res.ok) throw new Error(data.message || data.error || '卸载失败');
|
if (!res.ok) throw new Error(data.message || data.error || '卸载失败');
|
||||||
|
|
||||||
|
// Check if unload actually failed (pipe still exists)
|
||||||
|
if (data.process?.status === 'connecting' && data.process?.error) {
|
||||||
|
setUnloadFailedAlert({ pid, error: data.process.error });
|
||||||
|
setProcessActionStatus(`进程 ${pid} 卸载失败`);
|
||||||
|
} else {
|
||||||
setProcessActionStatus(`已从进程 ${pid} 卸载`);
|
setProcessActionStatus(`已从进程 ${pid} 卸载`);
|
||||||
|
}
|
||||||
|
|
||||||
await refreshProcesses();
|
await refreshProcesses();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setProcessActionStatus(`卸载失败:${(e as Error).message}`);
|
setProcessActionStatus(`卸载失败:${(e as Error).message}`);
|
||||||
@@ -376,6 +386,25 @@ function AppInner() {
|
|||||||
{active === 'settings' && <SettingsPage fetchApi={fetchApi} onLogout={handleLogout} />}
|
{active === 'settings' && <SettingsPage fetchApi={fetchApi} onLogout={handleLogout} />}
|
||||||
</MainLayout>
|
</MainLayout>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
open={!!unloadFailedAlert}
|
||||||
|
onOpenChange={(open) => !open && setUnloadFailedAlert(null)}
|
||||||
|
title="卸载失败"
|
||||||
|
description={
|
||||||
|
unloadFailedAlert ? (
|
||||||
|
<>
|
||||||
|
<p>进程 {unloadFailedAlert.pid} 的 SnowLuma DLL 卸载失败。</p>
|
||||||
|
<p className="mt-2 text-sm">{unloadFailedAlert.error}</p>
|
||||||
|
<p className="mt-2 text-sm text-muted-foreground">
|
||||||
|
系统将继续尝试重新连接该进程。如需彻底卸载,请重启 QQ 进程。
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
confirmText="知道了"
|
||||||
|
onConfirm={() => setUnloadFailedAlert(null)}
|
||||||
|
/>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user