模块化 AppStore 并完善素材管理与个人空间设置。

将会话、权限、位置、收款与排队存储拆分为独立模块,同步更新各 ViewModel 与单元测试,并补充素材管理 UI 与个人空间设置交互。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-13 11:01:08 +08:00
parent ceca780ab3
commit 005349f8e6
128 changed files with 2953 additions and 1123 deletions

View File

@ -16,8 +16,8 @@ final class HomeLocationStateStoreTests: XCTestCase {
defaults = UserDefaults(suiteName: "HomeLocationStateStoreTests")!
defaults.removePersistentDomain(forName: "HomeLocationStateStoreTests")
appStore = AppStore(defaults: defaults)
appStore.userId = "1001"
appStore.accountType = "scenic_user"
appStore.session.userId = "1001"
appStore.session.accountType = .scenicUser
}
override func tearDown() {
@ -27,21 +27,21 @@ final class HomeLocationStateStoreTests: XCTestCase {
func testExpiredOnlineSessionIsClearedOnRestore() {
let expiredTimestamp = Int64(Date().timeIntervalSince1970 * 1000) - HomeLocationStateStore.onlineDurationMillis - 1_000
appStore.onlineStatus = true
appStore.lastLocationReportTime = expiredTimestamp
appStore.location.onlineStatus = true
appStore.location.lastReportTime = expiredTimestamp
let stateStore = HomeLocationStateStore(store: appStore)
stateStore.restoreStateIfNeeded()
XCTAssertFalse(stateStore.isOnline)
XCTAssertFalse(appStore.onlineStatus)
XCTAssertEqual(appStore.lastLocationReportTime, 0)
XCTAssertFalse(appStore.location.onlineStatus)
XCTAssertEqual(appStore.location.lastReportTime, 0)
}
func testActiveOnlineSessionRestoresCountdown() {
let recentTimestamp = Int64(Date().timeIntervalSince1970 * 1000) - 60_000
appStore.onlineStatus = true
appStore.lastLocationReportTime = recentTimestamp
appStore.location.onlineStatus = true
appStore.location.lastReportTime = recentTimestamp
let stateStore = HomeLocationStateStore(store: appStore)
stateStore.restoreStateIfNeeded()
@ -56,7 +56,7 @@ final class HomeLocationStateStoreTests: XCTestCase {
}
func testShouldTriggerTimeoutReminderWithinWindow() {
appStore.locationReminderMinutes = 10
appStore.location.reminderMinutes = 10
let stateStore = HomeLocationStateStore(store: appStore)
stateStore.startLocationReport(at: Int64(Date().timeIntervalSince1970 * 1000))
stateStore.updateReminderMinutes(10)
@ -124,22 +124,22 @@ final class HomeLocationStateStoreTests: XCTestCase {
}
func testRestoreClearsOnlineStateWhenStoredLastReportTimeIsMissing() {
appStore.onlineStatus = true
appStore.lastLocationReportTime = 0
appStore.location.onlineStatus = true
appStore.location.lastReportTime = 0
let stateStore = HomeLocationStateStore(store: appStore)
stateStore.restoreStateIfNeeded()
XCTAssertFalse(stateStore.isOnline)
XCTAssertFalse(appStore.onlineStatus)
XCTAssertEqual(appStore.lastLocationReportTime, 0)
XCTAssertFalse(appStore.location.onlineStatus)
XCTAssertEqual(appStore.location.lastReportTime, 0)
XCTAssertEqual(stateStore.nextReportCountdownSeconds, 0)
}
func testRestoreClearsRuntimeStateWhenPersistedOffline() {
let stateStore = HomeLocationStateStore(store: appStore)
stateStore.startLocationReport(at: Int64(Date().timeIntervalSince1970 * 1000))
appStore.onlineStatus = false
appStore.location.onlineStatus = false
stateStore.restoreStateIfNeeded()