This commit is contained in:
2025-10-09 10:02:37 +08:00
parent 4065da3766
commit db67a99288
7 changed files with 247 additions and 16 deletions

View File

@@ -1,7 +1,6 @@
<template>
<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="stage === 'downloading' ? `正在更新 ${appName}` : '软件更新'">
<div v-if="stage === 'check'" class="update-content">
@@ -14,7 +13,6 @@
<p class="desc">{{ appName }} {{ info.latestVersion }} 可供安装您现在的版本是 {{
version
}}要现在安装吗</p>
<div class="update-details form">
<h4>更新信息</h4>
<el-input
@@ -25,14 +23,13 @@
readonly
resize="none"/>
</div>
<div class="update-actions row">
<div class="update-buttons">
<div class="left-actions">
<el-button size="small" @click="show=false">跳过这个版本</el-button>
<el-button size="small" @click="skipVersion">跳过这个版本</el-button>
</div>
<div class="right-actions">
<el-button size="small" @click="show=false">稍后提醒</el-button>
<el-button size="small" @click="remindLater">稍后提醒</el-button>
<el-button size="small" type="primary" @click="start">下载更新</el-button>
</div>
</div>
@@ -64,7 +61,6 @@
</div>
</div>
</div>
<div v-else-if="stage === 'completed'" class="update-content">
<div class="update-header text-center">
<img src="/icon/icon.png" class="app-icon" alt="App Icon"/>
@@ -118,6 +114,9 @@ const info = ref({
hasUpdate: false
})
const SKIP_VERSION_KEY = 'skipped_version'
const REMIND_LATER_KEY = 'remind_later_time'
async function autoCheck() {
try {
version.value = await (window as any).electronAPI.getJarVersion()
@@ -129,6 +128,18 @@ async function autoCheck() {
return
}
// 检查是否跳过此版本
const skippedVersion = localStorage.getItem(SKIP_VERSION_KEY)
if (skippedVersion === result.latestVersion) {
return
}
// 检查是否在稍后提醒时间内
const remindLater = localStorage.getItem(REMIND_LATER_KEY)
if (remindLater && Date.now() < parseInt(remindLater)) {
return
}
info.value = {
currentVersion: result.currentVersion,
latestVersion: result.latestVersion,
@@ -145,6 +156,17 @@ async function autoCheck() {
}
}
function skipVersion() {
localStorage.setItem(SKIP_VERSION_KEY, info.value.latestVersion)
show.value = false
}
function remindLater() {
// 24小时后再提醒
localStorage.setItem(REMIND_LATER_KEY, (Date.now() + 24 * 60 * 60 * 1000).toString())
show.value = false
}
async function start() {
if (!info.value.downloadUrl) {
ElMessage.error('下载链接不可用')
@@ -222,6 +244,8 @@ onMounted(async () => {
onUnmounted(() => {
(window as any).electronAPI.removeDownloadProgressListener()
})
</script>
<style scoped>
@@ -396,10 +420,6 @@ onUnmounted(() => {
border-radius: 8px;
}
.download-header {
text-align: center;
margin-bottom: 20px;
}
.download-header h3 {
font-size: 14px;