From d834f03835043b32a49271077a5157e4c47f2273 Mon Sep 17 00:00:00 2001 From: pengfeizhou Date: Thu, 25 Feb 2021 11:31:55 +0800 Subject: [PATCH] feat:reload match context adjust --- .../src/main/java/pub/doric/devkit/DoricDev.java | 4 +++- doric-iOS/Devkit/Classes/DoricDev.m | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java index 7c6e152b..576658f4 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java @@ -206,8 +206,10 @@ public class DoricDev { } public DoricContext matchContext(String source) { + source = source.replace(".js", "").replace(".ts", ""); for (DoricContext context : DoricContextManager.aliveContexts()) { - if (source.contains(context.getSource()) || context.getSource().equals("__dev__")) { + String doricSource = context.getSource().replace(".js", "").replace(".ts", ""); + if (source.equals(doricSource) || doricSource.equals("__dev__")) { return context; } } diff --git a/doric-iOS/Devkit/Classes/DoricDev.m b/doric-iOS/Devkit/Classes/DoricDev.m index 39de1a85..fcf85765 100644 --- a/doric-iOS/Devkit/Classes/DoricDev.m +++ b/doric-iOS/Devkit/Classes/DoricDev.m @@ -154,8 +154,18 @@ - (BOOL)isReloadingContext:(DoricContext *)context { - (DoricContext *)matchContext:(NSString *)source { + source = [[source stringByReplacingOccurrencesOfString:@".js" + withString:@""] + stringByReplacingOccurrencesOfString:@".ts" + withString:@"" + ]; for (DoricContext *context in [DoricContextManager.instance aliveContexts]) { - if ([source containsString:context.source] || [context.source isEqualToString:@"__dev__"]) { + NSString *contextSource = [[context.source stringByReplacingOccurrencesOfString:@".js" + withString:@""] + stringByReplacingOccurrencesOfString:@".ts" + withString:@"" + ]; + if ([source isEqualToString:contextSource] || [contextSource isEqualToString:@"__dev__"]) { return context; } }