This commit is contained in:
2025-09-27 14:05:45 +08:00
parent 89f600fa11
commit fe3e24b945
23 changed files with 474 additions and 261 deletions

View File

@@ -2,7 +2,7 @@
<div>
<div class="version-info" @click="autoCheck">v{{ version || '-' }}</div>
<el-dialog v-model="show" width="522px" :close-on-click-modal="false" align-center class="update-dialog" title="软件更新">
<el-dialog v-model="show" width="522px" :close-on-click-modal="false" align-center class="update-dialog" :title="stage === 'downloading' ? `正在更新 ${appName}` : '软件更新'">
<div v-if="stage === 'check'" class="update-content">
<div class="update-layout">
<div class="left-pane">
@@ -39,30 +39,27 @@
</div>
<div v-else-if="stage === 'downloading'" class="update-content">
<div class="update-header text-center">
<img src="/icon/icon.png" class="app-icon" alt="App Icon" />
<h3>正在更新 {{ appName }}</h3>
<p>正在下载更新文件...</p>
</div>
<div class="download-progress">
<div class="progress-info">
<span>{{ prog.current }} / {{ prog.total }}</span>
<div class="download-main">
<div class="download-icon">
<img src="/icon/icon.png" class="app-icon" alt="App Icon" />
</div>
<el-progress
:percentage="prog.percentage"
:show-text="false"
:stroke-width="6"
color="#409EFF" />
<div class="progress-details">
<span>{{ prog.percentage }}%</span>
<span v-if="prog.speed">{{ prog.speed }}</span>
<div class="download-content">
<div class="download-info">
<p>正在下载更新</p>
</div>
<div class="download-progress">
<el-progress
:percentage="prog.percentage"
:show-text="false"
:stroke-width="6"
color="#409EFF" />
<div class="progress-details">
<span style="font-weight: 500">{{ prog.current }} / {{ prog.total }}</span>
<el-button size="small" @click="cancelDownload">取消</el-button>
</div>
</div>
</div>
</div>
<div class="update-buttons">
<el-button @click="cancelDownload">取消下载</el-button>
</div>
</div>
<div v-else-if="stage === 'completed'" class="update-content">
@@ -107,7 +104,7 @@ const show = computed({
type Stage = 'check' | 'downloading' | 'completed'
const stage = ref<Stage>('check')
const appName = ref('ERP客户端')
const appName = ref('我了个电商')
const version = ref('2.0.0')
const prog = ref({ percentage: 0, current: '0 MB', total: '0 MB', speed: '' as string | undefined })
const info = ref({
@@ -149,14 +146,12 @@ async function start() {
ElMessage({ message: '下载链接不可用', type: 'error' })
return
}
if (!window.electronAPI) {
ElMessage({ message: '更新功能不可用', type: 'error' })
return
}
stage.value = 'downloading'
prog.value = { percentage: 0, current: '0 MB', total: '0 MB', speed: '' }
window.electronAPI.onDownloadProgress((progress) => {
prog.value = {
percentage: progress.percentage || 0,
@@ -210,12 +205,6 @@ async function installUpdate() {
type: 'warning'
}
)
if (!window.electronAPI) {
ElMessage({ message: '更新功能不可用', type: 'error' })
return
}
const response = await window.electronAPI.installUpdate()
if (response.success) {
@@ -374,8 +363,53 @@ onUnmounted(() => {
border-radius: 8px;
}
.download-header {
text-align: center;
margin-bottom: 20px;
}
.download-header h3 {
font-size: 14px;
font-weight: 500;
margin: 0;
color: #1f2937;
}
.download-main {
display: grid;
grid-template-columns: 80px 1fr;
align-items: start;
}
.download-icon {
display: flex;
justify-content: center;
}
.download-icon .app-icon {
width: 64px;
height: 64px;
border-radius: 12px;
}
.download-content {
min-width: 0;
}
.download-info {
margin-bottom: 12px;
}
.download-info p {
font-size: 14px;
font-weight: 600;
color: #6b7280;
margin: 0;
}
.download-progress {
margin: 24px 0;
margin: 0;
}
.progress-info {
@@ -388,11 +422,15 @@ onUnmounted(() => {
}
.progress-details {
margin-top: 8px;
font-size: 12px;
color: #909399;
margin-top: 12px;
display: flex;
justify-content: space-between;
align-items: center;
}
.progress-details span {
font-size: 12px;
color: #909399;
}
:deep(.el-progress-bar__outer) {