feat:add Environment

This commit is contained in:
pengfei.zhou 2019-12-10 20:30:43 +08:00
parent 24fb291ba8
commit 7247d99db6
3 changed files with 12 additions and 3 deletions

View File

@ -55,7 +55,15 @@ - (instancetype)init {
- (void)initJSExecutor { - (void)initJSExecutor {
__weak typeof(self) _self = self; __weak typeof(self) _self = self;
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
[self.jsExecutor injectGlobalJSObject:INJECT_ENVIRONMENT obj:@{
@"platform": @"iOS",
@"platformVersion": [[UIDevice currentDevice] systemVersion],
@"appName": infoDictionary[@"CFBundleName"],
@"appVersion": infoDictionary[@"CFBundleShortVersionString"],
@"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
@"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
}];
[self.jsExecutor injectGlobalJSObject:INJECT_LOG obj:^(NSString *type, NSString *message) { [self.jsExecutor injectGlobalJSObject:INJECT_LOG obj:^(NSString *type, NSString *message) {
DoricLog(@"JS:%@", message); DoricLog(@"JS:%@", message);
}]; }];

View File

@ -26,7 +26,7 @@ extern NSString *const DORIC_BUNDLE_SANDBOX;
extern NSString *const DORIC_BUNDLE_LIB; extern NSString *const DORIC_BUNDLE_LIB;
extern NSString *const DORIC_MODULE_LIB; extern NSString *const DORIC_MODULE_LIB;
extern NSString *const INJECT_ENVIRONMENT;
extern NSString *const INJECT_LOG; extern NSString *const INJECT_LOG;
extern NSString *const INJECT_REQUIRE; extern NSString *const INJECT_REQUIRE;
extern NSString *const INJECT_TIMER_SET; extern NSString *const INJECT_TIMER_SET;

View File

@ -26,6 +26,7 @@
NSString *const DORIC_BUNDLE_LIB = @"doric-lib"; NSString *const DORIC_BUNDLE_LIB = @"doric-lib";
NSString *const DORIC_MODULE_LIB = @"doric"; NSString *const DORIC_MODULE_LIB = @"doric";
NSString *const INJECT_ENVIRONMENT = @"Environment";
NSString *const INJECT_LOG = @"nativeLog"; NSString *const INJECT_LOG = @"nativeLog";
NSString *const INJECT_REQUIRE = @"nativeRequire"; NSString *const INJECT_REQUIRE = @"nativeRequire";