Tody up a little bit

This commit is contained in:
Pitu 2019-03-29 03:28:25 +00:00
parent e9ce158e36
commit a248f69947
2 changed files with 8 additions and 25 deletions

View File

@ -14,38 +14,22 @@ export default {
}, },
created() { created() {
Vue.prototype.$onPromiseError = (error, logout = false) => { Vue.prototype.$onPromiseError = (error, logout = false) => {
this.processCatch(error, logout); 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);
}
}; };
Vue.prototype.$showToast = (text, error, duration) => { Vue.prototype.$showToast = (text, error, duration) => {
this.showToast(text, error, duration);
};
},
methods: {
showToast(text, error, duration) {
this.$toast.open({ this.$toast.open({
duration: duration || 2500, duration: duration || 2500,
message: text, message: text,
position: 'is-bottom', position: 'is-bottom',
type: error ? 'is-danger' : 'is-success' type: error ? 'is-danger' : 'is-success'
}); });
}, };
processCatch(error, logout) {
if (error.response && error.response.data && error.response.data.message) {
this.showToast(error.response.data.message, true, 5000);
/*
if (error.response.status === 429) return;
if (error.response.status === 502) return;
if (error.response.data.message === 'Token expired') {
this.$logOut();
setTimeout(() => this.$router.push('/'), 3000);
}
*/
} else {
console.error(error);
this.showToast('Something went wrong, please check the console :(', true, 5000);
}
}
} }
}; };
</script> </script>

View File

@ -5,10 +5,9 @@
<template> <template>
<section id="login" <section id="login"
class="hero is-fullheight"> class="hero is-fullheight">
<Navbar/> <Navbar />
<div class="hero-body"> <div class="hero-body">
<div class="container has-text-left"> <div class="container has-text-left">
<h2 class="subtitle">What is lolisafe?</h2> <h2 class="subtitle">What is lolisafe?</h2>
<article class="message"> <article class="message">
<div class="message-body"> <div class="message-body">