refactor: improve code formatting and consistency across components

- Updated button and span elements in ThemeToggle.vue and TopActions.vue for better readability.
- Enhanced UninstallConfirmModal.vue and UpdateAppsModal.vue with consistent indentation and spacing.
- Refactored downloadStatus.ts and storeConfig.ts for improved code clarity.
- Standardized string quotes and spacing in typedefinition.ts and processInstall.ts.
- Ensured consistent use of arrow functions and improved variable declarations throughout the codebase.
This commit is contained in:
Elysia
2026-02-12 18:32:41 +08:00
parent e11740ad4c
commit 6622e70033
29 changed files with 1681 additions and 1042 deletions

View File

@@ -1,22 +1,22 @@
import { computed,ComputedRef,ref,unref,watch } from "vue";
import type { DownloadItem,DownloadItemStatus } from "./typedefinition";
import { computed, ComputedRef, ref, unref, watch } from "vue";
import type { DownloadItem, DownloadItemStatus } from "./typedefinition";
export const downloads = ref<DownloadItem[]>([]);
export function removeDownloadItem(pkgname:string) {
export function removeDownloadItem(pkgname: string) {
const list = downloads.value;
for (let i = list.length - 1; i >= 0; i -= 1) {
if (list[i].pkgname === pkgname) {
list.splice(i,1);
list.splice(i, 1);
}
}
}
export function watchDownloadsChange (cb: () => void) {
const statusById = new Map<number,DownloadItemStatus>();
export function watchDownloadsChange(cb: () => void) {
const statusById = new Map<number, DownloadItemStatus>();
for (const item of downloads.value) {
statusById.set(item.id,item.status);
statusById.set(item.id, item.status);
}
watch(
@@ -27,7 +27,7 @@ export function watchDownloadsChange (cb: () => void) {
if (item.status === "completed" && prevStatus !== "completed") {
cb();
}
statusById.set(item.id,item.status);
statusById.set(item.id, item.status);
}
if (statusById.size > list.length) {
@@ -42,7 +42,7 @@ export function watchDownloadsChange (cb: () => void) {
);
}
export function useDownloadItemStatus (
export function useDownloadItemStatus(
pkgname?: ComputedRef<string | undefined>,
) {
const status: ComputedRef<DownloadItemStatus | undefined> = computed(() => {
@@ -63,7 +63,7 @@ export function useDownloadItemStatus (
};
}
export function useInstallFeedback (pkgname?: ComputedRef<string | undefined>) {
export function useInstallFeedback(pkgname?: ComputedRef<string | undefined>) {
const installFeedback = computed(() => {
const name = unref(pkgname);
if (!name) return false;

View File

@@ -1,7 +1,8 @@
import { ref } from "vue";
import type { App } from "./typedefinition";
export const APM_STORE_BASE_URL: string = 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<App | null>(null);

View File

@@ -1,40 +1,46 @@
export interface InstallLog {
id: number;
success: boolean;
time: number;
exitCode: number | null;
message: string;
id: number;
success: boolean;
time: number;
exitCode: number | null;
message: string;
}
export interface DownloadResult extends InstallLog {
success: boolean;
exitCode: number | null;
success: boolean;
exitCode: number | null;
}
export type DownloadItemStatus = 'downloading' | 'installing' | 'paused' | 'completed' | 'failed' | 'queued'; // 可根据实际状态扩展
export type DownloadItemStatus =
| "downloading"
| "installing"
| "paused"
| "completed"
| "failed"
| "queued"; // 可根据实际状态扩展
export interface DownloadItem {
id: number;
name: string;
pkgname: string;
version: string;
icon: string;
status: DownloadItemStatus;
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; // 日志消息
}>;
source: string; // 例如 'APM Store'
retry: boolean; // 当前是否为重试下载
upgradeOnly?: boolean; // 是否为仅升级任务
error?: string;
id: number;
name: string;
pkgname: string;
version: string;
icon: string;
status: DownloadItemStatus;
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; // 日志消息
}>;
source: string; // 例如 'APM Store'
retry: boolean; // 当前是否为重试下载
upgradeOnly?: boolean; // 是否为仅升级任务
error?: string;
}
/*
@@ -54,68 +60,67 @@ export interface DownloadItem {
"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;
// 原始数据
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
flags?: string; // Tags in apm packages manager, e.g. "automatic" for dependencies
arch?: string; // Architecture, e.g. "amd64", "arm64"
currentStatus: 'not-installed' | 'installed'; // Current installation status
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
flags?: string; // Tags in apm packages manager, e.g. "automatic" for dependencies
arch?: string; // Architecture, e.g. "amd64", "arm64"
currentStatus: "not-installed" | "installed"; // Current installation status
}
export interface UpdateAppItem {
pkgname: string;
currentVersion?: string;
newVersion?: string;
selected?: boolean;
upgrading?: boolean;
pkgname: string;
currentVersion?: string;
newVersion?: string;
selected?: boolean;
upgrading?: boolean;
}
/**************Below are type from main process ********************/
export interface InstalledAppInfo {
pkgname: string;
version: string;
arch: string;
flags: string;
raw: string;
pkgname: string;
version: string;
arch: string;
flags: string;
raw: string;
}
/**
* ipcSender传递的信息
*/
export type ChannelPayload = {
success: boolean;
message: string;
[k: string]: unknown;
};
success: boolean;
message: string;
[k: string]: unknown;
};