升级 AppStore 缓存 Key 并在覆盖安装时强制重新登录。
统一账号作用域 Key 对齐 Android,新增缓存 schema 迁移清理旧数据,并同步更新相关模块与单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -25,33 +25,53 @@ final class AppLocationStore {
|
||||
|
||||
/// 是否处于位置上报在线状态。
|
||||
var onlineStatus: Bool {
|
||||
get { defaults.bool(forKey: scopedKey(.onlineStatus)) }
|
||||
set { defaults.set(newValue, forKey: scopedKey(.onlineStatus)) }
|
||||
get {
|
||||
guard let key = scopedKey(.onlineStatus) else { return false }
|
||||
return defaults.bool(forKey: key)
|
||||
}
|
||||
set {
|
||||
guard let key = scopedKey(.onlineStatus) else { return }
|
||||
defaults.set(newValue, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
/// 上次位置上报时间戳,单位为毫秒。
|
||||
var lastReportTime: Int64 {
|
||||
get { Int64(defaults.integer(forKey: scopedKey(.lastReportTime))) }
|
||||
set { defaults.set(Int(newValue), forKey: scopedKey(.lastReportTime)) }
|
||||
get {
|
||||
guard let key = scopedKey(.lastReportTime) else { return 0 }
|
||||
return Int64(defaults.integer(forKey: key))
|
||||
}
|
||||
set {
|
||||
guard let key = scopedKey(.lastReportTime) else { return }
|
||||
defaults.set(Int(newValue), forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
/// 位置超时提前提醒分钟数,0 表示不提醒。
|
||||
var reminderMinutes: Int {
|
||||
get { defaults.integer(forKey: scopedKey(.reminderMinutes)) }
|
||||
set { defaults.set(newValue, forKey: scopedKey(.reminderMinutes)) }
|
||||
get {
|
||||
guard let key = scopedKey(.reminderMinutes) else { return 0 }
|
||||
return defaults.integer(forKey: key)
|
||||
}
|
||||
set {
|
||||
guard let key = scopedKey(.reminderMinutes) else { return }
|
||||
defaults.set(newValue, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
/// 清除上次位置上报时间。
|
||||
func clearLastReportTime() {
|
||||
defaults.removeObject(forKey: scopedKey(.lastReportTime))
|
||||
guard let key = scopedKey(.lastReportTime) else { return }
|
||||
defaults.removeObject(forKey: key)
|
||||
}
|
||||
|
||||
/// 清除当前账号的位置上报状态和偏好。
|
||||
func clear() {
|
||||
Key.allCases.forEach { defaults.removeObject(forKey: scopedKey($0)) }
|
||||
func clear(accountScope: String) {
|
||||
guard !accountScope.isEmpty else { return }
|
||||
Key.allCases.forEach { defaults.removeObject(forKey: "\(accountScope)_\($0.rawValue)") }
|
||||
}
|
||||
|
||||
private func scopedKey(_ key: Key) -> String {
|
||||
"\(session.accountCachePrefix)_\(key.rawValue)"
|
||||
private func scopedKey(_ key: Key) -> String? {
|
||||
session.accountScopedKey(key.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user