drill.init(async e=>{let{remote:t}=require("electron"),{app:a}=t.require("electron");const r=require("https"),s=(require("http"),require("path")),o=require("compressing"),p=require("pfs");let[i,c]=await e("common/data","util/getVersionCode"),n=a.getVersion();$("#appVersion").text=n,$("#launcherVersion").text=i.appDatas.c_launcher.version,$("#pageCreatorVersion").text=i.appDatas.pageCreator.version,$("#e_version").html=`E - ${process.versions.electron}`;let l=await fetch("https://kirakiray.com/creator/update.json");l=await l.json();let u=0,h=[["appUpdateList","main",c(n)],["launcherUpdataList","c_launcher",c(i.appDatas.c_launcher.version)],["pageCreatorUpdateList","pageCreator",c(i.appDatas.pageCreator.version)]];if(h.forEach(e=>{let[t,a,r]=e,s=l[a].filter(e=>{let t=c(e.v);if(t>r)return e.appv=t,!0});if(s.length){u=1,s=s.sort((e,t)=>t.appv-e.appv),e.push(s[0]);let a=$("#"+t),r=a.que("ol");r.empty(),s.forEach(e=>{e.article.forEach(e=>{r.push(`<li>${e.text}</li>`)})}),a.display="",a.que(".update_tips").text=s[0].v}}),u){$("o-frame").$btns.que("#setBtn").class.add("has_pop");let e=$("#updateBtn");e.class.add("succeed"),e.text="更新",e.one("click",t=>{$("o-frame").$btns.class.add("unuse");let a=0,c=0,n=0;e.text="更新中",e.class.remove("succeed"),h.forEach(t=>{if(t.length>3){a++;let l=t.slice(-1)[0],u=$(`#${t[0]} .precentage_text`);r.get(`https://kirakiray.com/creator/${t[1]}/${l.v}.zip`,r=>{let l,h=parseInt(r.headers["content-length"]);r.on("data",e=>{l=l?Buffer.concat([l,e],l.length+e.length):e,u.text=`下载中 ${Math.round(l.length/h*100)}%`}),r.on("end",async r=>{console.log("下载结束",l),u.text="更新中";let h=s.normalize(`${i.appDir}/${t[1]}-dw.zip`),m=s.normalize(`${i.appDir}/${t[1]}_backup`),$=s.normalize(`${i.appDir}/${t[1]}`),d=s.normalize(`${i.appDir}`),g=0;try{switch(t[1]){case"main":h=s.normalize(`${process.resourcesPath}/app-dw.zip`),m=s.normalize(`${process.resourcesPath}/app_backup`),$=s.normalize(`${process.resourcesPath}/app`),d=s.normalize(process.resourcesPath),c=1;break;case"c_launcher":n=1}await p.writeFile(h,l),g=1,p.rename($,m),g=2,await o.zip.uncompress(h,d),u.text="更新成功",g=3,p.remove(m),p.remove(h),a--}catch(r){switch(console.error(r),g){case 3:break;case 2:p.rename(m,$);case 1:p.remove(h);case 0:u.text=`更新失败，请重新下载；错误状态 => ${g}`}}a||(setTimeout(()=>{let{app:e}=require("electron").remote;e.relaunch(),e.exit()},3e3),e.style.width="120px",setTimeout(()=>{e.text="更新成功，正在重启"},300),e.class.add("warn"))})})}})})}console.log(l)});