修复: 版本更新与设置面板走查问题
- 更新链路: 检查记录远端SHA256,下载完成事件回传,安装时带哈希校验 - 续传: 服务器忽略Range返回200时截断重下防追加损坏,文件名去query - 定时器: 自动检查可重入,配置变更免重启生效,关闭即停,下载加互斥 - 前端: 支持跳过此版本并按版本去重,手动检查不受门禁限制,启动未就绪延时重试 - 更新面板: 新增自动检查开关/间隔/地址配置与进度条状态映射 - 版本历史: cache参数强制刷新与加载超时重试兜底 - 配置: 侧边栏分区全链路持久化,保存请求复用api类型防字段丢失 - 侧边栏: 区块定位改显式类名,不再依赖排序位置 - 绑定: 重新生成并与镜像目录同步
This commit is contained in:
@@ -45,6 +45,30 @@
|
||||
</a-button>
|
||||
</a-space>
|
||||
|
||||
<!-- 更新设置 -->
|
||||
<div class="config-section">
|
||||
<div class="config-row">
|
||||
<span class="config-label">自动检查更新</span>
|
||||
<a-switch v-model="autoCheckEnabled" />
|
||||
</div>
|
||||
<div class="config-row">
|
||||
<span class="config-label">检查间隔(分钟)</span>
|
||||
<a-input-number v-model="checkIntervalMinutes" :min="5" :max="1440" style="width: 120px" />
|
||||
</div>
|
||||
<div class="config-row">
|
||||
<span class="config-label">检查地址</span>
|
||||
<a-input
|
||||
v-model="checkURL"
|
||||
placeholder="留空使用默认 https://c.1216.top/last-version.json"
|
||||
style="width: 320px"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<a-button type="primary" size="small" :loading="savingConfig" @click="handleSaveConfig">
|
||||
保存设置
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 更新信息 -->
|
||||
<a-alert
|
||||
v-if="updateInfo"
|
||||
@@ -67,7 +91,7 @@
|
||||
<template #icon>
|
||||
<icon-download />
|
||||
</template>
|
||||
{{ downloadProgress > 0 ? '下载中...' : '下载更新' }}
|
||||
{{ downloadButtonText }}
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="downloadedFile"
|
||||
@@ -89,7 +113,7 @@
|
||||
<div v-if="downloadProgress > 0 || downloading" class="download-progress">
|
||||
<a-progress
|
||||
:percent="downloadProgress"
|
||||
:status="downloadStatus"
|
||||
:status="progressBarStatus"
|
||||
/>
|
||||
<div class="progress-info">
|
||||
<span>{{ updateStore.formatFileSize(progressInfo.downloaded) }} / {{ updateStore.formatFileSize(progressInfo.total) }}</span>
|
||||
@@ -113,7 +137,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { Message, Modal } from '@arco-design/web-vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { IconHistory } from '@arco-design/web-vue/es/icon'
|
||||
@@ -121,8 +145,8 @@ import { useUpdateStore } from '../stores/update'
|
||||
import { parseMarkdown, isMarkedReady, preloadMarked } from '../utils/markedExtensions'
|
||||
import { sanitizeHtml } from '@/utils/fileUtils'
|
||||
import { parseWailsEventData } from '@/utils/wailsEvent'
|
||||
import { GetCurrentVersion, GetUpdateConfig, InstallUpdate } from '../wailsjs/v3-bindings/u-desk/app'
|
||||
import { On, Off } from '@wailsio/events'
|
||||
import { GetCurrentVersion, GetUpdateConfig, SetUpdateConfig, InstallUpdate } from '../wailsjs/v3-bindings/u-desk/app'
|
||||
import { Events } from '@wailsio/runtime'
|
||||
|
||||
// Emits
|
||||
defineEmits(['open-version-history'])
|
||||
@@ -139,6 +163,26 @@ const lastCheckTime = ref('-')
|
||||
const installResult = ref(null)
|
||||
const downloadedFile = ref(null)
|
||||
|
||||
// 更新设置
|
||||
const autoCheckEnabled = ref(false)
|
||||
const checkIntervalMinutes = ref(60)
|
||||
const checkURL = ref('')
|
||||
const savingConfig = ref(false)
|
||||
|
||||
// 下载按钮文案:下载中/安装中/可下载三态
|
||||
const downloadButtonText = computed(() => {
|
||||
if (downloading.value) return `下载中...${Math.round(downloadProgress.value)}%`
|
||||
if (installing.value) return '安装中...'
|
||||
return '下载更新'
|
||||
})
|
||||
|
||||
// a-progress 状态映射:store 的 active/exception/success → arco 的 normal/danger/success
|
||||
const progressBarStatus = computed(() => {
|
||||
if (downloadStatus.value === 'exception') return 'danger'
|
||||
if (downloadStatus.value === 'success') return 'success'
|
||||
return 'normal'
|
||||
})
|
||||
|
||||
/** 渲染 changelog(Markdown → HTML) */
|
||||
function renderChangelog(text: string): string {
|
||||
if (!text) return ''
|
||||
@@ -163,13 +207,39 @@ const loadConfig = async () => {
|
||||
const result = await GetUpdateConfig()
|
||||
if (!result.success) return
|
||||
|
||||
const { last_check_time = '-' } = result.data || {}
|
||||
const {
|
||||
last_check_time = '-',
|
||||
auto_check_enabled = false,
|
||||
check_interval_minutes = 60,
|
||||
check_url = ''
|
||||
} = result.data || {}
|
||||
lastCheckTime.value = last_check_time
|
||||
autoCheckEnabled.value = auto_check_enabled
|
||||
checkIntervalMinutes.value = check_interval_minutes
|
||||
checkURL.value = check_url
|
||||
} catch (error) {
|
||||
console.error('加载配置失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 保存设置
|
||||
const handleSaveConfig = async () => {
|
||||
savingConfig.value = true
|
||||
try {
|
||||
const result = await SetUpdateConfig(autoCheckEnabled.value, checkIntervalMinutes.value, checkURL.value)
|
||||
if (result.success) {
|
||||
Message.success('设置已保存')
|
||||
} else {
|
||||
Message.error(result.message || '保存设置失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存设置失败:', error)
|
||||
Message.error('保存设置失败:' + (error as Error).message)
|
||||
} finally {
|
||||
savingConfig.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查更新
|
||||
const handleCheckUpdate = async () => {
|
||||
installResult.value = null
|
||||
@@ -241,11 +311,11 @@ onMounted(async () => {
|
||||
await loadConfig()
|
||||
|
||||
// 监听下载完成事件(仅用于记录文件路径)
|
||||
On('download-complete', onDownloadComplete)
|
||||
Events.On('download-complete', onDownloadComplete)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
Off('download-complete')
|
||||
Events.Off('download-complete')
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -353,4 +423,24 @@ onUnmounted(() => {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
|
||||
.config-section {
|
||||
margin-top: 16px;
|
||||
padding: 12px 16px;
|
||||
background: var(--color-fill-1);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.config-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.config-label {
|
||||
width: 110px;
|
||||
flex-shrink: 0;
|
||||
font-size: 13px;
|
||||
color: var(--color-text-2);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user