main.js 1.2 KB

12345678910111213141516171819202122
  1. const Fs=require("fire-fs"),Path=require("fire-path");
  2. module.exports={
  3. load(){},
  4. unload(){},
  5. messages:{
  6. showPanel(){
  7. Editor.Panel.open("hot-update-tools")
  8. },
  9. "editor:build-finished":(o,t)=>{
  10. if(Editor.log("[HotUpdateTools] build platform:"+t.platform),"win32"===t.platform||"android"===t.platform||"ios"===t.platform||"mac"===t.platform){
  11. let o=Editor.url("packages://hot-update-tools/main_code.js");
  12. if(Fs.existsSync(o)){
  13. const e=Fs.readFileSync(o,"utf-8");
  14. let a=Path.normalize(t.dest),i=Path.join(a,"main.js"),l=e+Fs.readFileSync(i,"utf8");
  15. Fs.writeFileSync(i,l),Editor.log("[HotUpdateTools] SearchPath updated in built main.js for hot update");
  16. let d=(new Date).getTime();
  17. Editor.Ipc.sendToPanel("hot-update-tools","hot-update-tools:onBuildFinished",d),Editor.require("packages://hot-update-tools/core/CfgUtil.js").updateBuildTimeByMain(d)
  18. }else Editor.log(`文件丢失: ${o}`)
  19. }else Editor.log(`[HotUpdateTools] don't need update main.js, platform: ${t.platform}`)
  20. }
  21. }
  22. };