mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-09-21 06:00:11 +08:00
refactor(更新中心): E方案重设计更新条目 + 已忽略沉底 + 复用app.update显示更新时间 + 安全加固
- 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泛型)经核实为误报
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<UpdateCenterItem
|
||||
v-for="item in items"
|
||||
v-for="item in enrichedItems"
|
||||
:key="item.taskKey"
|
||||
:item="item"
|
||||
:task="taskMap.get(item.taskKey)"
|
||||
@@ -29,6 +29,7 @@
|
||||
import { computed } from "vue";
|
||||
|
||||
import type {
|
||||
App,
|
||||
UpdateCenterItem as UpdateCenterItemModel,
|
||||
UpdateCenterTaskState,
|
||||
} from "@/global/typedefinition";
|
||||
@@ -39,6 +40,7 @@ const props = defineProps<{
|
||||
items: UpdateCenterItemModel[];
|
||||
tasks: UpdateCenterTaskState[];
|
||||
selectedTaskKeys: Set<string>;
|
||||
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<UpdateCenterItemModel[]>(() => {
|
||||
const updateByPkg = new Map<string, number>();
|
||||
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]));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user