Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Usage4Claude/Helpers/LocalizationHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,19 @@ enum L {
static var hint: String { localized("settings.general.time_format_hint") }
static var preview: String { localized("settings.general.time_format_preview") }
}
// MARK: - Graph Type
enum GraphType {
static var circular: String { localized("graph_type.circular") }
static var linear: String { localized("graph_type.linear") }
}

// MARK: - Graph Style Settings
enum GraphStyle {
static var title: String { localized("graph_style.title") }
static var hint: String { localized("graph_style.hint") }
static var circularDescription: String { localized("graph_style.circular_description") }
static var linearDescription: String { localized("graph_style.linear_description") }
}

// MARK: - Helper Methods

Expand Down
33 changes: 33 additions & 0 deletions Usage4Claude/Models/UserSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,22 @@ enum AppAppearance: String, CaseIterable, Codable {
}
}
}
/// 图表显示类型(圆形 vs 线性)
enum GraphDisplayType: String, CaseIterable, Codable {
/// 圆形图表 - 当前百分比环形显示
case circular = "circular"
/// 线性图表 - 时间轴与用量预测显示
case linear = "linear"

var localizedName: String {
switch self {
case .circular:
return L.GraphType.circular
case .linear:
return L.GraphType.linear
}
}
}

/// 应用语言选项
enum AppLanguage: String, CaseIterable, Codable {
Expand Down Expand Up @@ -451,6 +467,14 @@ class UserSettings: ObservableObject {
}
}

/// 图表显示类型(圆形/线性)
@Published var graphDisplayType: GraphDisplayType {
didSet {
defaults.set(graphDisplayType.rawValue, forKey: "graphDisplayType")
NotificationCenter.default.post(name: .settingsChanged, object: nil)
}
}

/// 是否为首次启动标记
@Published var isFirstLaunch: Bool {
didSet {
Expand Down Expand Up @@ -784,6 +808,14 @@ class UserSettings: ObservableObject {
self.customDisplayTypes = [.fiveHour, .sevenDay]
}

// 加载图表显示类型,默认为圆形
if let typeString = defaults.string(forKey: "graphDisplayType"),
let type = GraphDisplayType(rawValue: typeString) {
self.graphDisplayType = type
} else {
self.graphDisplayType = .circular
}

// 检查是否首次启动(如果没有保存过认证信息,就是首次启动)
if !defaults.bool(forKey: "hasLaunched") {
self.isFirstLaunch = true
Expand Down Expand Up @@ -910,6 +942,7 @@ class UserSettings: ObservableObject {
displayMode = .smart
customDisplayTypes = [.fiveHour, .sevenDay, .extraUsage]
notificationsEnabled = true
graphDisplayType = .circular

// 重置智能模式状态
lastUtilization = nil
Expand Down
9 changes: 9 additions & 0 deletions Usage4Claude/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,12 @@
"weblogin.success" = "Successfully added account: %@";
"weblogin.cloudflare_blocked" = "If the page won't load, please use manual input instead.";
"weblogin.privacy_notice" = "Your credentials are only used locally and stored securely in the system Keychain.";
// MARK: - Graph Type
"graph_type.circular" = "Circular";
"graph_type.linear" = "Linear";

// MARK: - Graph Style Settings
"graph_style.title" = "Graph Style";
"graph_style.hint" = "Choose how usage is visualized";
"graph_style.circular_description" = "Shows usage as a percentage ring";
"graph_style.linear_description" = "Shows usage timeline with pace prediction";
9 changes: 9 additions & 0 deletions Usage4Claude/Resources/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,12 @@
"weblogin.success" = "アカウントを追加しました:%@";
"weblogin.cloudflare_blocked" = "ページが読み込めない場合は、手動入力をご利用ください。";
"weblogin.privacy_notice" = "ログイン情報はローカルでのみ使用され、システムの Keychain に安全に保存されます。";
// MARK: - Graph Type
"graph_type.circular" = "サークル";
"graph_type.linear" = "ライン";

// MARK: - Graph Style Settings
"graph_style.title" = "グラフスタイル";
"graph_style.hint" = "使用量の表示方法を選択";
"graph_style.circular_description" = "使用量をパーセントリングで表示";
"graph_style.linear_description" = "使用量をタイムラインとペース予測で表示";
9 changes: 9 additions & 0 deletions Usage4Claude/Resources/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,12 @@
"weblogin.success" = "계정이 추가되었습니다: %@";
"weblogin.cloudflare_blocked" = "페이지를 로드할 수 없는 경우 수동 입력을 사용해 주세요.";
"weblogin.privacy_notice" = "로그인 정보는 로컬에서만 사용되며 시스템 Keychain에 안전하게 저장됩니다.";
// MARK: - Graph Type
"graph_type.circular" = "원형";
"graph_type.linear" = "선형";

// MARK: - Graph Style Settings
"graph_style.title" = "그래프 스타일";
"graph_style.hint" = "사용량 표시 방식 선택";
"graph_style.circular_description" = "사용량을 퍼센트 링으로 표시";
"graph_style.linear_description" = "사용량을 타임라인과 속도 예측으로 표시";
9 changes: 9 additions & 0 deletions Usage4Claude/Resources/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,12 @@
"weblogin.success" = "已成功添加账户:%@";
"weblogin.cloudflare_blocked" = "如果页面无法加载,请使用手动输入方式。";
"weblogin.privacy_notice" = "您的登录信息仅在本地使用,并安全存储于系统 Keychain 中。";
// MARK: - Graph Type
"graph_type.circular" = "圆形";
"graph_type.linear" = "线性";

// MARK: - Graph Style Settings
"graph_style.title" = "图表样式";
"graph_style.hint" = "选择使用量的显示方式";
"graph_style.circular_description" = "以百分比圆环显示使用量";
"graph_style.linear_description" = "以时间线和速度预测显示使用量";
9 changes: 9 additions & 0 deletions Usage4Claude/Resources/zh-Hant.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,12 @@
"weblogin.success" = "已成功新增帳戶:%@";
"weblogin.cloudflare_blocked" = "如果頁面無法載入,請使用手動輸入方式。";
"weblogin.privacy_notice" = "您的登入資訊僅在本機使用,並安全儲存於系統 Keychain 中。";
// MARK: - Graph Type
"graph_type.circular" = "圓形";
"graph_type.linear" = "線性";

// MARK: - Graph Style Settings
"graph_style.title" = "圖表樣式";
"graph_style.hint" = "選擇使用量的顯示方式";
"graph_style.circular_description" = "以百分比圓環顯示使用量";
"graph_style.linear_description" = "以時間線和速度預測顯示使用量";
Loading