diff options
| author | Pitu <[email protected]> | 2018-09-18 03:52:49 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2018-09-18 03:52:49 -0300 |
| commit | 8ca6784eec8d8f1e4a9c4f6875704f09aae1103a (patch) | |
| tree | e652ea6738384e5156f9d030365bc9e234cb1be0 /src/site | |
| parent | Enable changing album options (diff) | |
| download | host.fuwn.me-8ca6784eec8d8f1e4a9c4f6875704f09aae1103a.tar.xz host.fuwn.me-8ca6784eec8d8f1e4a9c4f6875704f09aae1103a.zip | |
Better error handling on invalid links
Diffstat (limited to 'src/site')
| -rw-r--r-- | src/site/views/PublicAlbum.vue | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/site/views/PublicAlbum.vue b/src/site/views/PublicAlbum.vue index e156698..f242957 100644 --- a/src/site/views/PublicAlbum.vue +++ b/src/site/views/PublicAlbum.vue @@ -19,7 +19,7 @@ <template> <section class="hero is-fullheight"> - <template v-if="files.length"> + <template v-if="files && files.length"> <div class="hero-body align-top"> <div class="container"> <h1 class="title">{{ name }}</h1> @@ -67,6 +67,23 @@ export default { downloadLink }; } catch (error) { + return { + name: null, + downloadEnabled: false, + files: [], + downloadLink: null, + error: error.response.status + }; + /* + if (error.response.status === 404) { + + setTimeout(() => this.$router.push('/404'), 3000); + } else { + console.error(error); + } + return {}; + */ + /* console.error(error); return { name: null, @@ -74,6 +91,7 @@ export default { files: [], downloadLink: null }; + */ } }, data() { @@ -99,17 +117,20 @@ export default { }; }, mounted() { + if (this.error) { + if (this.error === 404) { + this.$toast.open('Album not found', true, 3000); + setTimeout(() => this.$router.push('/404'), 3000); + return; + } else { + this.$toast.open(`Error code ${this.error}`, true, 3000); + } + } this.$ga.page({ page: `/a/${this.$route.params.identifier}`, title: `Album | ${this.name}`, location: window.location.href }); - }, - methods: { - async downloadAlbum() { - const response = await axios.get(`${config.baseURL}/album/${this.$route.params.identifier}/zip`); - console.log(response.data); - } } }; </script> |