feat: 移除设置功能并优化主功能状态管理
- 从HomeFeature和MainFeature中移除设置相关状态和逻辑,简化状态管理。 - 更新视图以去除设置页面的展示,提升用户体验。 - 删除SettingFeature及其相关视图,减少冗余代码,增强代码可维护性。
This commit is contained in:
@@ -14,7 +14,6 @@ struct MainFeature: Reducer {
|
||||
var accountModel: AccountModel? = nil
|
||||
// 新增:导航路径和设置页面 State
|
||||
var navigationPath: [Destination] = []
|
||||
var settingState: SettingFeature.State? = nil
|
||||
var appSettingState: AppSettingFeature.State? = nil
|
||||
// 新增:登出标志
|
||||
var isLoggedOut: Bool = false
|
||||
@@ -22,7 +21,6 @@ struct MainFeature: Reducer {
|
||||
|
||||
// 新增:导航目标
|
||||
enum Destination: Hashable, Equatable {
|
||||
case setting
|
||||
case test
|
||||
case appSetting
|
||||
}
|
||||
@@ -36,8 +34,6 @@ struct MainFeature: Reducer {
|
||||
case accountModelLoaded(AccountModel?)
|
||||
// 新增:导航相关
|
||||
case navigationPathChanged([Destination])
|
||||
case settingButtonTapped
|
||||
case settingAction(SettingFeature.Action)
|
||||
case testButtonTapped
|
||||
case appSettingButtonTapped
|
||||
case appSettingAction(AppSettingFeature.Action)
|
||||
@@ -84,20 +80,11 @@ struct MainFeature: Reducer {
|
||||
return .none
|
||||
case .navigationPathChanged(let newPath):
|
||||
// pop 回来时清空 settingState
|
||||
if !newPath.contains(.setting) {
|
||||
state.settingState = nil
|
||||
}
|
||||
if !newPath.contains(.appSetting) {
|
||||
state.appSettingState = nil
|
||||
}
|
||||
state.navigationPath = newPath
|
||||
return .none
|
||||
case .settingButtonTapped:
|
||||
state.settingState = SettingFeature.State()
|
||||
state.navigationPath.append(.setting)
|
||||
return .none
|
||||
case .settingAction:
|
||||
return .none
|
||||
case .testButtonTapped:
|
||||
state.navigationPath.append(.test)
|
||||
return .none
|
||||
@@ -117,9 +104,6 @@ struct MainFeature: Reducer {
|
||||
}
|
||||
}
|
||||
// 设置页作用域
|
||||
.ifLet(\ .settingState, action: \.settingAction) {
|
||||
SettingFeature()
|
||||
}
|
||||
.ifLet(\ .appSettingState, action: \.appSettingAction) {
|
||||
AppSettingFeature()
|
||||
}
|
||||
|
Reference in New Issue
Block a user