feat: 自动更新按钮生效

This commit is contained in:
DLmaster361
2025-09-13 17:43:36 +08:00
parent 6c7a0226fd
commit b36fb89566
7 changed files with 244 additions and 49 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div class="initialization-container">
<div class="initialization-page">
<!-- 管理员权限检查 -->
<AdminCheck v-if="!isAdmin" />
@@ -268,17 +268,17 @@ onUnmounted(() => {
</script>
<style scoped>
.initialization-container {
min-height: 100vh;
padding: 50px 100px;
margin: 0 auto;
background-color: var(--ant-color-bg-layout);
color: var(--ant-color-text);
.initialization-page {
padding: 20px;
box-sizing: border-box;
width: 100%;
min-height: 100%;
}
/* 响应式优化 */
@media (max-width: 768px) {
.initialization-container {
padding: 20px;
.initialization-page {
padding: 10px;
}
}
</style>

View File

@@ -11,6 +11,7 @@ import { message } from 'ant-design-vue'
import type { ThemeColor, ThemeMode } from '../composables/useTheme'
import { useTheme } from '../composables/useTheme.ts'
import { useSettingsApi } from '../composables/useSettingsApi'
import { useUpdateChecker } from '../composables/useUpdateChecker'
import type { SelectValue } from 'ant-design-vue/es/select'
import type { SettingsData } from '../types/settings'
import { Service, type VersionOut } from '@/api'
@@ -23,6 +24,7 @@ const app_version = import.meta.env.VITE_APP_VERSION || '获取版本失败!'
const router = useRouter()
const { themeMode, themeColor, themeColors, setThemeMode, setThemeColor } = useTheme()
const { loading, getSettings, updateSettings } = useSettingsApi()
const { restartPolling } = useUpdateChecker()
const updateVisible = ref(false)
@@ -184,6 +186,22 @@ const handleSettingChange = async (category: keyof SettingsData, key: string, va
message.error('托盘设置更新失败')
}
}
// 如果是自动检查更新设置变更,重新启动定时任务
if (category === 'Update' && key === 'IfAutoUpdate') {
try {
console.log(`检测到自动检查更新设置变更: ${value}`)
await restartPolling()
if (value) {
message.success('已启用自动检查更新')
} else {
message.success('已禁用自动检查更新')
}
} catch (error) {
console.error('重新启动更新检查任务失败:', error)
message.error('更新检查设置变更失败')
}
}
}
const getBackendVersion = async () => {