禁用 MiniRoom 悬浮球(v0.2 版本)

问题:
- MiniRoom 悬浮球在启动时就显示
- v0.2 版本不包含房间功能,不需要此组件

修复:
1. 注释 setupRoomMiniView 调用
2. 添加版本说明注释
3. 后续版本可通过 Build Configuration 控制

影响范围:
- 仅影响 EPTabBarController
- GlobalEventManager 保留完整代码
- 便于后续版本恢复

技术说明:
- v0.2: 无 MiniRoom(当前)
- v0.5+: 启用 MiniRoom(需要房间功能)
- 使用注释而非删除,便于版本管理
This commit is contained in:
edwinQQQ
2025-10-10 15:40:28 +08:00
parent 12a8ef9a62
commit 49ac7efa66
11 changed files with 466 additions and 47 deletions

View File

@@ -0,0 +1,250 @@
//
// EPMineViewController.m
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import "EPMineViewController.h"
#import "EPMineHeaderView.h"
#import "EPMomentCell.h"
#import <Masonry/Masonry.h>
#import "Api+Moments.h"
#import "AccountInfoStorage.h"
#import "UserInfoModel.h"
#import "MomentsInfoModel.h"
#import <MJExtension/MJExtension.h>
@interface EPMineViewController () <UITableViewDelegate, UITableViewDataSource>
// MARK: - UI Components
///
@property (nonatomic, strong) UITableView *tableView;
///
@property (nonatomic, strong) EPMineHeaderView *headerView;
// MARK: - Data
///
@property (nonatomic, strong) NSMutableArray<MomentsInfoModel *> *momentsData;
///
@property (nonatomic, assign) NSInteger currentPage;
///
@property (nonatomic, assign) BOOL isLoading;
///
@property (nonatomic, strong) UserInfoModel *userInfo;
@end
@implementation EPMineViewController
// MARK: - Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
self.momentsData = [NSMutableArray array];
self.currentPage = 1;
self.isLoading = NO;
[self setupUI];
[self loadUserInfo];
[self loadUserMoments];
NSLog(@"[EPMineViewController] 个人主页加载完成");
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//
[self refreshUserInfo];
}
// MARK: - Setup
- (void)setupGradientBackground {
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = self.view.bounds;
gradientLayer.colors = @[
(id)[UIColor colorWithRed:0.3 green:0.2 blue:0.6 alpha:1.0].CGColor, // #4C3399
(id)[UIColor colorWithRed:0.2 green:0.3 blue:0.8 alpha:1.0].CGColor // #3366CC
];
gradientLayer.startPoint = CGPointMake(0, 0);
gradientLayer.endPoint = CGPointMake(1, 1);
[self.view.layer insertSublayer:gradientLayer atIndex:0];
}
- (void)setupUI {
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:kImage(@"vc_bg")];
[self.view addSubview:bgImageView];
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
[self setupHeaderView];
[self setupTableView];
NSLog(@"[EPMineViewController] UI 设置完成");
}
- (void)setupHeaderView {
self.headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300)];
[self.view addSubview:self.headerView];
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(20);
make.left.right.equalTo(self.view);
make.height.equalTo(@300);
}];
}
- (void)setupTableView {
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.showsVerticalScrollIndicator = NO;
// cell EPMomentCell
[self.tableView registerClass:[EPMomentCell class] forCellReuseIdentifier:@"EPMomentCell"];
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.headerView.mas_bottom).offset(10);
make.left.right.equalTo(self.view);
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
}];
//
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
self.tableView.refreshControl = refreshControl;
}
// MARK: - Data Loading
- (void)loadUserInfo {
NSString *uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
NSLog(@"[EPMineViewController] 未登录,无法获取用户信息");
return;
}
// API
[Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200 && data.data) {
self.userInfo = [UserInfoModel mj_objectWithKeyValues:data.data];
//
NSDictionary *userInfoDict = @{
@"nickname": self.userInfo.nick ?: @"未设置昵称",
@"avatar": self.userInfo.avatar ?: @"",
@"uid": self.userInfo.uid > 0 ? @(self.userInfo.uid).stringValue : @"",
@"followers": @(self.userInfo.fansNum),
@"following": @(self.userInfo.followNum),
};
[self.headerView updateWithUserInfo:userInfoDict];
NSLog(@"[EPMineViewController] 用户信息加载成功: %@", self.userInfo.nick);
} else {
NSLog(@"[EPMineViewController] 用户信息加载失败: %@", msg);
}
} uid:uid];
}
- (void)refreshUserInfo {
[self loadUserInfo];
}
- (void)loadUserMoments {
if (self.isLoading) return;
NSString *uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
NSLog(@"[EPMineViewController] 未登录,无法获取用户动态");
return;
}
self.isLoading = YES;
NSString *page = [NSString stringWithFormat:@"%ld", (long)self.currentPage];
// API API
[Api momentsRecommendList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
self.isLoading = NO;
[self.refreshControl endRefreshing];
if (code == 200 && data.data) {
NSArray *list = [MomentsInfoModel mj_objectArrayWithKeyValuesArray:data.data];
if (list.count > 0) {
[self.momentsData addObjectsFromArray:list];
self.currentPage++;
[self.tableView reloadData];
NSLog(@"[EPMineViewController] 用户动态加载成功,新增 %lu 条", (unsigned long)list.count);
}
} else {
NSLog(@"[EPMineViewController] 用户动态加载失败: %@", msg);
}
} page:page pageSize:@"10" types:@"0,2"];
}
- (void)refreshData {
self.currentPage = 1;
[self.momentsData removeAllObjects];
[self loadUserMoments];
}
// MARK: - UITableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.momentsData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
EPMomentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EPMomentCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor clearColor];
if (indexPath.row < self.momentsData.count) {
[cell configureWithModel:self.momentsData[indexPath.row]];
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 200; //
}
// MARK: - UITableView Delegate
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
//
if (indexPath.row == self.momentsData.count - 1 && !self.isLoading) {
[self loadUserMoments];
}
}
// MARK: - Lazy Loading
- (EPMineHeaderView *)headerView {
if (!_headerView) {
_headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300)];
}
return _headerView;
}
- (UIRefreshControl *)refreshControl {
return self.tableView.refreshControl;
}
@end