dootask/public/js/build/system-update.efe0fc0e.js
2026-10-10 09:50:29 +00:00

2 lines
15 KiB
JavaScript
Vendored

import l from"./preview.536e528c.js";import{n as c}from"./app.d80882e4.js";import"./openpgp_hi.15f91b1d.js";import"./index.40a8e116.js";import"./jquery.ead8aad7.js";import"./@babel.9410f858.js";import"./dayjs.2db954dd.js";import"./localforage.44d37169.js";import"./markdown-it.0450edb4.js";import"./mdurl.ce6c1dd8.js";import"./uc.micro.8d343c98.js";import"./entities.48a44fec.js";import"./linkify-it.c5e8196e.js";import"./punycode.js.4b3f125a.js";import"./highlight.js.cbbfb885.js";import"./markdown-it-link-attributes.e1d5d151.js";import"./@traptitech.acea8861.js";import"./vue.adba9046.js";import"./vuex.cc7cb26e.js";import"./axios.37c7f908.js";import"./mitt.1ea0a2a3.js";import"./quill-hi.ca2ea0cc.js";import"./parchment.d5c5924e.js";import"./quill-delta.385a10bf.js";import"./fast-diff.f17881f3.js";import"./lodash.clonedeep.3cc09a31.js";import"./lodash.isequal.dbdc2157.js";import"./eventemitter3.78b735ad.js";import"./lodash-es.76e3a28b.js";import"./quill-mention-hi.4eeb5a2d.js";import"./view-design-hi.24419422.js";import"./html-to-md.f297036e.js";import"./lodash.8fcd6fd4.js";import"./vue-router.2d566cd7.js";import"./vue-clipboard2.fd43a5bc.js";import"./clipboard.37b37361.js";import"./vuedraggable.f464b992.js";import"./sortablejs.3488b922.js";import"./vue-resize-observer.5af23a43.js";import"./element-sea.f8a64907.js";import"./deepmerge.cecf392e.js";import"./resize-observer-polyfill.5d591c5f.js";import"./throttle-debounce.7c3948b2.js";import"./babel-helper-vue-jsx-merge-props.5ed215c3.js";import"./normalize-wheel.2a034b9f.js";import"./async-validator.dca2b951.js";import"./babel-runtime.4773988a.js";import"./core-js.314b4a1d.js";var h=function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{staticClass:"setting-item submit"},[s("div",{staticClass:"system-update-box"},[t.taskMode?s("div",{class:["update-view",`is-${t.task.status||"running"}`]},[s("div",{staticClass:"view-head"},[s("div",{staticClass:"view-title"},[t._v(t._s(t.$L(t.taskTitle)))]),s("div",{staticClass:"view-desc"},[t.task.from_version&&t.task.to_version?s("span",[t._v("v"+t._s(t.task.from_version)+" \u2192 v"+t._s(t.task.to_version))]):t._e(),t.taskDuration?s("span",[t._v(t._s(t.$L("\u7528\u65F6 (*)",t.taskDuration)))]):t._e()])]),s("ul",{staticClass:"task-steps"},t._l(t.stages,function(i){return s("li",{key:i.key,class:t.stageClass(i.key)},[s("div",{staticClass:"step-dot"},[t.stageClass(i.key)==="process"?s("Loading"):t.stageClass(i.key)==="finish"?s("Icon",{attrs:{type:"md-checkmark"}}):t.stageClass(i.key)==="error"?s("Icon",{attrs:{type:"md-close"}}):t._e()],1),s("span",{staticClass:"step-label"},[t._v(t._s(t.$L(i.label)))])])}),0),t.task.status==="running"&&t.pollFailed?s("div",{staticClass:"view-notice warning"},[t._v(t._s(t.$L("\u670D\u52A1\u91CD\u542F\u4E2D\uFF0C\u6B63\u5728\u7B49\u5F85\u6062\u590D...")))]):t.task.status==="success"?s("div",{staticClass:"view-notice success"},[t._v(" "+t._s(t.$L("\u7CFB\u7EDF\u5DF2\u66F4\u65B0\u5230 v(*)\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u4EE5\u4F7F\u7528\u65B0\u7248\u672C",t.task.to_version||t.task.current_version))+" ")]):t.task.status==="failed"?s("div",{staticClass:"view-notice error"},[t.task.error?s("div",{staticClass:"notice-title"},[t._v(t._s(t.task.error))]):t._e(),t.task.backup_file?s("div",[t._v(t._s(t.$L("\u66F4\u65B0\u524D\u7684\u6570\u636E\u5E93\u5907\u4EFD\uFF1A(*)",t.task.backup_file)))]):t._e(),s("div",[t._v(t._s(t.$L("\u8BF7\u6839\u636E\u65E5\u5FD7\u5728\u670D\u52A1\u5668\u4E0A\u5904\u7406\uFF0C\u5FC5\u8981\u65F6\u6267\u884C (*) \u56DE\u6EDA\u4EE3\u7801\u540E\u91CD\u65B0\u66F4\u65B0",t.rollbackCommand)))])]):t._e(),s("div",{staticClass:"view-panel"},[s("div",{staticClass:"panel-head"},[t._v(t._s(t.$L("\u66F4\u65B0\u65E5\u5FD7")))]),s("pre",{ref:"log",staticClass:"panel-body is-log"},[t._v(t._s(t.taskLog||t.$L("\u7B49\u5F85\u65E5\u5FD7\u8F93\u51FA...")))])])]):s("div",{class:["update-view",t.checkStatus]},[s("div",{staticClass:"view-head"},[s("div",{staticClass:"view-title"},[t._v(t._s(t.$L(t.checkTitle)))]),s("div",{staticClass:"view-desc"},[t.info&&t.info.has_update?s("span",[t._v("v"+t._s(t.currentVersion)+" \u2192 v"+t._s(t.info.latest_version))]):s("span",[t._v(t._s(t.$L("\u5F53\u524D\u7248\u672C"))+" v"+t._s(t.currentVersion))]),t.info&&t.info.checked_at?s("span",[t._v(t._s(t.$L("\u4E0A\u6B21\u68C0\u67E5\uFF1A(*)",t.checkedTime)))]):t._e()])]),t.lastFailed?s("div",{staticClass:"view-notice error"},[s("div",{staticClass:"notice-title"},[t._v(t._s(t.$L("\u4E0A\u6B21\u7CFB\u7EDF\u66F4\u65B0\u5931\u8D25")))]),s("div",[t.lastFailed.error?s("span",[t._v(t._s(t.lastFailed.error))]):t._e(),s("a",{attrs:{href:"javascript:void(0)"},on:{click:t.viewLastTask}},[t._v(t._s(t.$L("\u67E5\u770B\u65E5\u5FD7")))])])]):t._e(),t.info&&!t.info.supported?[s("div",{staticClass:"view-notice warning"},[s("div",{staticClass:"notice-title"},[t._v(t._s(t.$L(t.reasonText)))]),s("div",[t._v(t._s(t.$L(t.reasonHint,"./cmd update")))])])]:t.info&&t.info.has_update?[t.info.has_local_changes?s("div",{staticClass:"view-notice error"},[s("div",{staticClass:"notice-title"},[t._v(t._s(t.$L("\u670D\u52A1\u5668\u5B58\u5728\u672C\u5730\u4FEE\u6539\uFF0C\u65E0\u6CD5\u5728\u7EBF\u66F4\u65B0")))]),s("div",[t._v(t._s(t.$L("\u8BF7\u5728\u670D\u52A1\u5668\u4E0A\u5904\u7406\u672C\u5730\u4FEE\u6539\u540E\uFF0C\u6267\u884C (*) \u66F4\u65B0\u7CFB\u7EDF","./cmd update")))])]):s("div",{staticClass:"view-notice warning"},[s("div",[t._v(t._s(t.$L("\u66F4\u65B0\u671F\u95F4\u7CFB\u7EDF\u5C06\u6682\u505C\u670D\u52A1\uFF08\u901A\u5E38 1~3 \u5206\u949F\uFF09\uFF0C\u6240\u6709\u5728\u7EBF\u6210\u5458\u4F1A\u77ED\u6682\u65AD\u5F00\u8FDE\u63A5")))]),s("div",[t._v(t._s(t.$L(t.info.has_db_changes?"\u66F4\u65B0\u524D\u5C06\u81EA\u52A8\u5907\u4EFD\u6570\u636E\u5E93\uFF08\u672C\u6B21\u66F4\u65B0\u5305\u542B\u6570\u636E\u5E93\u53D8\u66F4\uFF09":"\u66F4\u65B0\u524D\u5C06\u81EA\u52A8\u5907\u4EFD\u6570\u636E\u5E93")))])]),s("div",{staticClass:"view-panel"},[s("div",{staticClass:"panel-head"},[t._v(t._s(t.$L("\u66F4\u65B0\u5185\u5BB9")))]),s("div",{staticClass:"panel-body is-markdown"},[t.info.changelog?s("VMPreview",{attrs:{value:t.info.changelog}}):s("div",{staticClass:"panel-empty"},[t._v(t._s(t.$L("\u6682\u65E0\u66F4\u65B0\u4ECB\u7ECD\uFF01")))])],1)])]:t._e()],2)]),t.taskMode&&t.task.status!=="running"?s("div",{staticClass:"setting-footer"},[t.task.status==="success"?s("Button",{attrs:{type:"primary"},on:{click:t.reloadPage}},[t._v(t._s(t.$L("\u5237\u65B0\u9875\u9762")))]):t._e(),s("Button",{on:{click:t.backToCheck}},[t._v(t._s(t.$L("\u8FD4\u56DE")))])],1):t.taskMode?t._e():s("div",{staticClass:"setting-footer"},[t.info&&t.info.has_update&&!t.info.has_local_changes?s("Button",{attrs:{type:"primary",disabled:t.checkIng},on:{click:function(i){t.confirmShow=!0}}},[t._v(t._s(t.$L("\u7ACB\u5373\u66F4\u65B0\u7CFB\u7EDF")))]):t._e(),s("Button",{attrs:{loading:t.checkIng},on:{click:function(i){return t.check(!0)}}},[t._v(t._s(t.$L("\u68C0\u67E5\u66F4\u65B0")))])],1),s("Modal",{attrs:{title:t.$L("\u66F4\u65B0\u7CFB\u7EDF"),"mask-closable":!1},on:{"on-visible-change":t.onConfirmVisible},model:{value:t.confirmShow,callback:function(i){t.confirmShow=i},expression:"confirmShow"}},[s("div",{staticClass:"system-update-confirm"},[s("p",[t._v(t._s(t.$L("\u66F4\u65B0\u671F\u95F4\u7CFB\u7EDF\u5C06\u6682\u505C\u670D\u52A1\uFF08\u901A\u5E38 1~3 \u5206\u949F\uFF09\uFF0C\u6240\u6709\u5728\u7EBF\u6210\u5458\u4F1A\u77ED\u6682\u65AD\u5F00\u8FDE\u63A5\u3002\u66F4\u65B0\u524D\u4F1A\u81EA\u52A8\u5907\u4EFD\u6570\u636E\u5E93\u3002\u786E\u5B9A\u7ACB\u5373\u66F4\u65B0\u5417\uFF1F")))]),s("Input",{ref:"password",attrs:{type:"password",password:"",placeholder:t.$L("\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801")},on:{"on-enter":t.start},model:{value:t.password,callback:function(i){t.password=i},expression:"password"}})],1),s("div",{staticClass:"adaption",attrs:{slot:"footer"},slot:"footer"},[s("Button",{attrs:{type:"default"},on:{click:function(i){t.confirmShow=!1}}},[t._v(t._s(t.$L("\u53D6\u6D88")))]),s("Button",{attrs:{type:"primary",loading:t.startIng},on:{click:t.start}},[t._v(t._s(t.$L("\u7ACB\u5373\u66F4\u65B0")))])],1)])],1)},d=[];const a=[{key:"preparing",label:"\u51C6\u5907\u66F4\u65B0"},{key:"fetching",label:"\u83B7\u53D6\u66F4\u65B0"},{key:"backup",label:"\u5907\u4EFD\u6570\u636E\u5E93"},{key:"pulling",label:"\u66F4\u65B0\u4EE3\u7801"},{key:"composer",label:"\u5B89\u88C5\u4F9D\u8D56"},{key:"migrating",label:"\u8FC1\u79FB\u6570\u636E\u5E93"},{key:"restarting",label:"\u91CD\u542F\u670D\u52A1"},{key:"verifying",label:"\u68C0\u67E5\u670D\u52A1"}],o={disabled:["\u5728\u7EBF\u66F4\u65B0\u5DF2\u5173\u95ED","\u5982\u9700\u5F00\u542F\uFF0C\u8BF7\u8054\u7CFB\u8FD0\u7EF4\u4EBA\u5458\u8C03\u6574\u670D\u52A1\u5668\u914D\u7F6E\uFF1B\u4E5F\u53EF\u5728\u670D\u52A1\u5668\u4E0A\u6267\u884C (*) \u66F4\u65B0\u7CFB\u7EDF"],not_installed:["\u7CFB\u7EDF\u5C1A\u672A\u5B8C\u6210\u5B89\u88C5","\u8BF7\u5728\u670D\u52A1\u5668\u4E0A\u6267\u884C (*) \u66F4\u65B0\u7CFB\u7EDF"],no_git:["\u5F53\u524D\u90E8\u7F72\u65B9\u5F0F\u4E0D\u652F\u6301\u5728\u7EBF\u66F4\u65B0","\u8BF7\u5728\u670D\u52A1\u5668\u4E0A\u6267\u884C (*) \u66F4\u65B0\u7CFB\u7EDF"],detached_head:["\u5F53\u524D\u4EE3\u7801\u4E0D\u5728\u4EFB\u4F55\u5206\u652F\u4E0A\uFF0C\u65E0\u6CD5\u5728\u7EBF\u66F4\u65B0","\u8BF7\u5728\u670D\u52A1\u5668\u4E0A\u6267\u884C (*) \u66F4\u65B0\u7CFB\u7EDF"],fetch_failed:["\u65E0\u6CD5\u8FDE\u63A5\u4EE3\u7801\u4ED3\u5E93\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u5668\u7F51\u7EDC\u6216\u4ED3\u5E93\u5730\u5740","\u4E5F\u53EF\u5728\u670D\u52A1\u5668\u4E0A\u6267\u884C (*) \u66F4\u65B0\u7CFB\u7EDF"],appstore_unavailable:["\u65E0\u6CD5\u8FDE\u63A5\u5E94\u7528\u5546\u5E97\u670D\u52A1","\u8BF7\u68C0\u67E5\u5E94\u7528\u5546\u5E97\u670D\u52A1\u662F\u5426\u6B63\u5E38\u8FD0\u884C\uFF0C\u6216\u5728\u670D\u52A1\u5668\u4E0A\u6267\u884C (*) \u66F4\u65B0\u7CFB\u7EDF"],appstore_outdated:["\u5E94\u7528\u5546\u5E97\u670D\u52A1\u7248\u672C\u8FC7\u4F4E\uFF0C\u6682\u4E0D\u652F\u6301\u5728\u7EBF\u66F4\u65B0","\u8BF7\u5148\u5728\u670D\u52A1\u5668\u4E0A\u6267\u884C\u4E00\u6B21 (*)\uFF0C\u4E4B\u540E\u5373\u53EF\u5728\u7EBF\u66F4\u65B0"]},p={components:{VMPreview:l},data(){return{stages:a,info:null,checkIng:!1,currentVersion:window.systemInfo.version,confirmShow:!1,password:"",startIng:!1,taskMode:!1,task:{},taskId:"",taskLog:"",taskOffset:0,lastFailed:null,pollTimer:null,pollFailed:!1,nowTime:Date.now(),clockTimer:null}},computed:{reasonText(){var t;return(o[(t=this.info)==null?void 0:t.reason]||["\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u5728\u7EBF\u66F4\u65B0"])[0]},reasonHint(){var t;return(o[(t=this.info)==null?void 0:t.reason]||[null,"\u8BF7\u5728\u670D\u52A1\u5668\u4E0A\u6267\u884C (*) \u66F4\u65B0\u7CFB\u7EDF"])[1]},checkedTime(){return $A.daytz(this.info.checked_at*1e3).format("YYYY-MM-DD HH:mm:ss")},checkTitle(){return this.info?this.info.supported?this.info.has_update?"\u53D1\u73B0\u7CFB\u7EDF\u65B0\u7248\u672C":"\u7CFB\u7EDF\u5DF2\u662F\u6700\u65B0\u7248\u672C":"\u6682\u4E0D\u652F\u6301\u5728\u7EBF\u66F4\u65B0":this.checkIng?"\u6B63\u5728\u68C0\u67E5\u66F4\u65B0...":"\u68C0\u67E5\u66F4\u65B0\u5931\u8D25"},checkStatus(){return this.info?this.info.supported?this.info.has_update?"is-update":"is-latest":"is-unsupported":"is-loading"},taskTitle(){switch(this.task.status){case"success":return"\u7CFB\u7EDF\u66F4\u65B0\u5B8C\u6210";case"failed":return"\u7CFB\u7EDF\u66F4\u65B0\u5931\u8D25";default:return"\u7CFB\u7EDF\u66F4\u65B0\u4E2D..."}},taskDuration(){const t=parseInt(this.task.started_at)||0;if(!t)return"";const e=parseInt(this.task.finished_at)||Math.floor(this.nowTime/1e3),s=Math.max(0,e-t);return`${String(Math.floor(s/60)).padStart(2,"0")}:${String(s%60).padStart(2,"0")}`},rollbackCommand(){return this.task.from_commit?`git reset --hard ${this.task.from_commit.substring(0,12)}`:"git reset --hard <commit>"}},mounted(){this.init()},beforeDestroy(){this.stopPoll(),clearInterval(this.clockTimer)},methods:{async init(){const t=await this.fetchStatus(0).catch(e=>null);if(t&&t.status==="running"){this.enterTask(t.id),this.applyStatus(t),this.startPoll();return}t&&t.status==="failed"&&(this.lastFailed=t),this.check(!1)},check(t){this.checkIng=!0,this.$store.dispatch("call",{url:"system/update/check",data:{force:t?1:0}}).then(({data:e})=>{this.info=e,this.currentVersion=e.current_version||this.currentVersion,this.$store.state.systemNewVersion=e.has_update?e.latest_version:null}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.checkIng=!1})},onConfirmVisible(t){t&&(this.password="",this.$nextTick(e=>{var s;return(s=this.$refs.password)==null?void 0:s.focus()}))},start(){var t;if(!this.password){$A.messageWarning("\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801");return}this.startIng=!0,this.$store.dispatch("call",{url:"system/update/start",method:"post",data:{password:this.password,version:((t=this.info)==null?void 0:t.latest_version)||""}}).then(({data:e})=>{this.confirmShow=!1,this.lastFailed=null,this.enterTask(e.id),this.task={status:"running",stage:"preparing",from_version:e.from_version,to_version:e.to_version,started_at:Math.floor(Date.now()/1e3)},this.startPoll()}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.startIng=!1})},enterTask(t){clearInterval(this.clockTimer),this.clockTimer=setInterval(e=>{this.nowTime=Date.now()},1e3),this.taskMode=!0,this.taskId=t||"",this.taskLog="",this.taskOffset=0,this.pollFailed=!1},fetchStatus(t){return this.$store.dispatch("call",{url:"system/update/status",data:{offset:t},checkNetwork:!1,networkFailureRetry:!1}).then(({data:e})=>e)},applyStatus(t){if(this.taskId&&t.id&&t.id!==this.taskId)return;const{log:e,offset:s,...i}=t;this.task=Object.assign({},this.task,i),e&&(this.taskLog+=e,this.$nextTick(_=>{const r=this.$refs.log;r&&(r.scrollTop=r.scrollHeight)})),this.taskOffset=s||this.taskOffset,t.status==="success"&&(this.$store.state.systemNewVersion=null)},startPoll(){this.stopPoll(),this.pollTimer=setTimeout(async t=>{try{const e=await this.fetchStatus(this.taskOffset);this.pollFailed=!1,this.applyStatus(e)}catch{this.pollFailed=!0}this.task.status==="running"?this.startPoll():this.taskOffset>0&&this.fetchStatus(this.taskOffset).then(this.applyStatus).catch(e=>{})},2e3)},stopPoll(){this.pollTimer&&clearTimeout(this.pollTimer),this.pollTimer=null},viewLastTask(){const t=this.lastFailed;this.enterTask(t.id),this.task=Object.assign({},t),this.fetchStatus(0).then(this.applyStatus).catch(e=>{})},backToCheck(){this.stopPoll(),clearInterval(this.clockTimer),this.taskMode=!1,this.task={},this.check(!1)},stageClass(t){const e=a.findIndex(i=>i.key===t),s=this.task.stage==="done"?a.length:a.findIndex(i=>i.key===this.task.stage);return e<s?"finish":e===s?this.task.status==="failed"?"error":this.task.status==="running"?"process":"finish":"wait"},reloadPage(){$A.reloadUrl()}}},n={};var u=c(p,h,d,!1,f,null,null,null);function f(t){for(let e in n)this[e]=n[e]}var ht=function(){return u.exports}();export{ht as default};