修复失败后的处理逻辑,优化代码结构

main
RogerWork 1 year ago
parent b08ad2f7dc
commit 49dc91b493
  1. 78
      src/components/update/CinemaUpdate.vue

@ -59,6 +59,32 @@ onBeforeMount(
) )
//endregion //endregion
// region
let updateBtn = ref("更新")
const handleBtnName = (ip) => {
if (store.state.update_status[ip] === false) {
updateBtn.value = "更新"
}
if (store.state.update_status[ip] === true) {
updateBtn.value = "更新中"
}
}
// endregion
// region
const disableAll = ref(false)
const handleDisable = (ip) => {
disableAll.value = store.state.update_status[ip] === true;
}
// endregion
// region
const changUpdateStatus = (ip) => {
store.commit("change_update_status", ip)
}
// endregion
// region opened // region opened
// ipstore // ipstore
const addUpdateStatus = () => { const addUpdateStatus = () => {
@ -88,6 +114,11 @@ const handleOpened = () => {
} }
// endregion // endregion
// region close
const handleClose = () => {
store.state.update_dialog_show = false
}
// endregion
// region // region
const updateForm = ref() const updateForm = ref()
@ -95,10 +126,11 @@ const checkedCmd = ref([])
// //
const handleRep = (ip) => { const handleRep = (ip) => {
console.log(store.state.update_status[ip])
changUpdateStatus(ip) // changUpdateStatus(ip) //
handleBtnName(props.ip) // handleBtnName(props.ip) //
handleDisable(props.ip) // handleDisable(props.ip) //
store.commit("clear_update_status", props.ip) // console.log(store.state.update_status[ip])
} }
const handleUpdate = async () => { const handleUpdate = async () => {
@ -106,13 +138,7 @@ const handleUpdate = async () => {
alert("请先选择影院和目标版本!") alert("请先选择影院和目标版本!")
return return
} }
handleRep(props.ip)
//
changUpdateStatus(props.ip)
//
handleBtnName(props.ip)
//
handleDisable(props.ip)
// store // store
let data = {} let data = {}
@ -137,47 +163,17 @@ const handleUpdate = async () => {
// //
const ip = JSON.parse(JSON.stringify(res))["ip"] const ip = JSON.parse(JSON.stringify(res))["ip"]
handleRep(ip) handleRep(ip)
store.commit("clear_update_status", ip) //
}).catch(err => { }).catch(err => {
const ip = JSON.parse(JSON.stringify(err))["ip"] const ip = err.config.params.ip
handleRep(ip) handleRep(ip)
store.commit("clear_update_status", ip) //
alert("升级失败,请重试!") alert("升级失败,请重试!")
}) })
} }
// endregion // endregion
// region
const changUpdateStatus = (ip) => {
store.commit("change_update_status", ip)
}
// endregion
// region
let updateBtn = ref("更新")
const handleBtnName = (ip) => {
if (store.state.update_status[ip] === false) {
updateBtn.value = "更新"
}
if (store.state.update_status[ip] === true) {
updateBtn.value = "更新中"
}
}
// endregion
// region
const disableAll = ref(false)
const handleDisable = (ip) => {
disableAll.value = store.state.update_status[ip] === true;
}
// endregion
// region
const handleClose = () => {
store.state.update_dialog_show = false
}
// endregion
</script> </script>

Loading…
Cancel
Save