如题,creator自带的导入资源插件的源码可以在哪里看到呢?我想看看具体实现
通过调试主进程 Creator编辑器简单分析-如何调试插件的主进程代码 ,看到了大多数插件的代码,但是这个导入导出资源插件的代码没看到:
用打断点跟下去的方式找到了一部分代码,但是远远不够:
如题,creator自带的导入资源插件的源码可以在哪里看到呢?我想看看具体实现
通过调试主进程 Creator编辑器简单分析-如何调试插件的主进程代码 ,看到了大多数插件的代码,但是这个导入导出资源插件的代码没看到:
用打断点跟下去的方式找到了一部分代码,但是远远不够:
/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/builtin/package-asset/panel/import/index.js 的内容:
var e = require("fire-fs")
, t = (require("fire-path"),
Editor.require("packages://package-asset/utils.js"))
, r = Editor.require("packages://package-asset/parse/import.js");
Editor.require("packages://package-asset/lib/jszip-utils.min.js"),
Editor.require("packages://package-asset/lib/jszip.min.js");
const i = Editor.require("packages://package-asset/panel/import/asset-item.js");
Vue.component("package-import-asset-item", i),
Editor.Panel.extend({
style: e.readFileSync(Editor.url("packages://package-asset/panel/style.css")) + "",
template: e.readFileSync(Editor.url("packages://package-asset/panel/import/panel.html")) + "",
ready() {
t.init(this.profiles),
this._vm = new window.Vue({
el: this.shadowRoot,
created() {
this.metaList = [],
this.outPath = t.getDataByKey("out-path"),
this.folderPath = t.getDataByKey("import-folder-path"),
this._lastfolderPath = "",
this.noImportList = []
},
data: {
outPath: "",
folderPath: "",
filetree: [],
foldedAll: !0,
progress: 0,
progressState: Editor.T("IMPORT_ASSET.progress_state_wait")
},
watch: {
folderPath: {
handler(e) {
if (t.save("import-folder-path", e),
!e)
return this.filetree = null,
this.progressState = Editor.T("IMPORT_ASSET.progress_state_wait"),
void 0;
console.time(),
r.analyticalZip(e, (e,t)=>{
if (console.timeEnd(),
e)
return this.folderPath = this._lastfolderPath,
void 0;
this.filetree = t,
this.progressState = Editor.T("IMPORT_ASSET.progress_state_ready")
}
)
}
},
outPath: {
handler(e) {
t.save("out-path", e)
}
}
},
methods: {
T: Editor.T,
_isDisabled() {
return "" === this.folderPath || "" === this.outPath
},
_setFileTreeFolded(e, t) {
void 0 !== e.folded && (e.folded = t),
e.children && e.children.forEach(e=>{
"directory" === e.type && this._setFileTreeFolded(e, t)
}
)
},
_getFileTreeFolded(e, t) {
if (void 0 !== e.folded && !e.folded)
return t.foldedAll = !1,
void 0;
e.children && e.children.forEach(e=>{
"directory" === e.type && this._getFileTreeFolded(e, t)
}
)
},
_changedFileTreeFoldedState(e) {
if (void 0 === e)
return this.foldedAll = !0,
this._getFileTreeFolded(this.filetree, this),
void 0;
this._setFileTreeFolded(this.filetree, e),
this.foldedAll = e
},
onChooseImportFolder() {
t.showImportZipDialog((e,t)=>{
this._lastfolderPath = this.folderPath,
this.folderPath = t
}
)
},
onChooseOutFolder() {
t.showImportOutPathDialog((e,t)=>{
this.outPath = t
}
)
},
onClearAll() {
this.progress = 0,
this.folderPath = ""
},
onClearOutPath() {
this.outPath = ""
},
onImport() {
r.importZip(this.outPath, this.filetree, e=>{
this.progress = e.curProgress / e.total * 100,
this.progressState = e.outStrLog
}
)
}
}
})
}
});