update 尝试修复点击更新后无法推送到下载列表的问题

This commit is contained in:
2026-04-12 19:00:14 +08:00
parent 9080d76575
commit 68ab999eed
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
describe("processInstall queue forwarding", () => {
beforeEach(() => {
vi.resetModules();
});
it("forwards update-center queue-install events back to the main install queue", async () => {
const handlers = new Map<string, (...args: unknown[]) => void>();
const send = vi.fn();
const on = vi.fn(
(channel: string, handler: (...args: unknown[]) => void) => {
handlers.set(channel, handler);
},
);
Object.assign(window.ipcRenderer, {
on,
send,
invoke: vi.fn(),
});
await import("@/modules/processInstall");
const payload = JSON.stringify({
id: 7,
pkgname: "spark-weather",
origin: "spark",
upgradeOnly: true,
});
handlers.get("queue-install")?.({}, payload);
expect(send).toHaveBeenCalledWith("queue-install", payload);
});
});

View File

@@ -235,3 +235,9 @@ window.ipcRenderer.on("install-complete", (_event, log: DownloadResult) => {
} }
} }
}); });
window.ipcRenderer.on("queue-install", (_event, payload: unknown) => {
const serializedPayload =
typeof payload === "string" ? payload : JSON.stringify(payload);
window.ipcRenderer.send("queue-install", serializedPayload);
});