feat: 添加已安装应用和可更新应用的管理功能,支持卸载和升级操作

This commit is contained in:
Elysia
2026-01-28 18:14:04 +08:00
parent ac0dc225bc
commit ea0261a192
7 changed files with 606 additions and 97 deletions

View File

@@ -9,6 +9,7 @@ import { downloads } from "../global/downloadStatus";
import { InstallLog, DownloadItem, DownloadResult } from '../global/typedefinition';
let downloadIdCounter = 0;
const fallbackIcon = 'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"%3E%3Crect fill="%23f0f0f0" width="100" height="100"/%3E%3Ctext x="50" y="50" text-anchor="middle" dy=".3em" fill="%23999" font-size="14"%3EAPM%3C/text%3E%3C/svg%3E';
export const handleInstall = () => {
if (!currentApp.value?.Pkgname) return;
@@ -53,6 +54,35 @@ export const handleRetry = (download_: DownloadItem) => {
window.ipcRenderer.send('queue-install', JSON.stringify(download_));
};
export const handleUpgrade = (pkgname: string, newVersion = '') => {
if (!pkgname) return;
downloadIdCounter += 1;
const download: DownloadItem = {
id: downloadIdCounter,
name: pkgname,
pkgname: pkgname,
version: newVersion,
icon: fallbackIcon,
status: 'queued',
progress: 0,
downloadedSize: 0,
totalSize: 0,
speed: 0,
timeRemaining: 0,
startTime: Date.now(),
logs: [
{ time: Date.now(), message: '开始更新...' }
],
source: 'APM Update',
retry: false,
upgradeOnly: true
};
downloads.value.push(download);
window.ipcRenderer.send('queue-install', JSON.stringify(download));
};
export const handleRemove = () => {
if (!currentApp.value?.Pkgname) return;
window.ipcRenderer.send('remove-installed', currentApp.value.Pkgname);