Skip to content

iOS PackageManager

zhangyanqiang edited this page Apr 26, 2018 · 1 revision

PackageManager

在iqiyi项目中,通过 QIYIConstitute 类实现了包文件的本地管理,需要用到该程序的用户,只需将相应的实现改为本公司的包文件管理即可,通过 QIYIAssets 的接口将所存储的本地文件传给到小程序的核心框架中,就能完成相关的加载。

-(NSString *) obtainHtmlPath {
  return [self getRootBasePath:@"/template.html"];
}

-(NSData *) obtainBaseScript {
    NSData *qyJS = [self.local readFromFile:
    [self getRootBasePath: @"/core/qy.thread.js"]];
    
    NSData *componentJS = [self.local readFromFile:
    [self getRootBasePath:@"/component/component.thread.js"]];

    NSMutableData * result = [NSMutableData dataWithData:qyJS];
    [result appendData:componentJS];
     return result;
}

-(NSData*) obtainBundleScript:(NSString*)path {
   return [self.local readFromFile:[self getRootBusinessPath:
   [path stringByAppendingString:@"bundle.js"]]];
}

-(NSString*) obtainBundleCss:(NSString*)path {
    return [self getRootBusinessPath:
    [path stringByAppendingString:@"bundle.css"]];
}

-(NSData *) obtainManifest {
    return [self.local readFromFile:
          [self getRootBusinessPath:@"/conf/manifest.json"]];

}

-(NSData*) obtainFile:(NSString*)file {
    NSString *busPath = [self getRootBusinessPath:file];
    NSData *data = [self.local readFromFile:busPath];
    if (data == nil) {
        NSString *basePath = [self getRootBasePath:file];
        data = [self.local readFromFile:basePath];
    }
    return data;
}