Skip to content

Commit

Permalink
Merge branch 'dev' into google-gemini
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng authored Jan 28, 2024
2 parents 127d4ba + 896d04d commit dc3b3e8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
6 changes: 4 additions & 2 deletions Easydict/Feature/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ let kHideMenuBarIconKey = "EZConfiguration_kHideMenuBarIconKey"
@DefaultsWrapper(.launchAtStartup)
var launchAtStartup: Bool

let updater = GlobalContext.shared.updaterController.updater

var automaticallyChecksForUpdates: Bool {
get {
GlobalContext.shared.updaterController.updater.automaticallyDownloadsUpdates
updater.automaticallyChecksForUpdates
}
set {
GlobalContext.shared.updaterController.updater.automaticallyDownloadsUpdates = newValue
updater.automaticallyChecksForUpdates = newValue
logSettings(["automatically_checks_for_updates": newValue])
}
}
Expand Down
6 changes: 2 additions & 4 deletions Easydict/NewApp/View/MenuItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ final class MenuItemStore: ObservableObject {
@Published var canCheckForUpdates = false

init() {
GlobalContext.shared
.updaterController
.updater
Configuration.shared.updater
.publisher(for: \.canCheckForUpdates)
.assign(to: &$canCheckForUpdates)
}
Expand Down Expand Up @@ -171,7 +169,7 @@ struct MenuItemView: View {
private var checkUpdateItem: some View {
Button("check_updates") {
NSLog("检查更新")
GlobalContext.shared.updaterController.updater.checkForUpdates()
Configuration.shared.updater.checkForUpdates()
}.disabled(!store.canCheckForUpdates)
}

Expand Down
23 changes: 20 additions & 3 deletions Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 izual. All rights reserved.
//

import Defaults
import SwiftUI

@available(macOS 13, *)
Expand All @@ -20,7 +21,7 @@ struct AboutTab: View {
.font(.system(size: 26, weight: .semibold))
Text("current_version") + Text(verbatim: " \(version)")
.font(.system(size: 14))
Toggle("auto_check_update", isOn: $autoChecksForUpdates)
Toggle("auto_check_update", isOn: $checkUpdaterViewModel.autoChecksForUpdates)
Text(verbatim: "(") + Text("lastest_version") + Text(verbatim: " \(lastestVersion ?? version))")

HStack {
Expand All @@ -45,8 +46,8 @@ struct AboutTab: View {
}
}

@AppStorage("EZConfiguration_kAutomaticallyChecksForUpdatesKey")
private var autoChecksForUpdates = false
@StateObject private var checkUpdaterViewModel = CheckUpdaterViewModel()

@State
private var lastestVersion: String?
private var appName: String {
Expand All @@ -56,6 +57,22 @@ struct AboutTab: View {
private var version: String {
Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
}

class CheckUpdaterViewModel: ObservableObject {
private let updater = Configuration.shared.updater

@Published var autoChecksForUpdates = true {
didSet {
updater.automaticallyChecksForUpdates = autoChecksForUpdates
}
}

init() {
updater
.publisher(for: \.automaticallyChecksForUpdates)
.assign(to: &$autoChecksForUpdates)
}
}
}

@available(macOS 13, *)
Expand Down
8 changes: 3 additions & 5 deletions Easydict/NewApp/View/SettingView/Tabs/PrivacyTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 izual. All rights reserved.
//

import Defaults
import SwiftUI

@available(macOS 13, *)
Expand Down Expand Up @@ -33,11 +34,8 @@ struct PrivacyTab: View {
.formStyle(.grouped)
}

@AppStorage("EZConfiguration_kAllowCrashLogKey")
private var allowCollectCrashLog = true

@AppStorage("EZConfiguration_kAllowAnalyticsKey")
private var allowCollectAnalytics = true
@Default(.allowCrashLog) private var allowCollectCrashLog
@Default(.allowAnalytics) private var allowCollectAnalytics
}

@available(macOS 13, *)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ Easydict 作为一个免费开源的非盈利项目,目前主要是作者个
| 2024-01-15 || 20 | 感谢开源,感谢有你:) |
| 2024-01-16 | ㅤ sd | 5 | 大佬牛逼🐂🍺 |
| 2024-01-23 || 5 | |
| 2024-01-28 || 7 | |

</p>

Expand Down
1 change: 1 addition & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ If you don't want your username to be displayed in the list, please choose anony
| 2024-01-15 || 20 | 感谢开源,感谢有你:) |
| 2024-01-16 | ㅤ sd | 5 | 大佬牛逼🐂🍺 |
| 2024-01-23 || 5 | |
| 2024-01-28 || 7 | |

</p>

Expand Down

0 comments on commit dc3b3e8

Please sign in to comment.