feat:add debug option:start debugging

This commit is contained in:
pengfei.zhou
2021-03-02 15:11:16 +08:00
committed by osborn
parent de4188b74e
commit cf888e3655
7 changed files with 117 additions and 22 deletions

View File

@@ -61,6 +61,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)stopDebugging:(BOOL)resume;
- (void)requestDebugging:(DoricContext *)context;
- (BOOL)isReloadingContext:(DoricContext *)context;
- (void)reload:(NSString *)source script:(NSString *)script;

View File

@@ -227,6 +227,12 @@ - (void)stopDebugging:(BOOL)resume {
});
}
- (void)requestDebugging:(DoricContext *)context {
[self.wsClient sendToServer:@"DEBUG" payload:@{
@"source": context.source
}];
}
- (void)sendDevCommand:(NSString *)command payload:(NSDictionary *)payload {
[self.wsClient sendToServer:command payload:payload];
}

View File

@@ -105,11 +105,18 @@ - (void)onClick {
}];
[alertController addAction:cancel];
[alertController addAction:viewSource];
if ([self.doricContext.driver isKindOfClass:DoricDebugDriver.class]) {
UIAlertAction *stopDebugging = [UIAlertAction actionWithTitle:@"Stop debugging" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) {
[DoricDev.instance stopDebugging:YES];
}];
[alertController addAction:stopDebugging];
if (DoricDev.instance.isInDevMode) {
if ([self.doricContext.driver isKindOfClass:DoricDebugDriver.class]) {
UIAlertAction *stopDebugging = [UIAlertAction actionWithTitle:@"Stop debugging" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) {
[DoricDev.instance stopDebugging:YES];
}];
[alertController addAction:stopDebugging];
} else {
UIAlertAction *startDebugging = [UIAlertAction actionWithTitle:@"Start debugging" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) {
[DoricDev.instance requestDebugging:self.doricContext];
}];
[alertController addAction:startDebugging];
}
}
[self.vc presentViewController:alertController animated:true completion:nil];