From 0e57ce383819863920b5209cc969dbb363c7f150 Mon Sep 17 00:00:00 2001 From: nextfu Date: Fri, 10 Apr 2020 20:45:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=BA=E5=9D=9B=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 ++ libs/js/cc-console-utils.js | 51 +++++++++++++++++++++++++++++++++++++ preview.js | 6 +++++ 3 files changed, 59 insertions(+) diff --git a/index.html b/index.html index f78e0cf..6cb90fd 100644 --- a/index.html +++ b/index.html @@ -45,6 +45,8 @@
Recompile
+ mdi-cloud-search + mdi-forum mdi-home diff --git a/libs/js/cc-console-utils.js b/libs/js/cc-console-utils.js index 8f1c064..64458f2 100644 --- a/libs/js/cc-console-utils.js +++ b/libs/js/cc-console-utils.js @@ -115,4 +115,55 @@ const initConsoleUtil = function () { }, 2000); return target; } + cc.total = function () { + let rawCacheData = cc.loader._cache; + let cacheData = []; + let totalTextureSize = 0; + for (let k in rawCacheData) { + let item = rawCacheData[k]; + // console.log(item) + if (item.type !== 'js' && item.type !== 'json') { + let itemName = '_'; + let preview = ''; + let content = item.content.__classname__ ? item.content.__classname__ : item.type; + let formatSize = -1; + if (item.type === 'png' || item.type === 'jpg') { + let texture = rawCacheData[k.replace('.' + item.type, '.json')]; + if (texture && texture._owner && texture._owner._name) { + itemName = texture._owner._name; + preview = texture.content.url; + } + } else { + if (item.content.name && item.content.name.length > 0) { + itemName = item.content.name; + } else if (item._owner) { + itemName = item._owner.name || '_'; + } + if (content === 'cc.Texture2D') { + let texture = item.content; + preview = texture.url; + let textureSize = texture.width * texture.height * ((texture._native === '.jpg' ? 3 : 4) / 1024 / 1024); + totalTextureSize += textureSize; + // sizeStr = textureSize.toFixed(3) + 'M'; + formatSize = Math.round(textureSize * 1000) / 1000; + } else if (content === 'cc.SpriteFrame') { + preview = item.content._texture.url; + } + } + cacheData.push({ + // queueId: item.queueId, + type: item.type, + name: itemName, + // preview: preview, + id: item.id, + content: content, + size: formatSize + }); + } + } + // let cacheTitle = `缓存 [文件总数:${cacheData.length}][纹理缓存:${totalTextureSize.toFixed(2) + 'M'}]`; + // console.log(cacheTitle); + // console.table(cacheData); + return totalTextureSize.toFixed(2) + 'M'; + } } \ No newline at end of file diff --git a/preview.js b/preview.js index f678d7f..42a9a7a 100644 --- a/preview.js +++ b/preview.js @@ -119,6 +119,12 @@ const app = new Vue({ openGithub() { window.open('https://github.com/potato47/ccc-devtools'); }, + openCocosForum() { + window.open('https://forum.cocos.com/'); + }, + openCocosDocs() { + window.open('https://docs.cocos.com/'); + } } });