模块化 AppStore 并完善素材管理与个人空间设置。
将会话、权限、位置、收款与排队存储拆分为独立模块,同步更新各 ViewModel 与单元测试,并补充素材管理 UI 与个人空间设置交互。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
38
suixinkan/DataStore/AppPaymentStore.swift
Normal file
38
suixinkan/DataStore/AppPaymentStore.swift
Normal file
@ -0,0 +1,38 @@
|
||||
//
|
||||
// AppPaymentStore.swift
|
||||
// suixinkan
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// 管理当前账号的收款功能偏好。
|
||||
final class AppPaymentStore {
|
||||
|
||||
private enum Key: String, CaseIterable {
|
||||
case isOpenReceiveVoice = "key_is_open_receive_voice"
|
||||
}
|
||||
|
||||
private let defaults: UserDefaults
|
||||
private let session: AppSessionStore
|
||||
|
||||
/// 使用指定持久化容器和会话创建收款偏好存储。
|
||||
init(defaults: UserDefaults, session: AppSessionStore) {
|
||||
self.defaults = defaults
|
||||
self.session = session
|
||||
}
|
||||
|
||||
/// 收款到账是否开启语音播报。
|
||||
var isOpenReceiveVoice: Bool {
|
||||
get { defaults.bool(forKey: scopedKey(.isOpenReceiveVoice)) }
|
||||
set { defaults.set(newValue, forKey: scopedKey(.isOpenReceiveVoice)) }
|
||||
}
|
||||
|
||||
/// 清除当前账号的收款偏好。
|
||||
func clear() {
|
||||
Key.allCases.forEach { defaults.removeObject(forKey: scopedKey($0)) }
|
||||
}
|
||||
|
||||
private func scopedKey(_ key: Key) -> String {
|
||||
"\(session.accountCachePrefix)_\(key.rawValue)"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user