项目结构-2021-01-05

2022-03-29  本文已影响0人  勇往直前888

文件结构

image.png image.png image.png image.png

简评

Configure配置参数

这个目录主要是一些宏定义,定义一些常数,常用的宏等等

/** 距离 **/
#define SCREEN_BOUNDS               [UIScreen mainScreen].bounds
#define SCREEN_SCALE                [[UIScreen mainScreen] scale]
#define SCREEN_SIZE                 [UIScreen mainScreen].bounds.size
#define SCREEN_WIDTH                [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT               [UIScreen mainScreen].bounds.size.height
//根据iPhone6的屏幕大小缩放,适配当前屏幕
#define AutoScaleWidth(x)           ((SCREEN_WIDTH/375.00) * (x))
#define AutoScaleHeight(x)          ((SCREEN_HEIGHT/667.00) * (x))
//安全区域
#define SAFEAREAINSETS [XLHelperTool xl_safeAreaInsets]
+ (UIEdgeInsets)xl_safeAreaInsets {
    UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
    if (![window isKeyWindow]) {
        UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
        if (CGRectEqualToRect(keyWindow.bounds, [UIScreen mainScreen].bounds)) {
            window = keyWindow;
        }
    }
    if (@available(iOS 11.0, *)) {
        UIEdgeInsets insets = [window safeAreaInsets];
        return insets;
    }
    return UIEdgeInsetsZero;
}
//状态栏高度
#define STATUSBAR_HEIGHT (([UIWindow instancesRespondToSelector:@selector(safeAreaInsets)]) ? (SAFEAREAINSETS.top ?: 20) : 20)
//距离底部安全距离
#define SAFEAREA_BOTTOM_HEIGHT SAFEAREAINSETS.bottom
//导航栏高度
#define NAVIGATIONBAR_HEIGHT     (44 + STATUSBAR_HEIGHT)
//tabar高度
#define XL_TABBAR_HEIGHT         (49 + SAFEAREA_BOTTOM_HEIGHT)
//开发环境
//#define XLServerHttpDomain @"http://10.166.8.14:8130/"

//测试环境
#define XLServerHttpDomain @"https://appuat.mirrorftech.com/"

//公网测试
//#define XLServerHttpDomain @"https://apptest.mirrorftech.com/"
//颜色
#define COLOR_WITH_HEX(color)       [UIColor colorWithHex:(color) alpha:1.0]
+ (instancetype)colorWithHex:(NSInteger)hexValue {
    return [UIColor colorWithHex:hexValue alpha:1.0f];
}

+ (instancetype)colorWithHex:(NSInteger)hexValue alpha:(CGFloat)alpha {
    return [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16)) / 255.0
                           green:((float)((hexValue & 0xFF00) >> 8)) / 255.0
                            blue:((float)(hexValue & 0xFF)) / 255.0
                           alpha:alpha];
}
//弱引用
#define WEAKSELF                    typeof(self) __weak weakSelf=self;
//强引用
#define STRONGSELF                  __strong __typeof(weakSelf) strongSelf = weakSelf;
// 用户看到的1.0.0之类的
#define SYSTEM_VERSION              [[UIDevice currentDevice] systemVersion]

//app版本; build号;一个数字比如123
#define XLAPPVERSION         [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    //界面初始配置
    [self.startUpConfig configAppWithApplication:application launchOptions:launchOptions];
    
    return YES;
}
- (void)configAppWithApplication:(UIApplication *)application
                   launchOptions:(NSDictionary *)launchOptions {
    UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    XLBaseTabBarController *tabbarVC = [[XLBaseTabBarController alloc] init];
    window.rootViewController = [[XLBaseNavigationController alloc] initWithRootViewController:tabbarVC];
    [AppDelegate sharedInstance].window = window;
    [AppDelegate sharedInstance].navigationController = (XLBaseNavigationController *)window.rootViewController;
    [window makeKeyAndVisible];
    window.backgroundColor = [UIColor whiteColor];
    [[DTFrameworkInterface sharedInstance] manualInitMpaasFrameworkWithApplication:application launchOptions:launchOptions];
    
    if (XLLogEnable) {
        [XLAppLog setLogEnable:YES];
    } else {
        [XLAppLog setLogEnable:NO];
    }
    
    NSString *token = [XLUserDefaults getLastAvailableToken];
    [XLNetworking updateCustomHeaderDicWithToken:token];
    
    // 判断网络权限
    [ZYNetworkAccessibity start];
    
    //配置消息推送
    [self.pushTool configXLPush];
    
    //设置IQ键盘
    [self keyBoardConfig];
    
    //设置UI整体样式
    [self.uiConfig configUI];
    
    //直接进入首页
    [self jumpMainControllerWithVC:nil];
}

DTFrameworkInterface这是mPaaS的初始化入口

+(void)redirectNSLogToFile
{
    if(NO==gEnableXLLog)
        return;
    //如果已经连接Xcode调试则不输出到文件
    if(isatty(STDOUT_FILENO)) {
        return;
    }
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *logDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Log"];
    
    NSFileManager *fileManager = [NSFileManager defaultManager];
    BOOL fileExists = [fileManager fileExistsAtPath:logDirectory];
    if (!fileExists) {
        [fileManager createDirectoryAtPath:logDirectory  withIntermediateDirectories:YES attributes:nil error:nil];
    }
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"]];
    [formatter setDateFormat:@"yyyy-MM-dd"]; //每次启动后都保存一个新的日志文件中
    NSString *dateStr = [formatter stringFromDate:[NSDate date]];
    NSString *logFilePath = [logDirectory stringByAppendingFormat:@"/%@.log",dateStr];
    
    // 将log输入到文件
    freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], "a+", stdout);
    freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], "a+", stderr);
    
}
上一篇下一篇

猜你喜欢

热点阅读