新增公共房间管理器的初始化逻辑,并在登录和信息补全成功后调用初始化方法;在相关文件中引入公共房间管理器的头文件以支持新功能。同时,优化了公共房间管理器的状态检查和日志输出,提升代码可读性和功能性。
This commit is contained in:
0
.trae/rules/project_rules.md
Normal file
0
.trae/rules/project_rules.md
Normal file
@@ -19,6 +19,7 @@
|
|||||||
#import "UserInfoModel.h"
|
#import "UserInfoModel.h"
|
||||||
#import "XPLoginAuthCodeVC.h"
|
#import "XPLoginAuthCodeVC.h"
|
||||||
#import "FirstRechargeManager.h"
|
#import "FirstRechargeManager.h"
|
||||||
|
#import "PublicRoomManager.h"
|
||||||
|
|
||||||
@implementation PILoginManager
|
@implementation PILoginManager
|
||||||
+(void)loginWithVC:(MvpViewController *)VC isLoginPhone:(BOOL)isLoginPhone{
|
+(void)loginWithVC:(MvpViewController *)VC isLoginPhone:(BOOL)isLoginPhone{
|
||||||
@@ -86,5 +87,8 @@
|
|||||||
|
|
||||||
// 登录成功并进入主页后,启动首充监控
|
// 登录成功并进入主页后,启动首充监控
|
||||||
[[FirstRechargeManager sharedManager] startMonitoring];
|
[[FirstRechargeManager sharedManager] startMonitoring];
|
||||||
|
|
||||||
|
// 初始化公共房间管理器
|
||||||
|
[[PublicRoomManager sharedManager] initialize];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#import "LoginFullInfoProtocol.h"
|
#import "LoginFullInfoProtocol.h"
|
||||||
#import "PILoginManager.h"
|
#import "PILoginManager.h"
|
||||||
#import "ClientConfig.h"
|
#import "ClientConfig.h"
|
||||||
|
#import "PublicRoomManager.h"
|
||||||
|
|
||||||
#import "RegionListViewController.h"
|
#import "RegionListViewController.h"
|
||||||
|
|
||||||
@@ -370,6 +371,9 @@
|
|||||||
///需要重新加载一次 ticket 刷新tabbar的item
|
///需要重新加载一次 ticket 刷新tabbar的item
|
||||||
[[AccountInfoStorage instance] saveTicket:nil];
|
[[AccountInfoStorage instance] saveTicket:nil];
|
||||||
|
|
||||||
|
// 初始化公共房间管理器
|
||||||
|
[[PublicRoomManager sharedManager] initialize];
|
||||||
|
|
||||||
NSString * inviteCode = self.codeTextField.text.length > 0 ? self.codeTextField.text : @"";
|
NSString * inviteCode = self.codeTextField.text.length > 0 ? self.codeTextField.text : @"";
|
||||||
[PILoginManager jumpToHomeVCWithInviteCode:inviteCode];
|
[PILoginManager jumpToHomeVCWithInviteCode:inviteCode];
|
||||||
}
|
}
|
||||||
|
@@ -8,12 +8,14 @@
|
|||||||
#import "PublicRoomManager.h"
|
#import "PublicRoomManager.h"
|
||||||
#import "UserInfoModel.h"
|
#import "UserInfoModel.h"
|
||||||
#import "ClientConfig.h"
|
#import "ClientConfig.h"
|
||||||
|
#import "AccountModel.h"
|
||||||
#import "AccountInfoStorage.h"
|
#import "AccountInfoStorage.h"
|
||||||
#import "XPMessageRemoteExtModel.h"
|
#import "XPMessageRemoteExtModel.h"
|
||||||
#import "AttachmentModel.h"
|
#import "AttachmentModel.h"
|
||||||
#import "YUMIConstant.h"
|
#import "YUMIConstant.h"
|
||||||
|
#import "XPSkillCardPlayerManager.h"
|
||||||
|
|
||||||
@interface PublicRoomManager () <NIMChatManagerDelegate>
|
@interface PublicRoomManager () <NIMChatroomManagerDelegate, NIMChatManagerDelegate>
|
||||||
|
|
||||||
@property (nonatomic, assign) BOOL isInitialized;
|
@property (nonatomic, assign) BOOL isInitialized;
|
||||||
@property (nonatomic, assign) BOOL isInPublicRoom;
|
@property (nonatomic, assign) BOOL isInPublicRoom;
|
||||||
@@ -58,68 +60,52 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查用户是否已登录
|
|
||||||
// NSString *uid = [AccountInfoStorage instance].getUid;
|
|
||||||
// if (uid.length == 0) {
|
|
||||||
// NSLog(@"PublicRoomManager: 用户未登录,无法初始化");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 检查是否已获取到用户信息
|
|
||||||
// UserInfoModel *userInfo = [AccountInfoStorage instance].getHomeUserInfo;
|
|
||||||
// if (!userInfo || !userInfo.partitionId) {
|
|
||||||
// NSLog(@"PublicRoomManager: 用户信息不完整,等待用户信息更新");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 检查配置信息是否已加载
|
|
||||||
// ClientDataModel *configInfo = [ClientConfig shareConfig].configInfo;
|
|
||||||
// if (!configInfo || !configInfo.publicChatRoomIdMap) {
|
|
||||||
// NSLog(@"PublicRoomManager: 配置信息未加载,等待配置更新");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 保存用户信息
|
|
||||||
// self.userInfo = userInfo;
|
|
||||||
// self.currentUserId = uid;
|
|
||||||
|
|
||||||
// 注册云信代理
|
// 注册云信代理
|
||||||
[[NIMSDK sharedSDK].chatManager addDelegate:self];
|
[[NIMSDK sharedSDK].chatManager addDelegate:self];
|
||||||
|
[[NIMSDK sharedSDK].chatroomManager addDelegate:self];
|
||||||
|
|
||||||
// 标记为已初始化
|
// 标记为已初始化
|
||||||
self.isInitialized = YES;
|
self.isInitialized = YES;
|
||||||
|
}
|
||||||
|
|
||||||
// NSLog(@"PublicRoomManager: 初始化成功,用户ID: %@, 分区ID: %@", uid, userInfo.partitionId);
|
- (BOOL)checkConfigPublicRoomID:(NSString *)partitionId {
|
||||||
|
ClientDataModel *configInfo = [ClientConfig shareConfig].configInfo;
|
||||||
|
if (!configInfo || !configInfo.publicChatRoomIdMap) {
|
||||||
|
NSLog(@"PublicRoomManager: 配置信息未加载,等待配置更新");
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
// 尝试进入公共房间
|
self.currentPublicRoomId = [configInfo.publicChatRoomIdMap objectForKey:partitionId];
|
||||||
// [self tryEnterPublicRoom];
|
|
||||||
|
return [NSString isEmpty:self.currentPublicRoomId];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reset {
|
- (void)reset {
|
||||||
NSLog(@"PublicRoomManager: 开始重置");
|
NSLog(@"PublicRoomManager: 开始重置");
|
||||||
|
|
||||||
// 退出公共房间
|
// 退出公共房间(同步等待完成)
|
||||||
if (self.isInPublicRoom && self.currentPublicRoomId) {
|
if (self.isInPublicRoom && self.currentPublicRoomId) {
|
||||||
[self exitPublicRoomWithCompletion:^(NSError * _Nullable error) {
|
[self exitPublicRoomWithCompletion:^(NSError * _Nullable error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"PublicRoomManager: 退出公共房间失败: %@", error);
|
NSLog(@"PublicRoomManager: 退出公共房间失败: %@", error);
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"PublicRoomManager: 退出公共房间成功");
|
NSLog(@"PublicRoomManager: 退出公共房间成功");
|
||||||
|
|
||||||
|
self.currentUserId = nil;
|
||||||
|
self.userInfo = nil;
|
||||||
|
|
||||||
|
NSLog(@"PublicRoomManager: 重置完成");
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
} else {
|
||||||
|
NSLog(@"PublicRoomManager: 不在房间,不处理");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除云信代理
|
|
||||||
[[NIMSDK sharedSDK].chatManager removeDelegate:self];
|
|
||||||
|
|
||||||
// 重置状态
|
// 重置状态
|
||||||
self.isInitialized = NO;
|
self.isInitialized = NO;
|
||||||
self.isInPublicRoom = NO;
|
self.isInPublicRoom = NO;
|
||||||
self.currentPublicRoomId = nil;
|
self.currentPublicRoomId = nil;
|
||||||
self.currentUserId = nil;
|
|
||||||
self.userInfo = nil;
|
|
||||||
|
|
||||||
NSLog(@"PublicRoomManager: 重置完成");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - 状态查询
|
#pragma mark - 状态查询
|
||||||
@@ -139,8 +125,19 @@
|
|||||||
#pragma mark - 私有方法
|
#pragma mark - 私有方法
|
||||||
|
|
||||||
- (void)tryEnterPublicRoom {
|
- (void)tryEnterPublicRoom {
|
||||||
if (!self.isInitialized || !self.userInfo) {
|
NSLog(@"PublicRoomManager: 开始尝试进入公共房间");
|
||||||
NSLog(@"PublicRoomManager: 未初始化或用户信息缺失,无法进入公共房间");
|
NSLog(@"PublicRoomManager: 当前状态 - isInitialized: %@, isInPublicRoom: %@, currentPublicRoomId: %@",
|
||||||
|
self.isInitialized ? @"YES" : @"NO",
|
||||||
|
self.isInPublicRoom ? @"YES" : @"NO",
|
||||||
|
self.currentPublicRoomId ?: @"nil");
|
||||||
|
|
||||||
|
if (!self.isInitialized) {
|
||||||
|
NSLog(@"PublicRoomManager: 管理器未初始化,无法进入公共房间");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!self.userInfo) {
|
||||||
|
NSLog(@"PublicRoomManager: 用户信息缺失,无法进入公共房间");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,8 +146,18 @@
|
|||||||
ClientDataModel *configInfo = [ClientConfig shareConfig].configInfo;
|
ClientDataModel *configInfo = [ClientConfig shareConfig].configInfo;
|
||||||
NSDictionary *publicChatRoomIdMap = configInfo.publicChatRoomIdMap;
|
NSDictionary *publicChatRoomIdMap = configInfo.publicChatRoomIdMap;
|
||||||
|
|
||||||
if (!publicChatRoomIdMap || !partitionId) {
|
NSLog(@"PublicRoomManager: 配置信息 - partitionId: %@, configInfo: %@, publicChatRoomIdMap: %@",
|
||||||
NSLog(@"PublicRoomManager: 公共房间配置或分区ID缺失");
|
partitionId ?: @"nil",
|
||||||
|
configInfo ? @"存在" : @"nil",
|
||||||
|
publicChatRoomIdMap ? @"存在" : @"nil");
|
||||||
|
|
||||||
|
if (!publicChatRoomIdMap) {
|
||||||
|
NSLog(@"PublicRoomManager: 公共房间配置缺失");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!partitionId) {
|
||||||
|
NSLog(@"PublicRoomManager: 分区ID缺失");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +174,7 @@
|
|||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"PublicRoomManager: 进入公共房间失败: %@", error);
|
NSLog(@"PublicRoomManager: 进入公共房间失败: %@", error);
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"PublicRoomManager: 进入公共房间成功");
|
NSLog(@"PublicRoomManager: 进入公共房间成功,房间ID: %@", roomId.stringValue);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -176,7 +183,7 @@
|
|||||||
if (!self.userInfo) {
|
if (!self.userInfo) {
|
||||||
NSError *error = [NSError errorWithDomain:@"PublicRoomManager"
|
NSError *error = [NSError errorWithDomain:@"PublicRoomManager"
|
||||||
code:-1
|
code:-1
|
||||||
userInfo:@{NSLocalizedDescriptionKey: @"用户信息缺失"}];
|
userInfo:@{NSLocalizedDescriptionKey: @"用户信息缺失 nnn"}];
|
||||||
if (completion) {
|
if (completion) {
|
||||||
completion(error);
|
completion(error);
|
||||||
}
|
}
|
||||||
@@ -186,7 +193,6 @@
|
|||||||
// 创建进房请求
|
// 创建进房请求
|
||||||
NIMChatroomEnterRequest *request = [[NIMChatroomEnterRequest alloc] init];
|
NIMChatroomEnterRequest *request = [[NIMChatroomEnterRequest alloc] init];
|
||||||
request.roomId = roomId;
|
request.roomId = roomId;
|
||||||
|
|
||||||
// 设置扩展信息
|
// 设置扩展信息
|
||||||
XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init];
|
XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init];
|
||||||
extModel.defUser = self.userInfo.defUser;
|
extModel.defUser = self.userInfo.defUser;
|
||||||
@@ -269,6 +275,8 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"PublicRoomManager: room id-%@ 正在尝试退出公共房间", self.currentPublicRoomId);
|
||||||
|
|
||||||
@kWeakify(self);
|
@kWeakify(self);
|
||||||
[[NIMSDK sharedSDK].chatroomManager exitChatroom:self.currentPublicRoomId completion:^(NSError * _Nullable error) {
|
[[NIMSDK sharedSDK].chatroomManager exitChatroom:self.currentPublicRoomId completion:^(NSError * _Nullable error) {
|
||||||
@kStrongify(self);
|
@kStrongify(self);
|
||||||
@@ -290,8 +298,17 @@
|
|||||||
#pragma mark - 用户信息更新处理
|
#pragma mark - 用户信息更新处理
|
||||||
|
|
||||||
- (void)updateUserInfo:(UserInfoModel *)userInfo {
|
- (void)updateUserInfo:(UserInfoModel *)userInfo {
|
||||||
if (!userInfo || !userInfo.partitionId) {
|
NSLog(@"PublicRoomManager: 开始更新用户信息");
|
||||||
NSLog(@"PublicRoomManager: 用户信息更新失败,信息不完整");
|
NSLog(@"PublicRoomManager: 用户信息 - uid: %ld, partitionId: %@",
|
||||||
|
userInfo.uid, userInfo.partitionId ?: @"nil");
|
||||||
|
|
||||||
|
if (!userInfo) {
|
||||||
|
NSLog(@"PublicRoomManager: 用户信息为空,更新失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userInfo.partitionId) {
|
||||||
|
NSLog(@"PublicRoomManager: 用户分区ID缺失,更新失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,11 +320,25 @@
|
|||||||
|
|
||||||
self.userInfo = userInfo;
|
self.userInfo = userInfo;
|
||||||
self.currentUserId = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
self.currentUserId = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||||
|
if (![self checkConfigPublicRoomID:@(userInfo.uid).stringValue]) {
|
||||||
// 如果已初始化但未在公共房间,尝试进入
|
return;
|
||||||
if (self.isInitialized && !self.isInPublicRoom) {
|
|
||||||
[self tryEnterPublicRoom];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"PublicRoomManager: 用户信息更新完成 - currentUserId: %@, isInitialized: %@, isInPublicRoom: %@",
|
||||||
|
self.currentUserId,
|
||||||
|
self.isInitialized ? @"YES" : @"NO",
|
||||||
|
self.isInPublicRoom ? @"YES" : @"NO");
|
||||||
|
|
||||||
|
// 注释掉自动进入房间逻辑,改为统一入口控制
|
||||||
|
// 如果已初始化但未在公共房间,尝试进入
|
||||||
|
// if (self.isInitialized && !self.isInPublicRoom) {
|
||||||
|
// NSLog(@"PublicRoomManager: 条件满足,开始尝试进入公共房间");
|
||||||
|
// [self tryEnterPublicRoom];
|
||||||
|
// } else {
|
||||||
|
// NSLog(@"PublicRoomManager: 条件不满足,跳过进入公共房间 - isInitialized: %@, isInPublicRoom: %@",
|
||||||
|
// self.isInitialized ? @"YES" : @"NO",
|
||||||
|
// self.isInPublicRoom ? @"YES" : @"NO");
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - 配置更新处理
|
#pragma mark - 配置更新处理
|
||||||
@@ -324,10 +355,18 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注释掉自动进入房间逻辑,改为统一入口控制
|
||||||
// 如果未在公共房间,尝试进入
|
// 如果未在公共房间,尝试进入
|
||||||
if (!self.isInPublicRoom) {
|
// if (!self.isInPublicRoom) {
|
||||||
[self tryEnterPublicRoom];
|
// [self tryEnterPublicRoom];
|
||||||
}
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NIMChatRoomManagerDelegate
|
||||||
|
#define ConnectionStateStyleString(enum) \
|
||||||
|
[@[@"Entering", @"EnterOK", @"EnterFailed", @"LoseConnection"] objectAtIndex:(enum)]
|
||||||
|
- (void)chatroom:(NSString *)roomId connectionStateChanged:(NIMChatroomConnectionState)state {
|
||||||
|
NSLog(@"PublicRoomManager 房间连接状态: %@", ConnectionStateStyleString(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - NIMChatManagerDelegate
|
#pragma mark - NIMChatManagerDelegate
|
||||||
@@ -355,9 +394,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSLog(@"PublicRoomManager: 收到公共房间消息: %@\n%@",
|
// NSLog(@"PublicRoomManager: 收到公共房间消息: %@\n%@",
|
||||||
message.rawAttachContent,
|
// message.rawAttachContent,
|
||||||
messageExt.roomExt);
|
// messageExt.roomExt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,6 +404,12 @@
|
|||||||
|
|
||||||
- (void)handleFirst_106:(AttachmentModel *)attachment
|
- (void)handleFirst_106:(AttachmentModel *)attachment
|
||||||
message:(NIMMessage *)message {
|
message:(NIMMessage *)message {
|
||||||
|
// 只有用户在房间时,才会转发
|
||||||
|
if (![XPSkillCardPlayerManager shareInstance].isInRoom) {
|
||||||
|
NSLog(@"PublicRoomManager: 用户未在房间中,跳过消息转发");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (attachment.second) {
|
switch (attachment.second) {
|
||||||
case Custom_Message_Sub_Super_Gift:
|
case Custom_Message_Sub_Super_Gift:
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"MessageFromPublicRoomWithAttachmentNotification"
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"MessageFromPublicRoomWithAttachmentNotification"
|
||||||
|
@@ -199,13 +199,32 @@ exitCurrentRoom:(void(^)(void))exit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 在弹框显示前保存必要数据,避免依赖banner对象
|
||||||
|
NSString *targetRoomUid = self.model.roomUid;
|
||||||
|
void(^exitCurrentRoomBlock)(void) = self.exitCurrentRoom;
|
||||||
|
|
||||||
@kWeakify(self);
|
@kWeakify(self);
|
||||||
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
||||||
@kStrongify(self);
|
@kStrongify(self);
|
||||||
|
|
||||||
|
// 检查banner是否还存在
|
||||||
|
if (!self) {
|
||||||
|
NSLog(@"⚠️ LuckyGiftWinningBannerView: banner已被移除,但弹框回调仍在执行");
|
||||||
|
// 即使banner被移除,仍然执行跳转逻辑
|
||||||
|
if (exitCurrentRoomBlock) {
|
||||||
|
exitCurrentRoomBlock();
|
||||||
|
}
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
[XPRoomViewController openRoom:targetRoomUid
|
||||||
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// banner还存在,正常执行
|
||||||
if (self.exitCurrentRoom) {
|
if (self.exitCurrentRoom) {
|
||||||
self.exitCurrentRoom();
|
self.exitCurrentRoom();
|
||||||
}
|
}
|
||||||
NSString *targetRoomUid = self.model.roomUid;
|
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
[XPRoomViewController openRoom:targetRoomUid
|
[XPRoomViewController openRoom:targetRoomUid
|
||||||
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||||
|
@@ -55,9 +55,6 @@ exitCurrentRoom:(void(^)(void))exit {
|
|||||||
[superView addSubview:banner];
|
[superView addSubview:banner];
|
||||||
|
|
||||||
NSInteger time = 3;
|
NSInteger time = 3;
|
||||||
//#if DEBUG
|
|
||||||
// time = 3000;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
@kWeakify(banner);
|
@kWeakify(banner);
|
||||||
[banner popEnterAnimation:^(BOOL finished) {
|
[banner popEnterAnimation:^(BOOL finished) {
|
||||||
@@ -148,13 +145,32 @@ exitCurrentRoom:(void(^)(void))exit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 在弹框显示前保存必要数据,避免依赖banner对象
|
||||||
|
NSNumber *targetRoomUid = self.model.roomUid;
|
||||||
|
void(^exitCurrentRoomBlock)(void) = self.exitCurrentRoom;
|
||||||
|
|
||||||
@kWeakify(self);
|
@kWeakify(self);
|
||||||
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
||||||
@kStrongify(self);
|
@kStrongify(self);
|
||||||
|
|
||||||
|
// 检查banner是否还存在
|
||||||
|
if (!self) {
|
||||||
|
NSLog(@"⚠️ BravoGiftBannerView: banner已被移除,但弹框回调仍在执行");
|
||||||
|
// 即使banner被移除,仍然执行跳转逻辑
|
||||||
|
if (exitCurrentRoomBlock) {
|
||||||
|
exitCurrentRoomBlock();
|
||||||
|
}
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
[XPRoomViewController openRoom:targetRoomUid.stringValue
|
||||||
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// banner还存在,正常执行
|
||||||
if (self.exitCurrentRoom) {
|
if (self.exitCurrentRoom) {
|
||||||
self.exitCurrentRoom();
|
self.exitCurrentRoom();
|
||||||
}
|
}
|
||||||
NSNumber *targetRoomUid = self.model.roomUid;
|
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
[XPRoomViewController openRoom:targetRoomUid.stringValue
|
[XPRoomViewController openRoom:targetRoomUid.stringValue
|
||||||
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||||
|
@@ -204,15 +204,34 @@ exitCurrentRoom:(void(^)(void))exit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 在弹框显示前保存必要数据,避免依赖banner对象
|
||||||
|
NSInteger targetRoomUid = self.model.roomUid;
|
||||||
|
void(^exitCurrentRoomBlock)(void) = self.exitCurrentRoom;
|
||||||
|
|
||||||
@kWeakify(self);
|
@kWeakify(self);
|
||||||
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
||||||
@kStrongify(self);
|
@kStrongify(self);
|
||||||
|
|
||||||
|
// 检查banner是否还存在
|
||||||
|
if (!self) {
|
||||||
|
NSLog(@"⚠️ LuckyPackageBannerView: banner已被移除,但弹框回调仍在执行");
|
||||||
|
// 即使banner被移除,仍然执行跳转逻辑
|
||||||
|
if (exitCurrentRoomBlock) {
|
||||||
|
exitCurrentRoomBlock();
|
||||||
|
}
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
[XPRoomViewController openRoom:@(targetRoomUid).stringValue
|
||||||
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// banner还存在,正常执行
|
||||||
if (self.exitCurrentRoom) {
|
if (self.exitCurrentRoom) {
|
||||||
self.exitCurrentRoom();
|
self.exitCurrentRoom();
|
||||||
}
|
}
|
||||||
NSString *targetRoomUid = @(self.model.roomUid).stringValue;
|
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
[XPRoomViewController openRoom:targetRoomUid
|
[XPRoomViewController openRoom:@(targetRoomUid).stringValue
|
||||||
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||||
});
|
});
|
||||||
} cancelHandler:^{}];
|
} cancelHandler:^{}];
|
||||||
|
@@ -95,6 +95,7 @@ make.width.mas_lessThanOrEqualTo(size.width).priority(UILayoutPriorityDefaultHig
|
|||||||
- 简化约束逻辑,提高可维护性
|
- 简化约束逻辑,提高可维护性
|
||||||
- 移除冗余计算,提升性能和代码清晰度
|
- 移除冗余计算,提升性能和代码清晰度
|
||||||
- 正确处理 contentLabel 边距,避免文本宽度计算错误
|
- 正确处理 contentLabel 边距,避免文本宽度计算错误
|
||||||
|
- 修复 preferredMaxLayoutWidth 设置,确保与文本容器宽度一致
|
||||||
|
|
||||||
## 技术要点
|
## 技术要点
|
||||||
|
|
||||||
@@ -121,6 +122,11 @@ make.width.mas_lessThanOrEqualTo(size.width).priority(UILayoutPriorityDefaultHig
|
|||||||
- 实际可用宽度 = `kRoomMessageMaxWidth - 24`
|
- 实际可用宽度 = `kRoomMessageMaxWidth - 24`
|
||||||
- 确保文本尺寸计算与实际渲染空间一致
|
- 确保文本尺寸计算与实际渲染空间一致
|
||||||
|
|
||||||
|
6. **preferredMaxLayoutWidth 一致性**:
|
||||||
|
- contentLabel 的 preferredMaxLayoutWidth 必须与文本容器宽度保持一致
|
||||||
|
- 设置为 `kRoomMessageMaxWidth - 24`,避免因宽度不匹配导致的文本截断
|
||||||
|
- 确保 YYTextLayout 计算和 UILabel 渲染使用相同的宽度基准
|
||||||
|
|
||||||
## 风险评估
|
## 风险评估
|
||||||
|
|
||||||
- **低风险**: 修改主要是修正错误的参数和方法调用
|
- **低风险**: 修改主要是修正错误的参数和方法调用
|
||||||
|
@@ -189,6 +189,7 @@
|
|||||||
- ✅ 统一的文本布局策略
|
- ✅ 统一的文本布局策略
|
||||||
- ✅ 提高文本尺寸计算的准确性和性能
|
- ✅ 提高文本尺寸计算的准确性和性能
|
||||||
- ✅ 避免约束冲突导致的布局异常
|
- ✅ 避免约束冲突导致的布局异常
|
||||||
|
- ✅ 修复 preferredMaxLayoutWidth 与文本容器宽度不一致导致的截断问题
|
||||||
|
|
||||||
## 风险评估
|
## 风险评估
|
||||||
|
|
||||||
|
@@ -339,6 +339,20 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
|||||||
|
|
||||||
[[IAPManager sharedManager] handleLogin];
|
[[IAPManager sharedManager] handleLogin];
|
||||||
[[IAPManager sharedManager] retryCheckAllReceipt];
|
[[IAPManager sharedManager] retryCheckAllReceipt];
|
||||||
|
|
||||||
|
// 统一入口:1秒后进入公共房间
|
||||||
|
// @kWeakify(self);
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
// @kStrongify(self);
|
||||||
|
NSLog(@"TabbarViewController: 统一入口 - 开始进入公共房间");
|
||||||
|
[[PublicRoomManager sharedManager] enterPublicRoomWithCompletion:^(NSError * _Nullable error) {
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"TabbarViewController: 进入公共房间失败: %@", error);
|
||||||
|
} else {
|
||||||
|
NSLog(@"TabbarViewController: 进入公共房间成功");
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)getRoomGameInfo{
|
-(void)getRoomGameInfo{
|
||||||
@@ -391,7 +405,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
|||||||
[[XPSkillCardPlayerManager shareInstance] requestBravoGiftTabInfomation];
|
[[XPSkillCardPlayerManager shareInstance] requestBravoGiftTabInfomation];
|
||||||
[[RoomBoomManager sharedManager] saveUserInfo:userInfo];
|
[[RoomBoomManager sharedManager] saveUserInfo:userInfo];
|
||||||
|
|
||||||
// 更新公共房间管理器的用户信息
|
// 初始化PublicRoomManager并更新用户信息
|
||||||
|
[[PublicRoomManager sharedManager] initialize];
|
||||||
[[PublicRoomManager sharedManager] updateUserInfo:userInfo];
|
[[PublicRoomManager sharedManager] updateUserInfo:userInfo];
|
||||||
|
|
||||||
[self getRoomGameInfo];
|
[self getRoomGameInfo];
|
||||||
|
Reference in New Issue
Block a user