This commit is contained in:
xXpuma99Xx 2022-07-10 20:06:30 -05:00
parent bd21e0e004
commit 30eda498cb
2 changed files with 76 additions and 1 deletions

View File

@ -15,7 +15,7 @@ export default {
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
css: [],
plugins: [],
plugins: ['~/plugins/inject.js'],
components: true,
buildModules: [],
modules: ['nuxt-buefy', '@nuxtjs/axios', 'nuxt-socket-io'],

75
plugins/inject.js Normal file
View File

@ -0,0 +1,75 @@
const alertsGenericos = {
imprimirError(
buefy,
err = {},
title = '¡Hubo un error!',
onConfirm = () => {}
) {
buefy.dialog.alert({
ariaModal: true,
hasIcon: true,
onConfirm,
ariaRole: 'alertdialog',
confirmText: 'Entendido',
icon: 'alert-octagon',
iconPack: 'mdi',
message: err.message,
title,
type: 'is-danger',
})
// if (err.err && err.err === 'token error') {
// localStorage.clear()
// this.$router.push('/')
// }
},
imprimirMensaje(
buefy,
message,
onConfirm = () => {},
title = '¡Felicidades!'
) {
buefy.dialog.alert({
ariaModal: true,
hasIcon: true,
onConfirm,
ariaRole: 'alertdialog',
confirmText: 'Ok',
icon: 'check-circle',
iconPack: 'mdi',
message,
title,
type: 'is-success',
})
},
imprimirWarning(
buefy,
message,
onConfirm = () => {},
title = '¡Espera un minuto!',
onCancel = () => {}
) {
buefy.dialog.alert({
ariaModal: true,
canCancel: true,
hasIcon: true,
onCancel,
onConfirm,
ariaRole: 'alertdialog',
cancelText: 'Cancelar',
confirmText: 'Confirmar',
icon: 'help-circle',
iconPack: 'mdi',
message,
title,
type: 'is-warning',
})
},
getLocalhostInfo() {
const objeto = JSON.parse(localStorage.getItem('usuario'))
this.admin = objeto.operador
},
}
export default ({ app }, inject) => {
inject('alertsGenericos', alertsGenericos)
}