1
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
//
|
||||
|
||||
#import "BaseTabBarController.h"
|
||||
#import "HomeVC.h"
|
||||
#import "HomeMainVC.h"
|
||||
#import "MyVC.h"
|
||||
#import "KBShopVC.h"
|
||||
|
||||
@@ -10,10 +10,13 @@
|
||||
#import "KBPanModalView.h"
|
||||
#import "KBGuideVC.h" // 首次安装指引页
|
||||
#import "WMDragView.h"
|
||||
#import "KBMyVM.h"
|
||||
#import "KBUserSessionManager.h"
|
||||
|
||||
@interface HomeMainVC ()
|
||||
@property (nonatomic, strong) HomeHeadView *headView;
|
||||
@property (nonatomic, strong) KBPanModalView *simplePanModalView;
|
||||
@property (nonatomic, strong) KBMyVM *viewModel;
|
||||
|
||||
/// 权限按钮
|
||||
@property (nonatomic, strong) WMDragView *keyPermissButton;
|
||||
@@ -65,6 +68,17 @@
|
||||
// NSLog(@"[MainApp] 写入完成");
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
if (![KBUserSessionManager shared].isLoggedIn) {
|
||||
return;
|
||||
}
|
||||
if (!self.viewModel) {
|
||||
self.viewModel = [[KBMyVM alloc] init];
|
||||
}
|
||||
[self.viewModel fetchUserDetailWithCompletion:nil];
|
||||
}
|
||||
|
||||
// 在界面可见后做“首次安装”检查,避免在 viewDidLoad 期间 push 引起的转场警告
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
//
|
||||
// HomeVC.h
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2025/10/29.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HomeVC : UIViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,61 +0,0 @@
|
||||
//
|
||||
// HomeVC.m
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2025/10/29.
|
||||
//
|
||||
|
||||
#import "HomeVC.h"
|
||||
#import "HomeHeadView.h"
|
||||
#import "HomeSheetVC.h"
|
||||
|
||||
@interface HomeVC ()
|
||||
@property (nonatomic, strong) HomeHeadView *headView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation HomeVC
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = [UIColor yellowColor];
|
||||
CGFloat topV = (500);
|
||||
|
||||
[self.view addSubview:self.headView];
|
||||
[self setupMas:topV];
|
||||
// 创建sheetVC
|
||||
HomeSheetVC *vc = [[HomeSheetVC alloc] init];
|
||||
// 使用宏,避免误写成函数指针判断导致恒为 true
|
||||
// if (KB_DEVICE_HAS_NOTCH) {
|
||||
// vc.minHeight = KB_SCREEN_HEIGHT - topV - 34;
|
||||
// }else{
|
||||
vc.minHeight = KB_SCREEN_HEIGHT - topV;
|
||||
//
|
||||
// }
|
||||
vc.topInset = 100;
|
||||
[self presentPanModal:vc];
|
||||
}
|
||||
|
||||
- (void)setupMas:(CGFloat)headViewTopV{
|
||||
[self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.view);
|
||||
make.top.equalTo(self.view);
|
||||
make.height.mas_equalTo(headViewTopV);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - lazy
|
||||
- (HomeHeadView *)headView{
|
||||
if (!_headView) {
|
||||
_headView = [[HomeHeadView alloc] init];
|
||||
}
|
||||
return _headView;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -47,6 +47,13 @@ NSString * const KBUserCharacterDeletedNotification = @"KBUserCharacterDeletedNo
|
||||
}
|
||||
|
||||
KBUser *user = [KBUser mj_objectWithKeyValues:(NSDictionary *)dataObj];
|
||||
NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
|
||||
if (user.avatarUrl.length > 0) {
|
||||
[sharedDefaults setObject:user.avatarUrl forKey:AppGroup_UserAvatarURL];
|
||||
} else {
|
||||
[sharedDefaults removeObjectForKey:AppGroup_UserAvatarURL];
|
||||
}
|
||||
[sharedDefaults synchronize];
|
||||
if (completion) completion(user, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -100,6 +100,14 @@ typedef void(^KBNetworkDataCompletion)(NSData *_Nullable data,
|
||||
headers:(nullable NSDictionary<NSString *, NSString *> *)headers
|
||||
completion:(KBNetworkCompletion)completion;
|
||||
|
||||
/// 上传本地文件(multipart/form-data)
|
||||
- (nullable NSURLSessionDataTask *)uploadFile:(NSString *)path
|
||||
fileURL:(NSURL *)fileURL
|
||||
name:(NSString *)name
|
||||
mimeType:(NSString *)mimeType
|
||||
parameters:(nullable NSDictionary *)parameters
|
||||
headers:(nullable NSDictionary<NSString *, NSString *> *)headers
|
||||
completion:(KBNetworkCompletion)completion;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -323,6 +323,42 @@ autoShowBusinessError:YES
|
||||
completion:completion];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)uploadFile:(NSString *)path
|
||||
fileURL:(NSURL *)fileURL
|
||||
name:(NSString *)name
|
||||
mimeType:(NSString *)mimeType
|
||||
parameters:(NSDictionary *)parameters
|
||||
headers:(NSDictionary<NSString *, NSString *> *)headers
|
||||
completion:(KBNetworkCompletion)completion {
|
||||
if (!fileURL || !fileURL.isFileURL) {
|
||||
if (completion) {
|
||||
NSError *e = [NSError errorWithDomain:KBNetworkErrorDomain
|
||||
code:KBNetworkErrorInvalidResponse
|
||||
userInfo:@{NSLocalizedDescriptionKey: KBLocalized(@"Invalid file")}];
|
||||
completion(nil, nil, e);
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
NSError *readError = nil;
|
||||
NSData *data = [NSData dataWithContentsOfURL:fileURL options:0 error:&readError];
|
||||
if (readError || data.length == 0) {
|
||||
if (completion) {
|
||||
NSError *e = readError ?: [NSError errorWithDomain:KBNetworkErrorDomain
|
||||
code:KBNetworkErrorInvalidResponse
|
||||
userInfo:@{NSLocalizedDescriptionKey: KBLocalized(@"Empty file data")}];
|
||||
completion(nil, nil, e);
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
NSString *fileName = fileURL.lastPathComponent ?: @"upload.bin";
|
||||
return [self uploadFile:path
|
||||
fileData:data
|
||||
fileName:fileName
|
||||
mimeType:mimeType
|
||||
headers:headers
|
||||
completion:completion];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Core
|
||||
|
||||
|
||||
Reference in New Issue
Block a user