feat: android and iOS support load assets file remotely on dev mode
This commit is contained in:
parent
287015ae05
commit
68ba8875a5
@ -18,6 +18,7 @@ package pub.doric.devkit;
|
|||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
import pub.doric.resource.DoricAssetsLoader;
|
import pub.doric.resource.DoricAssetsLoader;
|
||||||
import pub.doric.resource.DoricAssetsResource;
|
import pub.doric.resource.DoricAssetsResource;
|
||||||
|
import pub.doric.resource.DoricRemoteResource;
|
||||||
import pub.doric.resource.DoricResource;
|
import pub.doric.resource.DoricResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,7 +31,11 @@ public class DoricDevAssetsLoader extends DoricAssetsLoader {
|
|||||||
@Override
|
@Override
|
||||||
public DoricResource load(DoricContext doricContext, String identifier) {
|
public DoricResource load(DoricContext doricContext, String identifier) {
|
||||||
if (DoricDev.getInstance().isInDevMode()) {
|
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);
|
return new DoricAssetsResource(doricContext, "assets/" + identifier);
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,16 @@
|
|||||||
|
|
||||||
#import "DoricDevAssetsLoader.h"
|
#import "DoricDevAssetsLoader.h"
|
||||||
#import "DoricDev.h"
|
#import "DoricDev.h"
|
||||||
|
#import <DoricCore/DoricRemoteResource.h>
|
||||||
|
|
||||||
@implementation DoricDevAssetsLoader
|
@implementation DoricDevAssetsLoader
|
||||||
|
|
||||||
- (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context {
|
- (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context {
|
||||||
if (DoricDev.instance.isInDevMode) {
|
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];
|
return [super load:identifier withContext:context];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user