Skip to content

Commit

Permalink
添加论坛跳转链接
Browse files Browse the repository at this point in the history
  • Loading branch information
nextfu committed Apr 10, 2020
1 parent 34a2437 commit 0e57ce3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<div class="item">
<v-btn id="btn-recompile" small height="25"><span style="color: #aaa;">Recompile</span></v-btn>
</div>
<v-icon @click="openCocosDocs" small>mdi-cloud-search</v-icon>
<v-icon @click="openCocosForum" small>mdi-forum</v-icon>
<v-icon @click="openGithub" small>mdi-home</v-icon>
</div>
</v-app-bar>
Expand Down
51 changes: 51 additions & 0 deletions libs/js/cc-console-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
6 changes: 6 additions & 0 deletions preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/');
}
}
});

Expand Down

0 comments on commit 0e57ce3

Please sign in to comment.