Files
DP/Server/Designer/assets/updater-legacy-a3f5551a.js

2 lines
16 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
!function(){function e(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e=function(){return t};var r,t={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{l({},"")}catch(r){l=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var o=r&&r.prototype instanceof w?r:w,a=Object.create(o.prototype),c=new C(n||[]);return i(a,"_invoke",{value:L(e,t,c)}),a}function h(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var p="suspendedStart",d="suspendedYield",v="executing",y="completed",g={};function w(){}function m(){}function x(){}var b={};l(b,c,(function(){return this}));var E=Object.getPrototypeOf,k=E&&E(E(N([])));k&&k!==n&&o.call(k,c)&&(b=k);var S=x.prototype=w.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(r){l(e,r,(function(e){return this._invoke(r,e)}))}))}function P(e,r){function t(n,i,a,c){var u=h(e[n],e,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&o.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,a,c)}),(function(e){t("throw",e,a,c)})):r.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return t("throw",e,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(e,o){function i(){return new r((function(r,n){t(e,o,r,n)}))}return n=n?n.then(i,i):i()}})}function L(e,t,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=j(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=h(e,t,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function j(e,t){var n=t.method,o=e.iterator[n];if(o===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=r,j(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,g;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=r),t.delegate=null,g):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g)}function D(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function O(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function N(e){if(e||""===e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(o.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=r,t.done=!0,t};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return m.prototype=x,i(S,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:m,configurable:!0}),m.displayName=l(x,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===m||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,l(e,s,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},_(P.prototype),l(P.prototype,u,(function(){return this})),t.AsyncIterator=P,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new P(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(S),l(S,s,"Generator"),l(S,c,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=N,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&o.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=r)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,o){return c.type="throw",c.arg=e,t.next=n,o&&(t.method="next",t.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),g},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),O(t),g}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;O(t)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:N(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=r),g}},t}function r(e,r,t,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void t(e)}c.done?r(u):Promise.resolve(u).then(n,o)}function t(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function c(e){r(a,o,i,c,u,"next",e)}function u(e){r(a,o,i,c,u,"throw",e)}c(void 0)}))}}function n(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function o(e,r,t){return(r=i(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(e){var r=function(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:r+""}System.register(["./index-legacy-fd2a7686.js"],(function(r,i){"use strict";var a,c,u,s,l;return{setters:[function(e){a=e.C,c=e.l,u=e._,s=e.a,l=e.c}],execute:function(){function f(){return"undefined"!=typeof cep_node&&(void 0!==cep_node.require&&void 0!==cep_node.process)}var h=f()?cep_node.require("fs"):{};console.error("isNodeJSEnabled()"+f());var p=f()?cep_node.require("path"):{},d=function(){return r=function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"cacheDir",""),o(this,"csInterface",null);try{var t;this.csInterface=new a;var n=this.csInterface.getSystemPath(null===(t=window.SystemPath)||void 0===t?void 0:t.USER_DATA)||"";n&&f()&&(this.cacheDir=p.join(n,"DesignerCache"),h.existsSync(this.cacheDir)||h.mkdirSync(this.cacheDir,{recursive:!0}))}catch(r){c.warn("Running in browser mode, CEP features disabled:",r),this.cacheDir=""}},d=[{key:"login",value:(b=t(e().mark((function r(t,n){var o,a,f,h,p,d;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,u((function(){return i.import("./index-legacy-fd2a7686.js").then((function(e){return e.d}))}),void 0,i.meta.url);case 3:return o=e.sent,a=o.getDeviceId,f=a(),c.log("🔐 [登录] device_id:",f),e.next=9,s.post(`${l.apiBaseUrl}/client/login`,{username:t,password:n,device_id:f});case 9:if(200!==(h=e.sent).data.code){e.next=14;break}return e.abrupt("return",h.data.data);case 14:throw new Error(h.data.message||"登录失败");case 15:e.next=30;break;case 17:if(e.prev=17,e.t0=e.catch(0),"ERR_NETWORK"!==e.t0.code&&"ECONNREFUSED"!==e.t0.code&&"Network Error"!==e.t0.message){e.next=22;break}throw c.error("❌ [登录] 无法连接到服务器"),new Error("无法连接到服务器,请检查:\n1. 服务器是否已启动\n2. 网络连接是否正常\n3. 服务器地址是否正确");case 22:if(401!==(null===(p=e.t0.response)||void 0===p?void 0:p.status)){e.next=25;break}throw c.error("❌ [登录] 认证失败"),new Error("用户名或密码错误");case 25:if(null===(d=e.t0.response)||void 0===d||null===(d=d.data)||void 0===d||!d.detail){e.next=28;break}throw c.error("❌ [登录] 业务错误:",e.t0.response.data.detail),new Error(e.t0.response.data.detail);case 28:throw c.error("❌ [登录] 未知错误:",e.t0),new Error(e.t0.message||"登录失败,请稍后重试");case 30:case"end":return e.stop()}}),r,null,[[0,17]])}))),function(e,r){return b.apply(this,arguments)})},{key:"checkUpdate",value:(x=t(e().mark((function r(t){var n,o,i,a;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,s.post(`${l.apiBaseUrl}/client/check_update`,{username:t});case 3:if(200!==(n=e.sent).data.code){e.next=8;break}return e.abrupt("return",n.data.data);case 8:throw new Error(n.data.message);case 9:e.next=27;break;case 11:if(e.prev=11,e.t0=e.catch(0),"ERR_NETWORK"!==e.t0.code&&"ECONNREFUSED"!==e.t0.code&&"Network Error"!==e.t0.message){e.next=16;break}throw c.error("❌ [检查更新] 无法连接到服务器"),new Error("无法连接到服务器,请检查:\n1. 服务器是否已启动\n2. 网络连接是否正常\n3. 服务器地址是否正确");case 16:if(401!==(null===(o=e.t0.response)||void 0===o?void 0:o.status)){e.next=19;break}throw c.error("❌ [检查更新] 认证失败"),new Error("登录已失效,请重新登录");case 19:if(404!==(null===(i=e.t0.response)||void 0===i?void 0:i.status)){e.next=22;break}throw c.error("❌ [检查更新] 用户不存在"),new Error("用户不存在");case 22:if(null===(a=e.t0.response)||void 0===a||null===(a=a.data)||void 0===a||!a.detail){e.next=25;break}throw c.error("❌ [检查更新] 业务错误:",e.t0.response.data.detail),new Error(e.t0.response.data.detail);case 25:throw c.error("❌ [检查更新] 未知错误:",e.t0),new Error(e.t0.message||"检查更新失败,请稍后重试");case 27:case"end":return e.stop()}}),r,null,[[0,11]])}))),function(e){return x.apply(this,arguments)})},{key:"download",value:(m=t(e().mark((function r(t,n){var o,i,a,c,u;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f()){e.next=2;break}throw new Error("下载功能需要在 CEP 环境中运行");case 2:return o=l.getDownloadUrl(t),i=p.basename(o),a=p.join(this.cacheDir,i),e.next=7,s({url:o,method:"GET",responseType:"arraybuffer",onDownloadProgress:function(e){var r=e.total||0,t=e.loaded;r>0&&n(Math.round(t/r*100))}});case 7:return c=e.sent,u=cep_node.require("buffer").Buffer,h.writeFileSync(a,u.from(c.data)),e.abrupt("return",a);case 11:case"end":return e.stop()}}),r,this)}))),function(e,r){return m.apply(this,arguments)})},{key:"unzip",value:(w=t(e().mark((function t(n,o){var i,a,u,s,l,d;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f()){e.next=2;break}throw new Error("解压功能需要在 CEP 环境中运行");case 2:if(c.log("📦 [解压] 开始解压..."),c.log(" - ZIP 文件:",n),c.log(" - 版本:",o),i=p.join(this.cacheDir,o),c.log(" - 目标目录:",i),h.existsSync(i)){c.log(" ⚠️ 目标目录已存在,删除旧文件...");try{h.rmSync(i,{recursive:!0,force:!0}),c.log(" ✓ 旧文件已删除")}catch(r){c.error(" ❌ 删除失败:",r.message)}}return h.mkdirSync(i,{recursive:!0}),c.log(" ✓ 目标目录已创建"),c.log(" ⏳ 正在解压 ZIP 文件(使用 PowerShell..."),c.log(" ⚠️ 此过程可能需要 5-15 秒,请耐心等待..."),a=Date.now(),u=cep_node.require("child_process"),s=n.replace(/'/g,"''"),l=i.replace(/'/g,"''"),d=`powershell -NoProfile -ExecutionPolicy Bypass -Command "Write-Host 'Starting extraction...'; Expand-Archive -Path '${s}' -DestinationPath '${l}' -Force; Write-Host 'Extraction completed'"`,c.log(" 📝 执行命令:",d.substring(0,100)+"..."),e.abrupt("return",new Promise((function(e,r){var t=setTimeout((function(){c.error(" ❌ 解压超时60秒"),r(new Error("解压超时,请检查文件大小或手动删除缓存目录重试"))}),6e4);u.exec(d,{maxBuffer:10485760},(function(n,o,u){clearTimeout(t);var s=((Date.now()-a)/1e3).toFixed(2);if(c.log(` ⏱️ PowerShell 执行耗时: ${s}`),o&&c.log(" 📤 PowerShell 输出:",o),n)return c.error(" ❌ PowerShell 错误:",u||n.message),void r(new Error(`解压失败: ${u||n.message}`));var l=p.join(i,"index.html");if(!h.existsSync(l))return c.error(" ❌ 验证失败: 未找到 index.html"),c.log(" 📁 目录内容:",h.readdirSync(i)),void r(new Error("解压后未找到 index.html文件可能损坏"));c.log(" ✅ 解压完成并验证通过!"),e(i)}))})));case 19:case"end":return e.stop()}}),t,this)}))),function(e,r){return w.apply(this,arguments)})},{key:"checkVersionCache",value:(g=t(e().mark((function r(t){var n,o,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f()){e.next=2;break}return e.abrupt("return",!1);case 2:return n=p.join(this.cacheDir,t),o=p.join(n,"index.html"),i=h.existsSync(o),c.log(`[Updater] 检查版本缓存: ${t} -> ${i?"存在":"不存在"}`),e.abrupt("return",i);case 7:case"end":return e.stop()}}),r,this)}))),function(e){return g.apply(this,arguments)})},{key:"launch",value:(y=t(e().mark((function r(t){var n,o,a,s,d,v,y,g,w;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f()){e.next=2;break}throw new Error("启动功能需要在 CEP 环境中运行");case 2:if(c.separator(),c.log("🚀 [启动 Core] 开始启动 Core 应用"),c.log(" - 版本:",t),c.log(" - 缓存目录:",this.cacheDir),n=p.join(this.cacheDir,t),o=p.join(n,"index.html"),c.log(" - 版本目录:",n),c.log(" - 入口文件:",o),c.log(" - 文件存在:",h.existsSync(o)),h.existsSync(o)){e.next=14;break}throw c.error("❌ [启动 Core] 入口文件不存在!"),new Error(`入口文件未找到: ${o}`);case 14:return a=localStorage.getItem("token"),s=localStorage.getItem("username"),e.next=18,u((function(){return i.import("./index-legacy-fd2a7686.js").then((function(e){return e.d}))}),void 0,i.meta.url);case 18:d=e.sent,v=d.getDeviceId,y=v(),c.log("🔐 [启动 Core] 读取登录信息:"),c.log(" - token:",a?"存在":"不存在"),c.log(" - username:",s),c.log(" - device_id:",y),g=l.getCoreUrl(t),a&&s?(w=new URLSearchParams({token:a,username:s,device_id:y,auto_login:"true"}),g+="#/home?"+w.toString(),c.log("✅ [启动 Core] 将通过 URL 参数传递登录信息(含 device_id")):(c.warn("⚠️ [启动 Core] 没有登录信息Core 需要重新登录"),g+="#/login"),c.log(" - 目标 URL:",g),c.log("✅ [启动 Core] 准备跳转到后端服务器..."),c.separator(),window.location.href=g;case 31:case"end":return e.stop()}}),r,this)}))),function(e){return y.apply(this,arguments)})}],d&&n(r.prototype,d),v&&n(r,v),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,d,v,y,g,w,m,x,b}();r("Updater",d)}}}))}();