Commit ce32f4ac authored by rockyl's avatar rockyl

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

parent 0d95aa07
...@@ -61,7 +61,7 @@ export async function loadAssetsGroups(groups, onStart?, onFinish?) { ...@@ -61,7 +61,7 @@ export async function loadAssetsGroups(groups, onStart?, onFinish?) {
await loadAssetsGroup(depAssets, groupName, () => { await loadAssetsGroup(depAssets, groupName, () => {
loaded++; loaded++;
globalEvent.dispatchEvent('load-assets-process', {loaded, total}) globalEvent.dispatchEvent('load-assets-process', {loaded, total})
}, ()=>{ }, () => {
globalEvent.dispatchEvent('load-assets-complete'); globalEvent.dispatchEvent('load-assets-complete');
}); });
} }
...@@ -113,14 +113,16 @@ export function loadAssets(config, onProgress?, onComplete?) { ...@@ -113,14 +113,16 @@ export function loadAssets(config, onProgress?, onComplete?) {
return Promise.all( return Promise.all(
config.map(assetConfig => { config.map(assetConfig => {
assetsConfig.push(assetConfig); assetsConfig.push(assetConfig);
if (assetConfig.url.indexOf(linkScheme) === 0) {
let linkUUID = assetConfig.url.replace(linkScheme, '');
assetConfig = getAssetByUUID(linkUUID);
}
if (assetConfig) {
const {url, ext, uuid} = assetConfig; const {url, ext, uuid} = assetConfig;
const loadFunc = loaderMapping[ext]; const loadFunc = loaderMapping[ext];
if (loadFunc) { if (loadFunc) {
if (url.indexOf(linkScheme) === 0) {
loaded++;
onProgress && onProgress(loaded, total);
return Promise.resolve();
}
let method = globalLoader['load' + loadFunc]; let method = globalLoader['load' + loadFunc];
return method.call(globalLoader, url, uuid).then( return method.call(globalLoader, url, uuid).then(
(data) => { (data) => {
...@@ -134,6 +136,13 @@ export function loadAssets(config, onProgress?, onComplete?) { ...@@ -134,6 +136,13 @@ export function loadAssets(config, onProgress?, onComplete?) {
} }
); );
} else { } else {
return p();
}
} else {
return p();
}
function p() {
loaded++; loaded++;
onProgress && onProgress(loaded, total); onProgress && onProgress(loaded, total);
return Promise.resolve(); 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