feat: android and iOS support load assets file remotely on dev mode

This commit is contained in:
pengfei.zhou 2021-12-08 11:45:03 +08:00 committed by osborn
parent 287015ae05
commit 68ba8875a5
2 changed files with 11 additions and 2 deletions

View File

@ -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);
}

View File

@ -4,12 +4,16 @@
#import "DoricDevAssetsLoader.h"
#import "DoricDev.h"
#import <DoricCore/DoricRemoteResource.h>
@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];
}