mirror of
https://github.com/jiayouzl/Bitcoin-Monitoring.git
synced 2025-11-25 19:37:50 +08:00
Major feature enhancement for the BTC price monitoring application: ### New Features - **Configurable Refresh Intervals**: Users can now select from 5s, 10s, 30s, 60s options - **Persistent Settings**: User preferences saved via UserDefaults - **GitHub Integration**: Direct link to project repository via menu - **Version Display**: Shows current app version in about dialog - **Debug Logging**: Comprehensive debug output for development (Debug builds only) ### Implementation Details - **AppSettings.swift**: New configuration management class - **RefreshInterval.swift**: Enum defining refresh options with display text - **Enhanced PriceManager**: Dynamic timer management with configurable intervals - **Updated BTCMenuBarApp**: Added refresh settings submenu, GitHub link, and version info - **Debug Infrastructure**: Conditional compilation logging throughout price update flow ### UI/UX Improvements - **Refresh Settings Submenu**: Visual indicators (✓) for current selection - **Enhanced About Dialog**: Shows current refresh interval and app version - **Clean Menu Structure**: Organized with proper separators and SF Symbols - **GitHub Button**: Quick access to project repository ### Code Quality - **Removed Redundancy**: Deleted unused ContentView.swift template file - **Comprehensive Comments**: Added detailed Chinese comments throughout - **Error Handling**: Robust error handling with user-friendly messages - **Architecture Clean**: Follows MVVM pattern with clear separation of concerns ### Files Changed - Modified: BTCMenuBarApp.swift, PriceManager.swift, project.pbxproj - Added: AppSettings.swift, RefreshInterval.swift - Deleted: ContentView.swift (unused template) - Updated: Entitlements, app entry point, and service files BREAKING CHANGE: None - all changes are additive and backward compatible
40 lines
1.0 KiB
Swift
40 lines
1.0 KiB
Swift
//
|
|
// RefreshInterval.swift
|
|
// Bitcoin Monitoring
|
|
//
|
|
// Created by Mark on 2025/10/29.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/// 刷新间隔选项枚举
|
|
/// 定义用户可以选择的价格刷新间隔
|
|
enum RefreshInterval: Double, CaseIterable, Codable {
|
|
case fiveSeconds = 5
|
|
case tenSeconds = 10
|
|
case thirtySeconds = 30
|
|
case sixtySeconds = 60
|
|
|
|
/// 获取刷新间隔的显示文本
|
|
/// - Returns: 用于在菜单中显示的中文文本
|
|
var displayText: String {
|
|
switch self {
|
|
case .fiveSeconds:
|
|
return "5秒"
|
|
case .tenSeconds:
|
|
return "10秒"
|
|
case .thirtySeconds:
|
|
return "30秒"
|
|
case .sixtySeconds:
|
|
return "60秒"
|
|
}
|
|
}
|
|
|
|
/// 获取包含当前标记的显示文本
|
|
/// - Parameter isCurrent: 是否为当前选中的间隔
|
|
/// - Returns: 带有当前标记的显示文本
|
|
func displayTextWithMark(isCurrent: Bool) -> String {
|
|
return isCurrent ? "✓ \(displayText)" : " \(displayText)"
|
|
}
|
|
}
|