diff --git a/electron/main/backend/update-center/index.ts b/electron/main/backend/update-center/index.ts index c3eab6b2..6aa1d3e0 100644 --- a/electron/main/backend/update-center/index.ts +++ b/electron/main/backend/update-center/index.ts @@ -535,15 +535,29 @@ export const registerUpdateCenterIpc = ( const results: { aptss?: string; apm?: string } = {}; - const runCommand = (command: string, args: string[]): Promise<{ code: number; stdout: string; stderr: 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 }); + 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 })); + 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 = ( @@ -554,17 +568,31 @@ export const registerUpdateCenterIpc = ( // aptss update — 需要提权 if (isSourceEnabled(storeFilter, "spark")) { const whichResult = await runCommand("which", ["aptss"]); - const aptssAvailable = whichResult.code === 0 && whichResult.stdout.trim().length > 0; + 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]); + 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)}`; + 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"); + console.warn( + "[UpdateCenter] pkexec not found, skipping aptss update", + ); } } else { results.aptss = "skipped: aptss not installed"; @@ -574,17 +602,29 @@ export const registerUpdateCenterIpc = ( // apm update — 也需要提权 if (isSourceEnabled(storeFilter, "apm")) { const whichResult = await runCommand("which", ["apm"]); - const apmAvailable = whichResult.code === 0 && whichResult.stdout.trim().length > 0; + 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]); + 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)}`; + 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"); + console.warn( + "[UpdateCenter] pkexec not found, skipping apm update", + ); } } else { results.apm = "skipped: apm not installed"; diff --git a/src/components/AppDetailModal.vue b/src/components/AppDetailModal.vue index 5f437b2a..361c6486 100644 --- a/src/components/AppDetailModal.vue +++ b/src/components/AppDetailModal.vue @@ -197,7 +197,7 @@ class="fas text-xs" :class="spkCopied ? 'fa-check' : 'fa-share-alt'" > - {{ spkCopied ? '已复制链接' : 'SPK 分享' }} + {{ spkCopied ? "已复制链接" : "SPK 分享" }} diff --git a/src/components/AppDetailPage.vue b/src/components/AppDetailPage.vue index 408efd3b..8ddd63c6 100644 --- a/src/components/AppDetailPage.vue +++ b/src/components/AppDetailPage.vue @@ -134,7 +134,7 @@ class="fas text-xs" :class="spkCopied ? 'fa-check' : 'fa-share-alt'" > - {{ spkCopied ? '已复制链接' : 'SPK 分享' }} + {{ spkCopied ? "已复制链接" : "SPK 分享" }} diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue index 5c6e0b39..07a1164f 100644 --- a/src/components/AppHeader.vue +++ b/src/components/AppHeader.vue @@ -80,7 +80,8 @@ const handleSearchFocus = () => { const handleInput = () => { const value = localSearchQuery.value.trim(); // 检测 SPK 分享链接: spk://store/{category}/{pkgname} - const spkMatch = value.match(/^spk:\/\/search\/(.+)$/i) || + const spkMatch = + value.match(/^spk:\/\/search\/(.+)$/i) || value.match(/^spk:\/\/store\/[^/]+\/(.+)$/i); if (spkMatch) { const pkgname = spkMatch[1].trim(); diff --git a/src/components/AppSidebar.vue b/src/components/AppSidebar.vue index bcd95679..c1e9674b 100644 --- a/src/components/AppSidebar.vue +++ b/src/components/AppSidebar.vue @@ -96,6 +96,11 @@ {{ entry.name }} + {{ entryCounts[entry.id] }} diff --git a/src/components/SubmitterWindow.vue b/src/components/SubmitterWindow.vue index 8abe13b5..d8bbb226 100644 --- a/src/components/SubmitterWindow.vue +++ b/src/components/SubmitterWindow.vue @@ -46,12 +46,19 @@ class="hidden" @change="handleDebFileSelect" /> -
+

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

@@ -698,7 +705,11 @@ const loadCategoriesList = async (): Promise => { if (result?.success && result.data) { const data = result.data; - if (data.code === 0 && Array.isArray(data.data) && data.data.length > 0) { + if ( + data.code === 0 && + Array.isArray(data.data) && + data.data.length > 0 + ) { categoriesList.value = data.data.map( (item: { id: number; name: string }, index: number) => ({ id: typeof item.id === "number" ? item.id : index + 1, @@ -709,7 +720,10 @@ const loadCategoriesList = async (): Promise => { }), ); categoriesLoadError.value = ""; - console.log("[Submitter] Categories loaded from API:", categoriesList.value); + console.log( + "[Submitter] Categories loaded from API:", + categoriesList.value, + ); } else if (data.code === 0 && Array.isArray(data)) { categoriesList.value = data.map( (item: { id: number; name: string }, index: number) => ({ @@ -719,7 +733,10 @@ const loadCategoriesList = async (): Promise => { }), ); categoriesLoadError.value = ""; - console.log("[Submitter] Categories loaded from API (direct array):", categoriesList.value); + console.log( + "[Submitter] Categories loaded from API (direct array):", + categoriesList.value, + ); } else { const errMsg = `服务器返回异常: code=${data.code}, msg=${data.msg || "未知"}`; categoriesLoadError.value = errMsg; @@ -867,13 +884,8 @@ const searchHistoryApp = async () => { historyResult.data && historyResult.data.length > 0 ) { - console.log( - "[Submitter] ============== HISTORY INFO FOUND ==============", - ); - console.log( - "[Submitter] History info count:", - historyResult.data.length, - ); + console.log("[Submitter] ============== HISTORY INFO FOUND =============="); + console.log("[Submitter] History info count:", historyResult.data.length); console.log( "[Submitter] Available archs data:", JSON.stringify(historyResult.data, null, 2), @@ -882,14 +894,8 @@ const searchHistoryApp = async () => { console.log( "[Submitter] ============== BEFORE SETTING STATE ==============", ); - console.log( - "[Submitter] availableArchs before:", - availableArchs.value, - ); - console.log( - "[Submitter] showArchDialog before:", - showArchDialog.value, - ); + console.log("[Submitter] availableArchs before:", availableArchs.value); + console.log("[Submitter] showArchDialog before:", showArchDialog.value); // 按 amd64 → arm64 → loong64 顺序排序 const archOrder: Record = { @@ -900,10 +906,7 @@ const searchHistoryApp = async () => { availableArchs.value = [...historyResult.data].sort( (a, b) => (archOrder[a.store] ?? 99) - (archOrder[b.store] ?? 99), ); - console.log( - "[Submitter] availableArchs after:", - availableArchs.value, - ); + console.log("[Submitter] availableArchs after:", availableArchs.value); console.log( "[Submitter] availableArchs length:", availableArchs.value.length, @@ -922,10 +925,7 @@ const searchHistoryApp = async () => { } showArchDialog.value = true; - console.log( - "[Submitter] showArchDialog after:", - showArchDialog.value, - ); + console.log("[Submitter] showArchDialog after:", showArchDialog.value); console.log( "[Submitter] ============== DIALOG SHOULD BE SHOWING ==============", @@ -937,9 +937,7 @@ const searchHistoryApp = async () => { ); nextTick(() => { - console.log( - "[Submitter] ============== AFTER NEXT TICK ==============", - ); + console.log("[Submitter] ============== AFTER NEXT TICK =============="); console.log( "[Submitter] showArchDialog in nextTick:", showArchDialog.value, @@ -965,10 +963,7 @@ const searchHistoryApp = async () => { console.log( "[Submitter] ============== NO HISTORY INFO FOUND ==============", ); - console.log( - "[Submitter] historyResult.success:", - historyResult?.success, - ); + console.log("[Submitter] historyResult.success:", historyResult?.success); console.log("[Submitter] historyResult.data:", historyResult?.data); console.log( "[Submitter] historyResult.data.length:", diff --git a/src/modules/updateCenter.ts b/src/modules/updateCenter.ts index a72e722c..693011a5 100644 --- a/src/modules/updateCenter.ts +++ b/src/modules/updateCenter.ts @@ -153,7 +153,10 @@ export const createUpdateCenterStore = (): UpdateCenterStore => { loading.value = true; try { // 先运行系统更新(aptss update / apm update),确保本地包信息最新 - await window.ipcRenderer.invoke("update-center-run-system-update", storeFilter); + await window.ipcRenderer.invoke( + "update-center-run-system-update", + storeFilter, + ); const nextSnapshot = await window.updateCenter.refresh(storeFilter); applySnapshot(nextSnapshot); } finally {