fix: 修复取消上一次请求中存在的问题

This commit is contained in:
Xu Zhimeng 2024-03-11 11:09:41 +08:00
parent c5d8f3aed5
commit 59678df335

View File

@ -525,7 +525,10 @@ export default {
} }
} catch (error) { } catch (error) {
console.error(error) console.error(error)
this.isLoading = false const isCancel = axios.isCancel(error)
if(!isCancel) {
this.isLoading = false
}
} }
}, },
@ -561,6 +564,7 @@ export default {
cancelLastRequest() { cancelLastRequest() {
if (this._cancelToken && typeof this._cancelToken == 'function') { if (this._cancelToken && typeof this._cancelToken == 'function') {
this._cancelToken() this._cancelToken()
this._cancelToken = undefined
} }
}, },
@ -2058,6 +2062,8 @@ export default {
this.handleResetState() this.handleResetState()
const sampleData = await this.$store.dispatch('GET_SAMPLE_DATA', newVal.inputFileName) const sampleData = await this.$store.dispatch('GET_SAMPLE_DATA', newVal.inputFileName)
if (sampleData) { if (sampleData) {
this.cancelLastRequest()
this.isLoading = false
this.dataProcess(sampleData.data, sampleData.from) this.dataProcess(sampleData.data, sampleData.from)
} else { } else {
if (newVal.sampleId) { if (newVal.sampleId) {