提交 03193f05 编写于 作者: Y yixiangboy

获取mock列表的时机需要更新

上级 dd78a880
......@@ -20,7 +20,7 @@
#define DoKitVersion @"3.0.0"
//#define DoKit_OpenLog
#define DoKit_OpenLog
#ifdef DoKit_OpenLog
#define DoKitLog(...) NSLog(@"%s\n %@ \n\n",__func__,[NSString stringWithFormat:__VA_ARGS__]);
......
......@@ -193,7 +193,9 @@ typedef void (^DoraemonPerformanceBlock)(NSDictionary *);
[[DoraemonStatisticsUtil shareInstance] upLoadUserInfo];
//拉取最新的mock数据
[[DoraemonMockManager sharedInstance] queryMockData];
[[DoraemonMockManager sharedInstance] queryMockData:^(int flag) {
DoKitLog(@"mock get data, flag == %i",flag);
}];
//Weex工具的初始化
#if DoraemonWithWeex
......
......@@ -10,6 +10,8 @@
#import "DoraemonMockUploadViewController.h"
#import "DoraemonMockAPIViewController.h"
#import "DoraemonMockManager.h"
#import "DoraemonHomeWindow.h"
@interface DoraemonMockViewController()
......@@ -20,23 +22,44 @@
- (void)viewDidLoad {
[super viewDidLoad];
UITabBarController *tabBar = [[UITabBarController alloc] init];
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
if (@available(iOS 13.0, *)) {
tabBar.tabBar.backgroundColor = [UIColor systemBackgroundColor];
if (UITraitCollection.currentTraitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -0.5, CGRectGetWidth(tabBar.tabBar.frame), 0.5)];
view.backgroundColor = [UIColor doraemon_black_3];
[tabBar.tabBar insertSubview:view atIndex:0];
//拉取最新的mock数据
[[DoraemonMockManager sharedInstance] queryMockData:^(int flag) {
NSString *toast = nil;
if (flag == 1) {
//toast = @"数据更新成功";
toast = nil;
}else if(flag == 2){
toast = @"数据更新失败";
}else if(flag == 3){
toast = @"pId为空 更新失败";
}
} else {
#endif
tabBar.tabBar.backgroundColor = [UIColor whiteColor];
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
}
#endif
DoKitLog(@"mock get data, flag == %i",flag);
[self renderUI];
if (toast.length > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[DoraemonToastUtil showToastBlack:toast inView:[DoraemonHomeWindow shareInstance]];
});
}
}];
}
- (void)renderUI{
UITabBarController *tabBar = [[UITabBarController alloc] init];
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
if (@available(iOS 13.0, *)) {
tabBar.tabBar.backgroundColor = [UIColor systemBackgroundColor];
if (UITraitCollection.currentTraitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -0.5, CGRectGetWidth(tabBar.tabBar.frame), 0.5)];
view.backgroundColor = [UIColor doraemon_black_3];
[tabBar.tabBar insertSubview:view atIndex:0];
}
} else {
#endif
tabBar.tabBar.backgroundColor = [UIColor whiteColor];
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
}
#endif
UIViewController *vc1 = [[DoraemonMockAPIViewController alloc] init];
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:vc1];
......@@ -56,7 +79,6 @@
tabBar.modalPresentationStyle = UIModalPresentationFullScreen;
[self.navigationController presentViewController:tabBar animated:NO completion:nil];
}
@end
......@@ -27,8 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSString *uploadState;//上传信息选中的状态
@property (nonatomic, copy) NSString *uploadSearchText;//上传信息的搜索关键字
- (void)queryMockData;
- (void)queryMockData:(void(^)(int flag))block;
- (BOOL)needMock:(NSURLRequest *)request;
......
......@@ -56,7 +56,7 @@
}
}
- (void)queryMockData{
- (void)queryMockData:(void(^)(int flag))block{
NSString *pId = [DoraemonManager shareInstance].pId;
if (pId && pId.length>0) {
NSDictionary *params = @{
......@@ -114,11 +114,14 @@
weakSelf.upLoadArray = uploadArray;
weakSelf.groups = groups;
[self handleData];
block(1);
} error:^(NSError * _Nonnull error) {
DoKitLog(@"error == %@",error);
block(2);
}];
}else{
DoKitLog(@"请求接口列表必须保证pId不为空");
block(3);
}
}
......
......@@ -72,12 +72,14 @@
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:[self shareInstance] delegateQueue:queue];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) {
errorAction(error);
} else {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
successAction(dic);
}
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
errorAction(error);
} else {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
successAction(dic);
}
});
}];
[dataTask resume];
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册