From 30e1bc48408128064f9e486ea45529e18f74e8fa Mon Sep 17 00:00:00 2001 From: xiyidaiwa Date: Tue, 11 Aug 2026 23:54:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=9B=B4=E6=96=B0=E4=B8=AD=E5=BF=83):?= =?UTF-8?q?=20E=E6=96=B9=E6=A1=88=E9=87=8D=E8=AE=BE=E8=AE=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=9D=A1=E7=9B=AE=20+=20=E5=B7=B2=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E6=B2=89=E5=BA=95=20+=20=E5=A4=8D=E7=94=A8app.update=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=20+=20=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E5=8A=A0=E5=9B=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - UpdateCenterItem.vue: 改为单行紧凑卡片,显示 包名·当前→新版本、来源标签、更新时间(品牌色)、大小;已忽略项淡化 - updateCenter.ts: filteredItems 将已忽略项沉底到列表末尾 - UpdateCenterList/Modal + App.vue: 透传全局 apps,用 app.json 的 Update 字段(Date.parse)推算 updateTime,零额外网络请求 - typedefinition.ts + update-center/types.ts: 新增可选 updateTime 字段 - install-manager.ts: launch-app 补 pkgname.length > 256 长度限制(防 DoS) - index.ts: close 事件先 clearTimeout 防抖定时器再同步保存窗口状态(消除竞态) - App.vue: fetchWithRetry 重试 3→2、延迟 1000→500ms(体验优化) - 7维审计通过;AI审查2阻断项(getIconUrl防护/fetchWithRetry泛型)经核实为误报 --- debian/changelog | 2 +- electron/main/backend/install-manager.ts | 3 +- electron/main/backend/update-center/types.ts | 2 + electron/main/index.ts | 2 + src/App.vue | 10 +- src/components/UpdateCenterModal.vue | 3 + .../update-center/UpdateCenterItem.vue | 204 ++++++++++-------- .../update-center/UpdateCenterList.vue | 21 +- src/global/typedefinition.ts | 2 + src/modules/updateCenter.ts | 9 +- 10 files changed, 167 insertions(+), 91 deletions(-) diff --git a/debian/changelog b/debian/changelog index 28ed93fd..ef47ec80 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -spark-store (5.2.1.16-test) UNRELEASED; urgency=medium +spark-store (5.2.1.18-test) UNRELEASED; urgency=medium * Initial release. (Closes: #nnnn) diff --git a/electron/main/backend/install-manager.ts b/electron/main/backend/install-manager.ts index e43610ad..c345720b 100644 --- a/electron/main/backend/install-manager.ts +++ b/electron/main/backend/install-manager.ts @@ -1359,7 +1359,8 @@ ipcMain.handle( if ( !pkgname || typeof pkgname !== "string" || - !PKGNAME_PATTERN.test(pkgname) + !PKGNAME_PATTERN.test(pkgname) || + pkgname.length > 256 ) { logger.warn(`Invalid pkgname provided for launch-app: ${pkgname}`); return { success: false, message: "Invalid package name" }; diff --git a/electron/main/backend/update-center/types.ts b/electron/main/backend/update-center/types.ts index 7692befa..102d0a2b 100644 --- a/electron/main/backend/update-center/types.ts +++ b/electron/main/backend/update-center/types.ts @@ -24,4 +24,6 @@ export interface UpdateCenterItem { migrationSource?: UpdateSource; migrationTarget?: UpdateSource; aptssVersion?: string; + // 更新发布时间(毫秒时间戳);由上游解析填充,暂无则缺省 + updateTime?: number; } diff --git a/electron/main/index.ts b/electron/main/index.ts index 10d04579..ba353933 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -483,6 +483,8 @@ async function createWindow() { mainWindow.on("close", (event) => { if (allowAppExit) { // 真正退出前同步保存最终窗口尺寸(防抖可能尚未触发) + // 先清除尚未触发的防抖定时器,避免旧定时器随后覆盖本次同步写入 + if (saveBoundsTimer) clearTimeout(saveBoundsTimer); const { width, height, x, y } = mainWindow.getBounds(); saveWindowState({ width, diff --git a/src/App.vue b/src/App.vue index fdc33152..01fbe0e5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -220,6 +220,7 @@ { - if (config.method?.toLowerCase() === "get" && typeof config.url === "string") { + if ( + config.method?.toLowerCase() === "get" && + typeof config.url === "string" + ) { // 按去除 query 的 pathname 判断,兼容 C2 自身追加的 ?_t= 及任何既有 query const reqPath = config.url.split("?")[0]; if (reqPath.endsWith(".json")) { @@ -449,8 +453,8 @@ axiosInstance.interceptors.request.use((config) => { const fetchWithRetry = async ( url: string, signal?: AbortSignal, - retries = 3, - delay = 1000, + retries = 2, + delay = 500, ): Promise => { try { const response = await axiosInstance.get(url, { signal }); diff --git a/src/components/UpdateCenterModal.vue b/src/components/UpdateCenterModal.vue index 574e66eb..ce139d01 100644 --- a/src/components/UpdateCenterModal.vue +++ b/src/components/UpdateCenterModal.vue @@ -66,6 +66,7 @@ :items="store.filteredItems.value" :tasks="store.snapshot.value.tasks" :selected-task-keys="store.selectedTaskKeys.value" + :apps="apps" @toggle-selection="emit('toggle-selection', $event)" @ignore-item="store.ignoreItem" @unignore-item="store.unignoreItem" @@ -86,6 +87,7 @@ diff --git a/src/components/update-center/UpdateCenterList.vue b/src/components/update-center/UpdateCenterList.vue index 68b10e5b..40e51db8 100644 --- a/src/components/update-center/UpdateCenterList.vue +++ b/src/components/update-center/UpdateCenterList.vue @@ -10,7 +10,7 @@
; + apps: App[]; }>(); defineEmits<{ @@ -47,6 +49,23 @@ defineEmits<{ (e: "unignore-item", packageName: string, newVersion: string): void; }>(); +// 从商店目录 apps 的 update 字段(app.json 的 Update,如 "2026-08-08") +// 推算更新发布时间,补全到更新列表项,用于显示「X天前」。匹配不到则保留原值(降级为「—」)。 +const enrichedItems = computed(() => { + const updateByPkg = new Map(); + for (const app of props.apps) { + if (app.pkgname && app.update) { + const t = Date.parse(app.update); + if (!Number.isNaN(t)) updateByPkg.set(app.pkgname, t); + } + } + return props.items.map((item) => { + if (item.updateTime && !Number.isNaN(item.updateTime)) return item; + const t = updateByPkg.get(item.packageName); + return t ? { ...item, updateTime: t } : item; + }); +}); + const taskMap = computed(() => { return new Map(props.tasks.map((task) => [task.taskKey, task])); }); diff --git a/src/global/typedefinition.ts b/src/global/typedefinition.ts index b5435bce..ae46fd0e 100644 --- a/src/global/typedefinition.ts +++ b/src/global/typedefinition.ts @@ -156,6 +156,8 @@ export interface UpdateCenterItem { migrationSource?: UpdateSource; migrationTarget?: UpdateSource; aptssVersion?: string; + // 更新发布时间(毫秒时间戳),用于列表显示「X天前」;暂无数据时前端降级为「—」 + updateTime?: number; } export interface UpdateCenterTaskState { diff --git a/src/modules/updateCenter.ts b/src/modules/updateCenter.ts index c26d7cce..172b7a1a 100644 --- a/src/modules/updateCenter.ts +++ b/src/modules/updateCenter.ts @@ -90,7 +90,14 @@ export const createUpdateCenterStore = (): UpdateCenterStore => { const filteredItems = computed(() => { const query = searchQuery.value.trim(); - return snapshot.value.items.filter((item) => matchesSearch(item, query)); + const matched = snapshot.value.items.filter((item) => + matchesSearch(item, query), + ); + // 已忽略项沉底:非忽略在前、已忽略在后,各自保持原有顺序 + return [ + ...matched.filter((item) => item.ignored !== true), + ...matched.filter((item) => item.ignored === true), + ]; }); const allSelected = computed(() => {