diff options
| author | Pitu <[email protected]> | 2019-04-24 08:37:12 +0000 |
|---|---|---|
| committer | Pitu <[email protected]> | 2019-04-24 08:37:12 +0000 |
| commit | a7c1855ce560dc5ef13c63c61cf73af36b956ba7 (patch) | |
| tree | 8329000931e78704abbb09991995fd706dd77881 /src | |
| parent | Globally catch exceptions (diff) | |
| download | host.fuwn.me-a7c1855ce560dc5ef13c63c61cf73af36b956ba7.tar.xz host.fuwn.me-a7c1855ce560dc5ef13c63c61cf73af36b956ba7.zip | |
Better alert handling
Diffstat (limited to 'src')
| -rw-r--r-- | src/site/layouts/default.vue | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/site/layouts/default.vue b/src/site/layouts/default.vue index e2c7e12..c0b2407 100644 --- a/src/site/layouts/default.vue +++ b/src/site/layouts/default.vue @@ -2,38 +2,37 @@ <nuxt /> </template> <script> -import Vue from 'vue'; export default { computed: { config() { return this.$store.state.config; + }, + alert() { + return this.$store.state.alert; } }, - mounted() { - console.log(`%c lolisafe %c v${this.config.version} %c`, 'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff', 'background:#ff015b; padding: 1px; border-radius: 0 3px 3px 0; color: #fff', 'background:transparent'); - }, - created() { - Vue.prototype.$onPromiseError = (error, logout = false) => { - if (error.response && error.response.data && error.response.data.message) { - this.$showToast(error.response.data.message, true, 5000); - } else { - console.error(error); - this.$showToast('Something went wrong, please check the console :(', true, 5000); - } - }; + watch: { + alert() { + if (!this.alert) return; - Vue.prototype.$showToast = (text, error, duration) => { this.$toast.open({ - duration: duration || 2500, - message: text, + duration: 3500, + message: this.alert.text, position: 'is-bottom', - type: error ? 'is-danger' : 'is-success' + type: this.alert.error ? 'is-danger' : 'is-success' }); - }; + + setTimeout(() => { + this.$store.dispatch('alert', null); + }, 3500); + } + }, + mounted() { + console.log(`%c lolisafe %c v${this.config.version} %c`, 'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff', 'background:#ff015b; padding: 1px; border-radius: 0 3px 3px 0; color: #fff', 'background:transparent'); } }; </script> <style lang="scss"> @import "~/assets/styles/style.scss"; - @import "~assets/styles/icons.min.css"; + @import "~/assets/styles/icons.min.css"; </style> |