模块化 AppStore 并完善素材管理与个人空间设置。
将会话、权限、位置、收款与排队存储拆分为独立模块,同步更新各 ViewModel 与单元测试,并补充素材管理 UI 与个人空间设置交互。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -24,8 +24,8 @@ final class HomeLocationStateStore {
|
||||
|
||||
init(store: AppStore = .shared) {
|
||||
self.store = store
|
||||
reminderMinutes = store.locationReminderMinutes
|
||||
isOnline = store.onlineStatus
|
||||
reminderMinutes = store.location.reminderMinutes
|
||||
isOnline = store.location.onlineStatus
|
||||
}
|
||||
|
||||
deinit {
|
||||
@ -44,18 +44,18 @@ final class HomeLocationStateStore {
|
||||
|
||||
/// 启动时恢复在线倒计时。
|
||||
func restoreStateIfNeeded() {
|
||||
reminderMinutes = store.locationReminderMinutes
|
||||
guard store.onlineStatus else {
|
||||
reminderMinutes = store.location.reminderMinutes
|
||||
guard store.location.onlineStatus else {
|
||||
isOnline = false
|
||||
stopCountdown()
|
||||
notifyChange()
|
||||
return
|
||||
}
|
||||
let lastTime = store.lastLocationReportTime
|
||||
let lastTime = store.location.lastReportTime
|
||||
guard lastTime > 0 else {
|
||||
isOnline = false
|
||||
store.onlineStatus = false
|
||||
store.clearLastLocationReportTime()
|
||||
store.location.onlineStatus = false
|
||||
store.location.clearLastReportTime()
|
||||
stopCountdown()
|
||||
notifyChange()
|
||||
return
|
||||
@ -65,7 +65,7 @@ final class HomeLocationStateStore {
|
||||
let elapsed = now - lastTime
|
||||
if elapsed >= Self.onlineDurationMillis {
|
||||
updateOnlineStatus(false)
|
||||
store.clearLastLocationReportTime()
|
||||
store.location.clearLastReportTime()
|
||||
notifyChange()
|
||||
return
|
||||
}
|
||||
@ -81,10 +81,10 @@ final class HomeLocationStateStore {
|
||||
/// 更新在线状态并持久化。
|
||||
func updateOnlineStatus(_ online: Bool) {
|
||||
isOnline = online
|
||||
store.onlineStatus = online
|
||||
store.location.onlineStatus = online
|
||||
if !online {
|
||||
stopCountdown()
|
||||
store.clearLastLocationReportTime()
|
||||
store.location.clearLastReportTime()
|
||||
}
|
||||
notifyChange()
|
||||
}
|
||||
@ -92,16 +92,16 @@ final class HomeLocationStateStore {
|
||||
/// 更新提醒分钟数。
|
||||
func updateReminderMinutes(_ minutes: Int) {
|
||||
reminderMinutes = minutes
|
||||
store.locationReminderMinutes = minutes
|
||||
store.location.reminderMinutes = minutes
|
||||
notifyChange()
|
||||
}
|
||||
|
||||
/// 开始新的位置上报会话。
|
||||
func startLocationReport(at timestamp: Int64 = Int64(Date().timeIntervalSince1970 * 1000)) {
|
||||
anchorTimestamp = timestamp
|
||||
store.lastLocationReportTime = timestamp
|
||||
store.location.lastReportTime = timestamp
|
||||
isOnline = true
|
||||
store.onlineStatus = true
|
||||
store.location.onlineStatus = true
|
||||
elapsedSeconds = 0
|
||||
nextReportCountdownSeconds = Self.onlineDurationMillis / 1000
|
||||
startCountdown(anchorTime: timestamp)
|
||||
@ -156,7 +156,7 @@ final class HomeLocationStateStore {
|
||||
if remaining <= 0 {
|
||||
self.nextReportCountdownSeconds = 0
|
||||
self.updateOnlineStatus(false)
|
||||
self.store.clearLastLocationReportTime()
|
||||
self.store.location.clearLastReportTime()
|
||||
return
|
||||
}
|
||||
self.nextReportCountdownSeconds = max(0, remaining / 1000)
|
||||
|
||||
@ -10,10 +10,10 @@ enum HomeMenuCatalog {
|
||||
|
||||
/// 全部已知菜单项,对齐 Android `Constants.menuList`。
|
||||
static let allItems: [HomeMenuItem] = [
|
||||
HomeMenuItem(uri: "space_settings", title: "空间设置", iconName: "person.crop.square.fill"),
|
||||
HomeMenuItem(uri: "space_settings", title: "空间设置", iconName: "home_menu_space"),
|
||||
HomeMenuItem(uri: "wallet", title: "我的钱包", iconName: "creditcard.fill"),
|
||||
HomeMenuItem(uri: "cloud_management", title: "相册云盘", iconName: "icloud.fill"),
|
||||
HomeMenuItem(uri: "asset_management", title: "素材管理", iconName: "photo.on.rectangle.angled"),
|
||||
HomeMenuItem(uri: "asset_management", title: "素材管理", iconName: "home_menu_material"),
|
||||
HomeMenuItem(uri: "task_management", title: "任务管理", iconName: "checklist"),
|
||||
HomeMenuItem(uri: "task_management_editor", title: "任务管理", iconName: "checklist"),
|
||||
HomeMenuItem(uri: "schedule_management", title: "日程管理", iconName: "calendar"),
|
||||
|
||||
@ -21,7 +21,7 @@ enum HomeRouteHandler {
|
||||
return
|
||||
}
|
||||
|
||||
if uri != "pilot_controller", uri != "wallet", AppStore.shared.currentScenicId <= 0 {
|
||||
if uri != "pilot_controller", uri != "wallet", AppStore.shared.session.currentScenicId <= 0 {
|
||||
showToast("请先选择景区", from: viewController)
|
||||
return
|
||||
}
|
||||
@ -87,7 +87,7 @@ enum HomeRouteHandler {
|
||||
|
||||
@MainActor
|
||||
private static func handleOperatingArea(from viewController: UIViewController, storeItem: StoreItem?) {
|
||||
guard let role = AppStore.shared.currentAppRole else {
|
||||
guard let role = AppStore.shared.session.currentAppRole else {
|
||||
showToast("当前账号暂不支持运营区域", from: viewController)
|
||||
return
|
||||
}
|
||||
@ -99,7 +99,7 @@ enum HomeRouteHandler {
|
||||
}
|
||||
showDeveloping(from: viewController)
|
||||
case .scenicAdmin:
|
||||
guard AppStore.shared.currentScenicId > 0 else {
|
||||
guard AppStore.shared.session.currentScenicId > 0 else {
|
||||
showToast("请先选择景区", from: viewController)
|
||||
return
|
||||
}
|
||||
@ -110,7 +110,7 @@ enum HomeRouteHandler {
|
||||
}
|
||||
|
||||
private static func hasCooperationOrderPermission() -> Bool {
|
||||
let permissions = AppStore.shared.permissionItems()
|
||||
let permissions = AppStore.shared.permissions.permissionItems()
|
||||
return permissions.contains { $0.uri == "cooperation_order" }
|
||||
|| permissions.contains(where: { containsCooperationOrder(in: $0) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user