将会话、权限、位置、收款与排队存储拆分为独立模块,同步更新各 ViewModel 与单元测试,并补充素材管理 UI 与个人空间设置交互。 Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.0 KiB
Swift
39 lines
1.0 KiB
Swift
//
|
|
// 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)"
|
|
}
|
|
}
|