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 - - +