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

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

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

Loading…
Cancel
Save