Commit ce32f4ac authored by rockyl's avatar rockyl

修复自定义模块链接的素材加载不到的问题

parent 0d95aa07
......@@ -40,7 +40,7 @@ export function checkAssetGroupLoaded(groupName) {
* @param onStart
* @param onFinish
*/
export async function loadAssetsGroups(groups, onStart?, onFinish?) {
export async function loadAssetsGroups(groups, onStart?, onFinish?) {
let total = 0;
let loaded = 0;
......@@ -61,7 +61,7 @@ export async function loadAssetsGroups(groups, onStart?, onFinish?) {
await loadAssetsGroup(depAssets, groupName, () => {
loaded++;
globalEvent.dispatchEvent('load-assets-process', {loaded, total})
}, ()=>{
}, () => {
globalEvent.dispatchEvent('load-assets-complete');
});
}
......@@ -113,27 +113,36 @@ export function loadAssets(config, onProgress?, onComplete?) {
return Promise.all(
config.map(assetConfig => {
assetsConfig.push(assetConfig);
const {url, ext, uuid} = assetConfig;
const loadFunc = loaderMapping[ext];
if (loadFunc) {
if (url.indexOf(linkScheme) === 0) {
loaded++;
onProgress && onProgress(loaded, total);
return Promise.resolve();
if (assetConfig.url.indexOf(linkScheme) === 0) {
let linkUUID = assetConfig.url.replace(linkScheme, '');
assetConfig = getAssetByUUID(linkUUID);
}
if (assetConfig) {
const {url, ext, uuid} = assetConfig;
const loadFunc = loaderMapping[ext];
if (loadFunc) {
let method = globalLoader['load' + loadFunc];
return method.call(globalLoader, url, uuid).then(
(data) => {
parse(assetConfig, data);
loaded++;
onProgress && onProgress(loaded, total);
},
(error) => {
failedList.push(url);
}
);
} else {
return p();
}
let method = globalLoader['load' + loadFunc];
return method.call(globalLoader, url, uuid).then(
(data) => {
parse(assetConfig, data);
loaded++;
onProgress && onProgress(loaded, total);
},
(error) => {
failedList.push(url);
}
);
} else {
return p();
}
function p() {
loaded++;
onProgress && onProgress(loaded, total);
return Promise.resolve();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment