!function(){var e=require("nw.gui"),a=require("os"),t=require("path"),o=require("child_process"),n=e.Window.get();n.setAlwaysOnTop(!0);var l=localStorage.getItem("downloadpath"),i=localStorage.getItem("uploadpath"),r=t.join(t.join(a.homedir(),"Desktop"),"享像派同步目录"),s=l||r,h=i||r;const d=axios.create();d.interceptors.request.use(e=>(e.headers.x_platform="PC_HELPER",e));var w=new Vue({el:"#root",data:{page:1,downloadpath:s,uploadpath:h,hasNewVersion:!1,versionName:"3.0.1",newVersionUrl:"",newVersionName:""},watch:{page:e=>{3===e&&w.checkVersion()}},methods:{checkVersion:()=>{var e="Darwin"==a.type?"PC_MAC":"PC_WIN";d.get("https://int.xxpie.com/api/ps/mine/getPCPluginVersion",{params:{platform:e,timestamp:(new Date).getTime()}}).then(e=>{200===e.status&&e.data.version_code>301?(w.newVersionUrl=e.data.version_url?e.data.version_url:"https://www.xxpie.com/downloads.html?page=downloadPCAssistant.html",w.newVersionName=e.data.version_name,w.hasNewVersion=!0,console.log("has new version "+w.newVersionName)):(w.hasNewVersion=!1,console.log("no new version"))}).catch(()=>{w.hasNewVersion=!1})},changeDownloadPath:e=>{e&&e.target&&e.target.files&&e.target.files.length>0&&(p=e.target.files[0].path,w.downloadpath=p)},cancelDownloadPath:()=>{w.downloadpath=s,n.close()},cancelUploadPath:()=>{w.uploadpath=h,n.close()},confirmDownloadPath:()=>{w.downloadpath!==s&&(localStorage.setItem("downloadpath",w.downloadpath),global.emitter.emit("changeDownloadPath",w.downloadpath),s=w.downloadpath),n.close()},changeUploadPath:e=>{p=e.target.files[0].path,e&&e.target&&e.target.files&&e.target.files.length>0&&(p=e.target.files[0].path,w.uploadpath=p)},confirmUploadPath:()=>{w.uploadpath!==h&&(localStorage.setItem("uploadpath",w.uploadpath),global.emitter.emit("changeUploadPath",w.uploadpath),h=w.uploadpath),n.close()},downloadNewVersion:()=>{w.newVersionUrl&&("Darwin"==a.type?o.exec('open "'+url+'"'):"Windows_NT"==a.type&&o.exec('explorer "'+url+'"'))},openPath:e=>{"Darwin"==a.type?o.exec('open "'+e+'"'):"Windows_NT"==a.type?o.exec('explorer.exe "'+e+'"'):alert("未识别的系统类型, 请联系客服人员获得帮助: 微信: xxpie_service; 系统类型: "+a.type)},showTip:(a,t)=>{var o=131;1===a?(global.tip={title:"下载目录",msg:"应用将自动在此文件夹下创建以相册和子相册名称命名的文件夹，无须自行创建。仅需设置一次，路径将自动保存。",showCancel:!1,confirmText:"好"},o=165):2===a?(global.tip={title:"上传目录",msg:"选择相册后，应用将在此文件夹下自动创建以相册和子相册名称命名的文件夹，将待上传照片拷贝至子相册文件夹下，即可开始上传。仅需设置一次，应用将自动保存。",showCancel:!1,confirmText:"好"},o=165):3===a&&(global.tip=t),e.Window.open("./tipwindow.html",{position:"center",width:420,height:o,min_width:420,min_height:o,max_width:420,max_height:o,id:"tip"})},openInBrowser:()=>{e.Shell.openExternal("https://www.xxpie.com/downloads.html?page=downloadPCAssistant.html")}}});w.checkVersion()}();