feat(submitter,update-center): add multiple features and optimize submission flow

1. add shell caller ssupdate command support
2. add pre-update system refresh for update center
3. add get-git-email IPC handler and auto-fill email
4. optimize deb submission UI and category handling
5. disable and auto-fill package name/version fields
6. add loading and error states for category list
7. fix category value matching for history data
This commit is contained in:
2026-07-13 22:07:01 +08:00
parent 0aca5744b0
commit 7c6bdf0e55
5 changed files with 256 additions and 152 deletions
+18
View File
@@ -911,6 +911,24 @@ export function registerSubmitterHandlers(
}
});
ipcMain.handle("get-git-email", async () => {
try {
const { exec } = await import("node:child_process");
const util = await import("util");
const execAsync = util.promisify(exec);
const { stdout } = await execAsync("git config user.email");
const email = stdout.trim();
logger.info({ email }, "[Submitter] Git email retrieved");
return { success: true, data: email || "" };
} catch (err) {
logger.warn(
{ err },
"[Submitter] Failed to get git email, not a git repo or git not installed",
);
return { success: false, data: "" };
}
});
ipcMain.handle("get-tags-list", async () => {
try {
const apiUrl = "https://upload.deepinos.org.cn/api/index/get_tags_list";
@@ -2,6 +2,8 @@ import { spawn } from "node:child_process";
import { BrowserWindow, ipcMain } from "electron";
import { SHELL_CALLER_PATH } from "../shared-installer";
import { findExecutable, SUPER_USER_COMMAND_CANDIDATES } from "../superuser";
import {
buildInstalledSourceMap,
mergeUpdateSources,
@@ -524,6 +526,75 @@ export const registerUpdateCenterIpc = (
| "subscribe"
>,
): void => {
ipc.handle(
"update-center-run-system-update",
async (_event, storeFilter: StoreFilter = "both") => {
console.log(
`[UpdateCenter] update-center-run-system-update called with storeFilter=${storeFilter}`,
);
const results: { aptss?: string; apm?: string } = {};
const runCommand = (command: string, args: string[]): Promise<{ code: number; stdout: string; stderr: string }> =>
new Promise((resolve) => {
const child = spawn(command, args, { shell: false, env: process.env });
let stdout = "";
let stderr = "";
child.stdout?.on("data", (data) => { stdout += data.toString(); });
child.stderr?.on("data", (data) => { stderr += data.toString(); });
child.on("error", (err) => resolve({ code: -1, stdout, stderr: err.message }));
child.on("close", (code) => resolve({ code: code ?? -1, stdout, stderr }));
});
const isSourceEnabled = (
filter: StoreFilter,
source: "spark" | "apm",
): boolean => filter === "both" || filter === source;
// aptss update — 需要提权
if (isSourceEnabled(storeFilter, "spark")) {
const whichResult = await runCommand("which", ["aptss"]);
const aptssAvailable = whichResult.code === 0 && whichResult.stdout.trim().length > 0;
if (aptssAvailable) {
console.log("[UpdateCenter] Running: pkexec shell-caller aptss ssupdate");
const superUserCmd = await findExecutable(SUPER_USER_COMMAND_CANDIDATES[0]);
if (superUserCmd) {
const result = await runCommand(superUserCmd, [SHELL_CALLER_PATH, "aptss", "ssupdate"]);
results.aptss = result.code === 0 ? "ok" : `failed: ${result.stderr.substring(0, 200)}`;
console.log("[UpdateCenter] aptss ssupdate result:", results.aptss);
} else {
results.aptss = "failed: pkexec not found";
console.warn("[UpdateCenter] pkexec not found, skipping aptss update");
}
} else {
results.aptss = "skipped: aptss not installed";
}
}
// apm update — 也需要提权
if (isSourceEnabled(storeFilter, "apm")) {
const whichResult = await runCommand("which", ["apm"]);
const apmAvailable = whichResult.code === 0 && whichResult.stdout.trim().length > 0;
if (apmAvailable) {
console.log("[UpdateCenter] Running: pkexec shell-caller apm update");
const superUserCmd = await findExecutable(SUPER_USER_COMMAND_CANDIDATES[0]);
if (superUserCmd) {
const result = await runCommand(superUserCmd, [SHELL_CALLER_PATH, "apm", "update"]);
results.apm = result.code === 0 ? "ok" : `failed: ${result.stderr.substring(0, 200)}`;
console.log("[UpdateCenter] apm update result:", results.apm);
} else {
results.apm = "failed: pkexec not found";
console.warn("[UpdateCenter] pkexec not found, skipping apm update");
}
} else {
results.apm = "skipped: apm not installed";
}
}
return results;
},
);
ipc.handle(
"update-center-open",
(_event, storeFilter: StoreFilter = "both") => service.open(storeFilter),