fix: error management
This commit is contained in:
45
web/index.js
45
web/index.js
@@ -4,6 +4,7 @@ const component_share = {
|
|||||||
template: `
|
template: `
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<h3>Share with others!</h3>
|
<h3>Share with others!</h3>
|
||||||
|
<p v-if="error_status">{{ error_status }}</p>
|
||||||
<p>Share link: <a :href="computed_share_link">{{ computed_share_link }}</a> , or share this page directly.</p>
|
<p>Share link: <a :href="computed_share_link">{{ computed_share_link }}</a> , or share this page directly.</p>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -30,6 +31,7 @@ const component_share = {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
file: {},
|
file: {},
|
||||||
|
error_status: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -43,6 +45,12 @@ const component_share = {
|
|||||||
id: parseInt(this.$route.query.id),
|
id: parseInt(this.$route.query.id),
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
this.file = response.data
|
this.file = response.data
|
||||||
|
}).catch((error) => {
|
||||||
|
if (error.response) {
|
||||||
|
this.error_status = error.response.data.status
|
||||||
|
} else {
|
||||||
|
this.error_status = 'Network error'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -168,7 +176,11 @@ const component_search_folders = {
|
|||||||
this.error_status = ""
|
this.error_status = ""
|
||||||
this.files_in_folder = response.data.files
|
this.files_in_folder = response.data.files
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.error_status = error.response.data.status
|
if (error.response) {
|
||||||
|
this.error_status = error.response.data.status
|
||||||
|
} else {
|
||||||
|
this.error_status = 'Network error'
|
||||||
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.is_loading = false
|
this.is_loading = false
|
||||||
})
|
})
|
||||||
@@ -199,7 +211,11 @@ const component_search_folders = {
|
|||||||
this.error_status = ""
|
this.error_status = ""
|
||||||
this.folders = response.data.folders
|
this.folders = response.data.folders
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.error_status = error.response.data.status
|
if (error.response) {
|
||||||
|
this.error_status = error.response.data.status
|
||||||
|
} else {
|
||||||
|
this.error_status = 'Network error'
|
||||||
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.is_loading = false
|
this.is_loading = false
|
||||||
})
|
})
|
||||||
@@ -627,10 +643,7 @@ const component_audio_player = {
|
|||||||
this.prepare_func()
|
this.prepare_func()
|
||||||
},
|
},
|
||||||
ffmpeg_config() {
|
ffmpeg_config() {
|
||||||
if (this.prepare) {
|
this.setup_player()
|
||||||
this.playing_file = {}
|
|
||||||
this.prepare_func()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -739,7 +752,11 @@ const component_search_files = {
|
|||||||
this.error_status = ""
|
this.error_status = ""
|
||||||
this.files = response.data.files
|
this.files = response.data.files
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.error_status = error.response.data.status
|
if (error.response) {
|
||||||
|
this.error_status = error.response.data.status
|
||||||
|
} else {
|
||||||
|
this.error_status = 'Network error'
|
||||||
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.is_loading = false
|
this.is_loading = false
|
||||||
})
|
})
|
||||||
@@ -766,10 +783,14 @@ const component_get_random_files = {
|
|||||||
return {
|
return {
|
||||||
files: [],
|
files: [],
|
||||||
is_loading: false,
|
is_loading: false,
|
||||||
|
error_status: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
computed_refresh() {
|
computed_refresh() {
|
||||||
|
if (this.error_status) {
|
||||||
|
return this.error_status
|
||||||
|
}
|
||||||
if (this.is_loading) {
|
if (this.is_loading) {
|
||||||
return 'Loading...'
|
return 'Loading...'
|
||||||
}
|
}
|
||||||
@@ -806,8 +827,16 @@ const component_get_random_files = {
|
|||||||
this.is_loading = true
|
this.is_loading = true
|
||||||
axios.get('/api/v1/get_random_files'
|
axios.get('/api/v1/get_random_files'
|
||||||
).then(response => {
|
).then(response => {
|
||||||
this.is_loading = false
|
this.error_status = ""
|
||||||
this.files = response.data.files;
|
this.files = response.data.files;
|
||||||
|
}).catch((error) => {
|
||||||
|
if (error.response) {
|
||||||
|
this.error_status = error.response.data.status
|
||||||
|
} else {
|
||||||
|
this.error_status = 'Network error'
|
||||||
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
this.is_loading = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user