This commit is contained in:
Julian Freeman
2026-03-14 16:18:11 -04:00
commit 375b6fdb11
46 changed files with 7988 additions and 0 deletions

View File

@@ -0,0 +1,224 @@
<template>
<div class="software-card">
<div class="card-header">
<div class="icon-container">
<img v-if="software.icon_url" :src="software.icon_url" :alt="software.name" class="software-icon" />
<div v-else class="icon-placeholder" :style="{ backgroundColor: placeholderColor }">
{{ software.name.charAt(0).toUpperCase() }}
</div>
</div>
<div class="info">
<h3 class="name">{{ software.name }}</h3>
<p class="id">{{ software.id }}</p>
</div>
</div>
<div class="card-body">
<p class="description" v-if="software.description">{{ software.description }}</p>
<div class="version-info">
<span class="version">当前: {{ software.version || '--' }}</span>
<span class="available" v-if="software.available_version">可用: {{ software.available_version }}</span>
</div>
</div>
<div class="card-actions">
<button
v-if="software.status === 'idle'"
@click="$emit('install', software.id)"
class="install-btn"
>
{{ actionLabel }}
</button>
<div v-else-if="software.status === 'installing' || software.status === 'pending'" class="progress-container">
<div class="progress-ring">
<svg viewBox="0 0 32 32">
<circle class="bg" cx="16" cy="16" r="14" fill="none" stroke-width="4" />
<circle class="fg" cx="16" cy="16" r="14" fill="none" stroke-width="4"
:style="{ strokeDasharray: 88, strokeDashoffset: 88 - (88 * (software.progress || 0.5)) }"
/>
</svg>
</div>
<span class="status-text">安装中...</span>
</div>
<div v-else-if="software.status === 'success'" class="status-success">
<span class="check-icon"></span> 已完成
</div>
<div v-else-if="software.status === 'error'" class="status-error">
失败
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps<{
software: {
id: string;
name: string;
description?: string;
version?: string;
available_version?: string;
icon_url?: string;
status: string;
progress: number;
},
actionLabel?: string
}>();
const placeholderColor = computed(() => {
const colors = ['#FF9500', '#FF3B30', '#34C759', '#007AFF', '#5856D6', '#AF52DE'];
let hash = 0;
for (let i = 0; i < props.software.id.length; i++) {
hash = props.software.id.charCodeAt(i) + ((hash << 5) - hash);
}
return colors[Math.abs(hash) % colors.length];
});
</script>
<style scoped>
.software-card {
background: white;
border-radius: var(--radius-card);
padding: 24px;
box-shadow: var(--card-shadow);
transition: transform 0.2s ease, box-shadow 0.2s ease;
display: flex;
flex-direction: column;
gap: 16px;
border: 1px solid rgba(0, 0, 0, 0.02);
}
.software-card:hover {
transform: translateY(-4px);
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}
.card-header {
display: flex;
align-items: center;
gap: 16px;
}
.icon-container {
width: 56px;
height: 56px;
border-radius: 14px;
overflow: hidden;
flex-shrink: 0;
}
.software-icon {
width: 100%;
height: 100%;
object-fit: cover;
}
.icon-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 24px;
font-weight: 700;
}
.info .name {
font-size: 17px;
font-weight: 600;
color: var(--text-main);
}
.info .id {
font-size: 13px;
color: var(--text-sec);
}
.card-body {
flex-grow: 1;
}
.description {
font-size: 14px;
color: var(--text-sec);
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
margin-bottom: 8px;
}
.version-info {
display: flex;
gap: 12px;
font-size: 12px;
color: var(--text-sec);
}
.install-btn {
width: 100%;
padding: 10px;
background-color: var(--bg-light);
border: none;
border-radius: var(--radius-btn);
color: var(--primary-color);
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
}
.install-btn:hover {
background-color: var(--primary-color);
color: white;
}
.progress-container {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
}
.progress-ring {
width: 24px;
height: 24px;
}
.progress-ring svg {
transform: rotate(-90deg);
}
.progress-ring .bg {
stroke: var(--border-color);
}
.progress-ring .fg {
stroke: var(--primary-color);
transition: stroke-dashoffset 0.3s ease;
}
.status-text {
font-size: 14px;
font-weight: 500;
color: var(--primary-color);
}
.status-success {
text-align: center;
color: #34C759;
font-weight: 600;
}
.status-error {
text-align: center;
color: #FF3B30;
font-weight: 600;
}
</style>