diff --git a/electron/main/backend/submitter.ts b/electron/main/backend/submitter.ts index eeb238b3..33321248 100644 --- a/electron/main/backend/submitter.ts +++ b/electron/main/backend/submitter.ts @@ -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"; diff --git a/electron/main/backend/update-center/index.ts b/electron/main/backend/update-center/index.ts index 1cf05c83..c3eab6b2 100644 --- a/electron/main/backend/update-center/index.ts +++ b/electron/main/backend/update-center/index.ts @@ -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), diff --git a/extras/shell-caller.sh b/extras/shell-caller.sh index 49b48b46..f9cb5921 100755 --- a/extras/shell-caller.sh +++ b/extras/shell-caller.sh @@ -155,7 +155,10 @@ case "$command_type" in echo "操作已取消" exit 0 fi - + elif [[ "$2" == "ssupdate" ]]; then + /usr/bin/aptss "${@:2}" -y 2>&1 + exit_code=$? + exit $? else # 非 remove/install 命令,拒绝执行 echo "拒绝执行 aptss 白名单外的指令" diff --git a/src/components/SubmitterWindow.vue b/src/components/SubmitterWindow.vue index 17ab4fb7..8abe13b5 100644 --- a/src/components/SubmitterWindow.vue +++ b/src/components/SubmitterWindow.vue @@ -46,12 +46,12 @@ class="hidden" @change="handleDebFileSelect" /> -
+

- 正在解析 deb 文件... + {{ isParsingDeb ? '正在解析 deb 文件...' : '正在从服务器查询已上架信息...' }}

@@ -93,8 +93,9 @@
@@ -108,8 +109,9 @@
@@ -302,14 +304,27 @@ class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2" >分类 +
+ 正在加载分类列表... +
+
+

+ 分类加载失败: {{ categoriesLoadError }} +

+