feat:add Environment
This commit is contained in:
parent
24fb291ba8
commit
7247d99db6
@ -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);
|
||||||
}];
|
}];
|
||||||
|
@ -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;
|
||||||
|
@ -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";
|
||||||
|
Reference in New Issue
Block a user