refactor: standardize app property names and improve TypeScript definitions

- Updated property names in AppCard.vue, AppDetailModal.vue, AppGrid.vue, and other components to use camelCase for consistency.
- Enhanced TypeScript definitions for props and emits in various components to improve type safety.
- Refactored download status handling in processInstall.ts to align with updated App interface.
- Improved error handling and type definitions in DownloadDetail.vue and related components.
- Added optional properties and refined existing interfaces in typedefinition.ts for better clarity and usability.
This commit is contained in:
Elysia
2026-01-31 17:16:02 +08:00
parent f89b9ebfd9
commit 3221cb6d5e
18 changed files with 433 additions and 360 deletions

View File

@@ -1,4 +1,4 @@
import { ref } from "vue";
import { DownloadItem } from './typedefinition';
import type { DownloadItem } from './typedefinition';
export const downloads = ref(<DownloadItem[]>[]);
export const downloads = ref<DownloadItem[]>([]);

View File

@@ -1,7 +1,8 @@
import { ref } from "vue";
import type { App } from "./typedefinition";
export const APM_STORE_BASE_URL=import.meta.env.VITE_APM_STORE_BASE_URL;
export const APM_STORE_BASE_URL: string = import.meta.env.VITE_APM_STORE_BASE_URL || '';
// 下面的变量用于存储当前应用的信息,其实用在多个组件中
export const currentApp = ref<any>(null);
export const currentApp = ref<App | null>(null);
export const currentAppIsInstalled = ref(false);

View File

@@ -17,13 +17,14 @@ export interface DownloadItem {
pkgname: string;
version: string;
icon: string;
status: 'installing' | 'paused' | 'completed' | 'failed' | 'queued'; // 可根据实际状态扩展
status: 'downloading' | 'installing' | 'paused' | 'completed' | 'failed' | 'queued'; // 可根据实际状态扩展
progress: number; // 0 ~ 100 的百分比,或 0 ~ 1 的小数(建议统一)
downloadedSize: number; // 已下载字节数
totalSize: number; // 总字节数(可能为 0 初始时)
speed: number; // 当前下载速度,单位如 B/s
timeRemaining: number; // 剩余时间0 表示未知
startTime: number; // Date.now() 返回的时间戳(毫秒)
endTime?: number; // 下载完成时间戳(毫秒),可选
logs: Array<{
time: number; // 日志时间戳
message: string; // 日志消息
@@ -31,4 +32,66 @@ export interface DownloadItem {
source: string; // 例如 'APM Store'
retry: boolean; // 当前是否为重试下载
upgradeOnly?: boolean; // 是否为仅升级任务
}
error?: string;
}
/*
"Name": "Visual Studio Code(vscode)",
"Version": "1.108.2-1769004815",
"Filename": "code_1.108.2-1769004815_amd64.deb",
"Torrent_address": "code_1.108.2-1769004815_amd64.deb.torrent",
"Pkgname": "code",
"Author": "shenmo<shenmo@spark-app.store>",
"Contributor": "shenmo<shenmo@spark-app.store>",
"Website": "https://code.visualstudio.com/",
"Update": "2026-01-26 17:34:15",
"Size": "110M",
"More": "VSCode是一款非常牛逼的编辑器",
"Tags": "community;ubuntu;deepin;uos;debian",
"img_urls": "[\"https://cdn.d.store.deepinos.org.cn/store/development/code/screen_1.png\",\"https://cdn.d.store.deepinos.org.cn/store/development/code/screen_2.png\",\"https://cdn.d.store.deepinos.org.cn/store/development/code/screen_3.png\",\"https://cdn.d.store.deepinos.org.cn/store/development/code/screen_4.png\",\"https://cdn.d.store.deepinos.org.cn/store/development/code/screen_5.png\"]",
"icons": "https://cdn.d.store.deepinos.org.cn/store/development/code/icon.png"
*/
export interface AppJson {
// 原始数据
Name: string;
Version: string;
Filename: string;
Torrent_address: string;
Pkgname: string;
Author: string;
Contributor: string;
Website: string;
Update: string;
Size: string;
More: string;
Tags: string;
img_urls: string; // 注意:部分 json 里可能是字符串形式的数组
icons: string;
}
export interface App {
name: string;
pkgname: string;
version: string;
filename: string;
torrent_address: string;
author: string;
contributor: string;
website: string;
update: string;
size: string;
more: string;
tags: string;
img_urls: string[];
icons: string;
category: string; // Frontend added
installed?: boolean; // Frontend state
}
export interface UpdateAppItem {
pkgname: string;
currentVersion?: string;
newVersion?: string;
selected?: boolean;
upgrading?: boolean;
}