feat: 实现DetailView头像点击功能并优化MeView
- 在DetailView中添加头像点击功能,支持展示非当前用户的主页。 - 更新OptimizedDynamicCardView以支持头像点击回调。 - 修改DetailFeature以管理用户主页显示状态。 - 在MeView中添加关闭按钮支持,优化用户体验。 - 确保其他页面的兼容性,未影响现有功能。
This commit is contained in:
@@ -12,7 +12,7 @@ struct MainFeature {
|
||||
struct State: Equatable {
|
||||
var selectedTab: Tab = .feed
|
||||
var feedList: FeedListFeature.State = .init()
|
||||
var me: MeFeature.State = .init()
|
||||
var me: MeFeature.State
|
||||
var accountModel: AccountModel? = nil
|
||||
// 新增:导航路径和设置页面 State
|
||||
var navigationPath: [Destination] = []
|
||||
@@ -20,8 +20,10 @@ struct MainFeature {
|
||||
// 新增:登出标志
|
||||
var isLoggedOut: Bool = false
|
||||
|
||||
init() {
|
||||
// 默认初始化
|
||||
init(accountModel: AccountModel? = nil) {
|
||||
self.accountModel = accountModel
|
||||
let uid = accountModel?.uid.flatMap { Int($0) } ?? 0
|
||||
self.me = MeFeature.State(displayUID: uid > 0 ? uid : nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +66,9 @@ struct MainFeature {
|
||||
state.selectedTab = tab
|
||||
state.navigationPath = []
|
||||
if tab == .other, let uidStr = state.accountModel?.uid, let uid = Int(uidStr), uid > 0 {
|
||||
if state.me.uid != uid {
|
||||
state.me.uid = uid
|
||||
state.me.isFirstLoad = true // 仅当用户切换时才重置首次加载
|
||||
if state.me.displayUID != uid {
|
||||
state.me.displayUID = uid
|
||||
state.me.isFirstLoad = true
|
||||
}
|
||||
return .send(.me(.onAppear))
|
||||
}
|
||||
@@ -86,8 +88,8 @@ struct MainFeature {
|
||||
state.accountModel = accountModel
|
||||
// 如果当前选中的是 MeView 标签页,且有有效的 uid,则触发数据加载
|
||||
if state.selectedTab == .other, let uidStr = accountModel?.uid, let uid = Int(uidStr), uid > 0 {
|
||||
if state.me.uid != uid {
|
||||
state.me.uid = uid
|
||||
if state.me.displayUID != uid {
|
||||
state.me.displayUID = uid
|
||||
state.me.isFirstLoad = true
|
||||
}
|
||||
return .send(.me(.onAppear))
|
||||
|
Reference in New Issue
Block a user