feat: error boundary
Some checks failed
Test / build (lts/*, ubuntu-latest) (push) Has been cancelled
Test / build (lts/*, windows-latest) (push) Has been cancelled

This commit is contained in:
Dustella 2025-06-28 12:09:35 +08:00
parent 24e686dafa
commit 11666081f9
Signed by: Dustella
GPG Key ID: 35AA0AA3DC402D5C
2 changed files with 13 additions and 8 deletions

View File

@ -26,9 +26,19 @@ const urlRef = computed(() => {
return props.imageQuery
})
const { onFetchResponse, onFetchError, isFetching, execute } = baseFetch(
const { onFetchResponse, isFetching, execute } = baseFetch(
urlRef,
{ immediate: false },
{ immediate: false, updateDataOnError: true, onFetchError: async ({ error, data, response }) => {
// same as afterFetch
imageResult.result = 'error'
const rawErrorMsg = (await response?.json()).error.message as string ?? '未知错误'
if (rawErrorMsg.includes('Improper input')) {
imageResult.message = '数据异常,无法拟合. 请使用其他时间段再试'
return { error, data }
}
imageResult.message = rawErrorMsg ?? '未知错误'
return { error, data }
} },
)
watch(isFetching, (fetching) => {
if (fetching) {
@ -51,11 +61,6 @@ onFetchResponse(async (resp) => {
}
})
onFetchError(async (error) => {
imageResult.result = 'error'
imageResult.message = error
})
function download() {
if (imageResult.result === 'success') {
const a = document.createElement('a')

View File

@ -33,7 +33,7 @@ const urll = computed(() => {
query.set('path', selected.path)
query.set('day', selected.day)
query.set('height_no', selected.height_no.toString())
query.set('lat_ranges', selected.lat_ranges)
query.set('lat_range', selected.lat_ranges)
return `/saber/render/gravity_wave/per_day/wave_fitting?${query}`
})