mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-08-10 06:14:07 +08:00
feat(update-center): 实现集中式软件更新中心功能
新增更新中心模块,支持管理 APM 和传统 deb 软件更新任务 - 添加更新任务队列管理、状态跟踪和日志记录功能 - 实现更新项忽略配置持久化存储 - 新增更新确认对话框和迁移提示 - 优化主窗口关闭时的任务保护机制 - 添加单元测试覆盖核心逻辑
This commit is contained in:
@@ -102,7 +102,10 @@ export async function loadPriorityConfig(arch: string): Promise<void> {
|
||||
};
|
||||
}
|
||||
isPriorityConfigLoaded = true;
|
||||
console.log("[PriorityConfig] 已从服务器加载优先级配置:", dynamicPriorityConfig);
|
||||
console.log(
|
||||
"[PriorityConfig] 已从服务器加载优先级配置:",
|
||||
dynamicPriorityConfig,
|
||||
);
|
||||
} else {
|
||||
// 配置文件不存在,默认优先 Spark
|
||||
console.log("[PriorityConfig] 服务器无配置文件,使用默认 Spark 优先");
|
||||
@@ -136,21 +139,6 @@ function resetPriorityConfig(): void {
|
||||
isPriorityConfigLoaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查配置是否为空(没有任何规则)
|
||||
*/
|
||||
function isConfigEmpty(): boolean {
|
||||
const { sparkPriority, apmPriority } = dynamicPriorityConfig;
|
||||
return (
|
||||
sparkPriority.pkgnames.length === 0 &&
|
||||
sparkPriority.categories.length === 0 &&
|
||||
sparkPriority.tags.length === 0 &&
|
||||
apmPriority.pkgnames.length === 0 &&
|
||||
apmPriority.categories.length === 0 &&
|
||||
apmPriority.tags.length === 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取混合模式下应用的默认优先来源
|
||||
* 判断优先级(从高到低):
|
||||
|
||||
@@ -123,6 +123,69 @@ export interface UpdateAppItem {
|
||||
upgrading?: boolean;
|
||||
}
|
||||
|
||||
export type UpdateSource = "aptss" | "apm";
|
||||
|
||||
export type UpdateCenterTaskStatus =
|
||||
| "queued"
|
||||
| "downloading"
|
||||
| "installing"
|
||||
| "completed"
|
||||
| "failed"
|
||||
| "cancelled";
|
||||
|
||||
export interface UpdateCenterItem {
|
||||
taskKey: string;
|
||||
packageName: string;
|
||||
displayName: string;
|
||||
currentVersion: string;
|
||||
newVersion: string;
|
||||
source: UpdateSource;
|
||||
ignored?: boolean;
|
||||
downloadUrl?: string;
|
||||
fileName?: string;
|
||||
size?: number;
|
||||
sha512?: string;
|
||||
isMigration?: boolean;
|
||||
migrationSource?: UpdateSource;
|
||||
migrationTarget?: UpdateSource;
|
||||
aptssVersion?: string;
|
||||
}
|
||||
|
||||
export interface UpdateCenterTaskState {
|
||||
taskKey: string;
|
||||
packageName: string;
|
||||
source: UpdateSource;
|
||||
status: UpdateCenterTaskStatus;
|
||||
progress: number;
|
||||
logs: Array<{ time: number; message: string }>;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
export interface UpdateCenterSnapshot {
|
||||
items: UpdateCenterItem[];
|
||||
tasks: UpdateCenterTaskState[];
|
||||
warnings: string[];
|
||||
hasRunningTasks: boolean;
|
||||
}
|
||||
|
||||
export interface UpdateCenterBridge {
|
||||
open: () => Promise<UpdateCenterSnapshot>;
|
||||
refresh: () => Promise<UpdateCenterSnapshot>;
|
||||
ignore: (payload: {
|
||||
packageName: string;
|
||||
newVersion: string;
|
||||
}) => Promise<void>;
|
||||
unignore: (payload: {
|
||||
packageName: string;
|
||||
newVersion: string;
|
||||
}) => Promise<void>;
|
||||
start: (taskKeys: string[]) => Promise<void>;
|
||||
cancel: (taskKey: string) => Promise<void>;
|
||||
getState: () => Promise<UpdateCenterSnapshot>;
|
||||
onState: (listener: (snapshot: UpdateCenterSnapshot) => void) => void;
|
||||
offState: (listener: (snapshot: UpdateCenterSnapshot) => void) => void;
|
||||
}
|
||||
|
||||
/**************Below are type from main process ********************/
|
||||
export interface InstalledAppInfo {
|
||||
pkgname: string;
|
||||
|
||||
Reference in New Issue
Block a user