(()=>{if("undefined"==typeof require)return;const e=require("https"),t=(require("http"),require("path"));require("zlib");drill.task(async(a,n)=>{let s=await a("common/app");n||(n=$(".setSlide")),n&&(async()=>{let a;try{a=await fetch("https://kirakiray.com/pageLuncher/update.json?v=a"+Math.random())}catch(e){return void(n.que(".update_con").text="请求失败，查看网络是否正常，或重新下载")}let r=await a.json(),i=r.versions[r.latest],o=parseInt(r.latest),l=parseInt(s.versionCode);if(o>l){$('.setSlide [data-totitle="update"]').class.add("bright"),$("o-frame").$btns.que("#setBtn").class.add(has_pop);let a=[],s=0,o=r.versions;Object.keys(o).forEach(e=>{if(parseInt(e)>l){let t=o[e];t.fixBug&&s++,t.main&&t.main.forEach(e=>a.push(e))}});let p=n.que(".update_con");p.html=`\n            <div class="update_con_title">可用更新 ${i.version}</div>\n            <ol></ol>\n            <p-button class="succeed update_btn">点击更新</p-button>\n            <br>\n            更新完成后 <span style="color:red;">应用会退出</span>，点击更新后等待重新打开应用后再工作\n            `;let u=p.que("ol");a.forEach(e=>{u.push(`<li>${e.text}；</li>`)}),s&&(s>8?u.push("<li>修复大量bug；</li>"):s>3?u.push("<li>修复很多bug；</li>"):u.push("<li>修复bug；</li>"));let c=p.que(".update_btn");c.one("click",a=>{const n=require("compressing"),s=require("pfs");c.class.remove("succeed"),e.get(i.url+"?v=a"+Math.random(),function(e){let a,r=parseInt(e.headers["content-length"]);e.on("data",e=>{a=a?Buffer.concat([a,e],a.length+e.length):e,c.text=`下载中 ${Math.round(a.length/r*100)}%`}),e.on("end",async e=>{console.log("下载结束",a),c.text="更新中";let r=process.resourcesPath;try{await s.writeFile(t.normalize(`${r}/app-dw.zip`),a),await n.zip.uncompress(t.normalize(`${r}/app-dw.zip`),t.normalize(`${r}`)),p.text="更新成功，请重新启动应用",setTimeout(()=>{require("electron").remote.app.quit()},1e3),await s.unlink(t.normalize(`${r}/app-dw.zip`))}catch(e){p.html='<span style="color:red;">更新失败，请重新下载</span>'}})})}),console.log(a,s,r)}else n.que(".update_con").text="没有更新"})()})})();