!function(){var e,n,o,i,r="",t={log:function(e){r&&(r+="<br>");r+=e;document.body.innerHTML=r},updateLog:function(e){r&&(r+="<br>");r=e;document.body.innerHTML=r}},s=require("qyutil"),c=require("nw.gui"),p=c.Window.get(),l=require("path"),u=require("child_process"),a=require("fs"),d=require("../latest.json"),f=require("node-webkit-updater"),w=new f(d);"win32"==process.platform?i="taskkill /f /im qynwnode.exe":"linux"==process.platform?i="pkill qynwnode":"darwin"==process.platform&&(i="pkill qynwnode");p.on("close",function(){a.existsSync(l.join(process.cwd(),"log/nwpid.txt"))&&a.unlinkSync(l.join(process.cwd(),"log/nwpid.txt"));u.exec(i);p.close(!0)});var g=l.join(process.cwd(),"log/DevTools");s.ensureDir(g);a.watch(g,function(e,n){if("open.txt"==n){p.showDevTools();a.unlink(l.join(g,"/open.txt"))}});if(c.App.argv.length>0){e=c.App.argv[0];n=c.App.argv[1];o=process.cwd();var q=s.readSrcLength(o),v=0;t.log("正在复制文件");s.copy(o,e,!0,function(){v++;if(v==q){w.runInstaller(n,[],{});c.App.quit()}})}else w.checkNewVersion(function(e,n,o){if(!e&&n){t.log("正在下载更新文件，请稍后");w.download(function(e,n){if(!e){t.log("文件下载完成，正在解压，稍后重启");w.unpack(n,function(e,n){if(!e){var o=process.cwd();if("darwin"==process.platform)var i=l.join(o,"/GameMei.app");else var i=l.join(o,"/GameMei.exe");w.runInstaller(n,[o,i],{});c.App.quit()}},o)}},o)}else qystart()})}();