From aca13966084df5d6a1ff60fd9d92fa2a55ba68af Mon Sep 17 00:00:00 2001 From: Santy-Wang Date: Fri, 12 Jul 2019 17:55:02 +0800 Subject: [PATCH] fix wechat loading issue (#4874) * fix wechat loading issue * refine --- cocos/load-pipeline/downloader.js | 20 ++------------------ cocos/load-pipeline/uuid-loader.js | 6 ++++++ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/cocos/load-pipeline/downloader.js b/cocos/load-pipeline/downloader.js index f45e207a3a..92124ec052 100644 --- a/cocos/load-pipeline/downloader.js +++ b/cocos/load-pipeline/downloader.js @@ -34,7 +34,7 @@ import * as PackDownloader from './pack-downloader'; import downloadBinary from './binary-downloader'; import downloadText from './text-downloader'; import downloadAudio from './audio-downloader'; -import {urlAppendTimestamp, decompressJson} from './utils'; +import {urlAppendTimestamp} from './utils'; function skip () { return null; @@ -118,23 +118,7 @@ function downloadImage (item, callback, isCrossOrigin, img) { function downloadUuid (item, callback) { var result = PackDownloader.load(item, callback); if (result === undefined) { - return this.extMap['json'](item, function (err, text) { - var out = null; - if (!err) { - try { - out = JSON.parse(text); - if (!CC_DEBUG && out.keys && out.data) { - var keys = out.keys; - out = out.data; - decompressJson(out, keys); - } - } - catch (e) { - err = new Error(debug.getError(4923, item.id, e.stack)); - } - } - callback(err, out); - }); + return this.extMap['json'](item, callback); } return result || undefined; } diff --git a/cocos/load-pipeline/uuid-loader.js b/cocos/load-pipeline/uuid-loader.js index b1dcb3ff80..8d6b16d6b6 100644 --- a/cocos/load-pipeline/uuid-loader.js +++ b/cocos/load-pipeline/uuid-loader.js @@ -33,6 +33,7 @@ import {_getClassById} from '../core/utils/js'; import * as debug from '../core/platform/CCDebug'; import deserialize from '../core/data/deserialize'; import LoadingItems from './loading-items'; +import {decompressJson} from './utils'; export function isSceneObj (json) { var SCENE_ID = 'cc.Scene'; @@ -221,6 +222,11 @@ export function loadUuid (item, callback) { if (typeof item.content === 'string') { try { json = JSON.parse(item.content); + if (!CC_DEBUG && json.keys && json.data) { + var keys = json.keys; + json = json.data; + decompressJson(json, keys); + } } catch (e) { return new Error(debug.getError(4923, item.id, e.stack));