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
2 changes: 1 addition & 1 deletion Shared/Sources/Shared/AI/AIBatchCorrectionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final class AIBatchCorrectionService {
public init() {}

public var isAvailable: Bool {
optimizationStorage.isConfigured
optimizationStorage.hasUsableConfiguration
}

/// 批量纠错,返回 [UUID: correctedText](仅包含需要修改的记录)
Expand Down
11 changes: 8 additions & 3 deletions Shared/Sources/Shared/Core/Storage/AIOptimizationStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,18 @@ public final class AIOptimizationStorage: Sendable {
set { defaults.set(newValue, forKey: Keys.disableThinking) }
}

/// 是否已完整配置(启用 + API Key 非空 + Base URL 非空)
public var isConfigured: Bool {
guard isEnabled else { return false }
/// 是否存在可复用的 AI 配置(不关心启用开关)
public var hasUsableConfiguration: Bool {
guard let key = apiKey, !key.isEmpty else { return false }
return !baseURL.isEmpty
}

/// 是否已完整配置(启用 + 存在可复用的 AI 配置)
public var isConfigured: Bool {
guard isEnabled else { return false }
return hasUsableConfiguration
}

public func clear() {
defaults.removeObject(forKey: Keys.isEnabled)
defaults.removeObject(forKey: Keys.apiKey)
Expand Down
2 changes: 1 addition & 1 deletion macOS/macOS/Views/Dashboard/Pages/HistoryPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ struct HistoryPage: View {
}
.buttonStyle(.bordered)
.controlSize(.regular)
.disabled(records.isEmpty || !AIOptimizationStorage.shared.isConfigured)
.disabled(records.isEmpty || !AIOptimizationStorage.shared.hasUsableConfiguration)

// 导出按钮
Button {
Expand Down