Refact:delete and optimize code

This commit is contained in:
pengfeizhou
2021-02-23 17:24:02 +08:00
committed by osborn
parent 2f7762e670
commit 04c19992ad
8 changed files with 149 additions and 32 deletions

View File

@@ -24,7 +24,6 @@
NS_ASSUME_NONNULL_BEGIN
@interface DoricDev : NSObject
@property(nonatomic, strong, nullable) DoricWSClient *wsClient;
+ (instancetype)instance;
@@ -41,6 +40,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)stopDebugging:(BOOL)resume;
- (void)reload:(NSString *)source script:(NSString *)script;
- (void)sendDevCommand:(NSString *)command payload:(NSDictionary *)payload;
@end
NS_ASSUME_NONNULL_END

View File

@@ -63,6 +63,7 @@ - (void)stopDebug:(BOOL)resume {
@interface DoricDev ()
@property(nonatomic, strong, nullable) DoricWSClient *wsClient;
@property(nonatomic, strong) DoricContextDebuggable *debuggable;
@end
@@ -177,4 +178,8 @@ - (void)stopDebugging:(BOOL)resume {
[self.debuggable stopDebug:resume];
self.debuggable = nil;
}
- (void)sendDevCommand:(NSString *)command payload:(NSDictionary *)payload {
[self.wsClient sendToServer:command payload:payload];
}
@end

View File

@@ -30,11 +30,11 @@ - (void)onException:(NSException *)exception inContext:(DoricContext *)context {
if (!DoricDev.instance.isInDevMode) {
return;
}
[DoricDev.instance.wsClient sendToServer:@"EXCEPTION"
payload:@{
@"source": [context.source stringByReplacingOccurrencesOfString:@".js" withString:@".ts"],
@"exception": exception.reason
}];
[DoricDev.instance sendDevCommand:@"EXCEPTION"
payload:@{
@"source": [context.source stringByReplacingOccurrencesOfString:@".js" withString:@".ts"],
@"exception": exception.reason
}];
}
- (void)onLog:(DoricLogType)type message:(NSString *)message {
@@ -48,10 +48,10 @@ - (void)onLog:(DoricLogType)type message:(NSString *)message {
typeString = @"ERROR";
}
[DoricDev.instance.wsClient sendToServer:@"LOG"
payload:@{
@"type": typeString,
@"message": message
}];
[DoricDev.instance sendDevCommand:@"LOG"
payload:@{
@"type": typeString,
@"message": message
}];
}
@end