Private
Public Access
1
0

新增:应用配置管理模块,优化文件系统功能

- 新增 ConfigAPI 和 ConfigService 实现配置管理
- 新增 SettingsPanel 和 UpdateNotification 组件
- 文件系统模块化重构,提升代码质量
- 提取公共函数,优化代码结构
- 版本号更新至 0.2.0
This commit is contained in:
2026-01-28 22:48:10 +08:00
parent 7e79a53dae
commit b849e6cc46
31 changed files with 3024 additions and 917 deletions

View File

@@ -10,6 +10,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
)
@@ -27,6 +28,7 @@ type RemoteVersionInfo struct {
Changelog string `json:"changelog"`
ForceUpdate bool `json:"force_update"`
ReleaseDate string `json:"release_date"`
FileSize int64 `json:"file_size"`
}
// UpdateCheckResult 更新检查结果
@@ -38,6 +40,7 @@ type UpdateCheckResult struct {
Changelog string `json:"changelog"`
ForceUpdate bool `json:"force_update"`
ReleaseDate string `json:"release_date"`
FileSize int64 `json:"file_size"`
}
// InstallResult 安装结果
@@ -81,8 +84,13 @@ func (s *UpdateService) CheckUpdate() (*UpdateCheckResult, error) {
return nil, fmt.Errorf("获取远程版本信息失败: %v", err)
}
log.Printf("[更新检查] 远程版本信息: 版本=%s, 下载地址=%s, 强制更新=%v",
remoteInfo.Version, remoteInfo.DownloadURL, remoteInfo.ForceUpdate)
log.Printf("[更新检查] 远程版本信息: 版本=%s, 下载地址=%s, 强制更新=%v, 更新日志长度=%d",
remoteInfo.Version, remoteInfo.DownloadURL, remoteInfo.ForceUpdate, len(remoteInfo.Changelog))
if remoteInfo.Changelog != "" {
log.Printf("[更新检查] 更新日志内容: %s", remoteInfo.Changelog)
} else {
log.Printf("[更新检查] 警告: 远程接口未返回更新日志")
}
// 解析远程版本号
remoteVersion, err := ParseVersion(remoteInfo.Version)
@@ -106,6 +114,7 @@ func (s *UpdateService) CheckUpdate() (*UpdateCheckResult, error) {
Changelog: remoteInfo.Changelog,
ForceUpdate: remoteInfo.ForceUpdate,
ReleaseDate: remoteInfo.ReleaseDate,
FileSize: remoteInfo.FileSize,
}
log.Printf("[更新检查] 检查完成: 有更新=%v", hasUpdate)
@@ -138,13 +147,24 @@ func (s *UpdateService) fetchRemoteVersionInfo() (*RemoteVersionInfo, error) {
log.Printf("[远程版本] 请求远程版本信息: %s", s.checkURL)
// 添加时间戳参数防止缓存
timestamp := time.Now().UnixMilli() // 使用毫秒级时间戳
var requestURL string
if strings.Contains(s.checkURL, "?") {
requestURL = fmt.Sprintf("%s&t=%d", s.checkURL, timestamp)
} else {
requestURL = fmt.Sprintf("%s?t=%d", s.checkURL, timestamp)
}
log.Printf("[远程版本] 实际请求URL: %s", requestURL)
// 创建 HTTP 客户端,设置超时
client := &http.Client{
Timeout: 10 * time.Second,
}
// 发送请求
resp, err := client.Get(s.checkURL)
resp, err := client.Get(requestURL)
if err != nil {
log.Printf("[远程版本] 网络请求失败: %v", err)
return nil, fmt.Errorf("网络请求失败: %v", err)