From 68ba8875a5a5e078ad69f74e3e9bd65e9c011ba1 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 8 Dec 2021 11:45:03 +0800 Subject: [PATCH] feat: android and iOS support load assets file remotely on dev mode --- .../main/java/pub/doric/devkit/DoricDevAssetsLoader.java | 7 ++++++- doric-iOS/Devkit/Classes/DoricDevAssetsLoader.m | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java index d3083600..34ea702a 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java @@ -18,6 +18,7 @@ package pub.doric.devkit; import pub.doric.DoricContext; import pub.doric.resource.DoricAssetsLoader; import pub.doric.resource.DoricAssetsResource; +import pub.doric.resource.DoricRemoteResource; import pub.doric.resource.DoricResource; /** @@ -30,7 +31,11 @@ public class DoricDevAssetsLoader extends DoricAssetsLoader { @Override public DoricResource load(DoricContext doricContext, String identifier) { if (DoricDev.getInstance().isInDevMode()) { - + return new DoricRemoteResource(doricContext, + String.format("http://%s:7778/assets/%s", + DoricDev.getInstance().getIP(), + identifier + )); } return new DoricAssetsResource(doricContext, "assets/" + identifier); } diff --git a/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.m b/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.m index 50da6e54..2b2233aa 100644 --- a/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.m +++ b/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.m @@ -4,12 +4,16 @@ #import "DoricDevAssetsLoader.h" #import "DoricDev.h" +#import @implementation DoricDevAssetsLoader - (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context { if (DoricDev.instance.isInDevMode) { - + return [[DoricRemoteResource alloc] initWithContext:context + identifier:[NSString stringWithFormat:@"http://%@:7778/assets/%@", + DoricDev.instance.ip, + identifier]]; } return [super load:identifier withContext:context]; }