From 63676e4d2a8a2f15d293bf907afbabf28ba8e3bb Mon Sep 17 00:00:00 2001 From: RogerWork Date: Thu, 1 Feb 2024 18:11:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A2=9E=E5=8A=A0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=202.=20=E5=A2=9E=E5=8A=A0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=203.=20=E7=BB=B4=E6=8A=A4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/update/CinemaUpdate.vue | 38 +++++++++++++++++++----- src/components/update/Tips.vue | 40 ++++++++++++++++++++++++++ src/views/update/index.vue | 2 +- 3 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 src/components/update/Tips.vue diff --git a/src/components/update/CinemaUpdate.vue b/src/components/update/CinemaUpdate.vue index c23d0cb..2ad61fc 100644 --- a/src/components/update/CinemaUpdate.vue +++ b/src/components/update/CinemaUpdate.vue @@ -3,6 +3,7 @@ import {computed, ref, watch} from "vue"; import {onBeforeMount, onUnmounted, onMounted, onBeforeUnmount} from "vue"; import {mapState, useStore} from "vuex"; import {get_git_ver, get_update_option, handle_update} from "@/apis/update.js" +import Tips from "@/components/update/Tips.vue" // 注册store const store = useStore() @@ -29,7 +30,7 @@ onBeforeMount(async () => { // endregion // region 获取升级命令的功能 -const updateCmd = ref({setup: [], teardown: [], sql: [], client: []}) +const updateCmd = ref({setup: [], teardown: [], sql: [], config: [], client: []}) onBeforeMount( async () => { @@ -37,6 +38,7 @@ onBeforeMount( // 返回值处理逻辑 if (Array.isArray(res)) { + console.log(res) res.forEach( (value, index) => { if (value.process === "setup") { @@ -48,6 +50,9 @@ onBeforeMount( if (value.process === "sql") { updateCmd.value.sql.push(value) } + if (value.process === "config") { + updateCmd.value.config.push(value) + } if (value.process === "client") { updateCmd.value.client.push(value) } @@ -160,23 +165,30 @@ const handleUpdate = async () => { } await handle_update(params).then(res => { + const res_data = JSON.parse(JSON.stringify(res)) + const res_ip = res_data["ip"] // 处理成功逻辑 - const ip = JSON.parse(JSON.stringify(res))["ip"] - handleRep(ip) - store.commit("clear_update_status", ip) // 清除临时状态 + if (res_data["result"] === "success") { + handleRep(res_ip) + store.commit("clear_update_status", res_ip) // 清除临时状态 + } + if (res_data["result"] === "fail") { + alert(res_ip + ' 升级失败:' + res_data["msg"]) + handleRep(res_ip) + store.commit("clear_update_status", res_ip) // 清除临时状态 + } }).catch(err => { const ip = err.config.params.ip handleRep(ip) store.commit("clear_update_status", ip) // 清除临时状态 - alert("升级失败,请重试!") + alert(ip + " 升级失败,请重试!") }) } // endregion - - +