change notification system to vue-toastification
This commit is contained in:
3
frontend/composables/useToast.js
Normal file
3
frontend/composables/useToast.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import {useToast} from "vue-toastification";
|
||||||
|
|
||||||
|
export default () => useToast()
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
|
|
||||||
import path from "path";
|
import path from 'path'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
ssr: false,
|
ssr: false,
|
||||||
@@ -32,7 +32,6 @@ export default defineNuxtConfig({
|
|||||||
modules: [
|
modules: [
|
||||||
'@vueuse/nuxt',
|
'@vueuse/nuxt',
|
||||||
'floating-vue/nuxt',
|
'floating-vue/nuxt',
|
||||||
'nuxt3-notifications',
|
|
||||||
],
|
],
|
||||||
|
|
||||||
nitro: {
|
nitro: {
|
||||||
@@ -41,6 +40,14 @@ export default defineNuxtConfig({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
build: {
|
||||||
|
transpile: ['vue-toastification'],
|
||||||
|
},
|
||||||
|
|
||||||
|
css: [
|
||||||
|
'vue-toastification/dist/index.css'
|
||||||
|
],
|
||||||
|
|
||||||
telemetry: false,
|
telemetry: false,
|
||||||
compatibilityDate: "2024-12-28",
|
compatibilityDate: "2024-12-28",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,10 +22,10 @@
|
|||||||
"marked-base-url": "^1.1.3",
|
"marked-base-url": "^1.1.3",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"nuxt": "^3.11.2",
|
"nuxt": "^3.11.2",
|
||||||
"nuxt3-notifications": "^1.2.0",
|
|
||||||
"plyr": "^3.7.8",
|
"plyr": "^3.7.8",
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.4.21",
|
||||||
"vue-router": "^4.3.0"
|
"vue-router": "^4.3.0",
|
||||||
|
"vue-toastification": "^2.0.0-rc.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
|||||||
9
frontend/plugins/toast.js
Normal file
9
frontend/plugins/toast.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import Toast from 'vue-toastification'
|
||||||
|
|
||||||
|
export default defineNuxtPlugin(nuxtApp => nuxtApp.vueApp.use(Toast, {
|
||||||
|
transition: "Vue-Toastification__bounce",
|
||||||
|
maxToasts: 5,
|
||||||
|
closeOnClick: false,
|
||||||
|
newestOnTop: true,
|
||||||
|
showCloseButtonOnHover: true,
|
||||||
|
}))
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import {useNotification} from '@kyvg/vue3-notification'
|
const toast = useToast()
|
||||||
|
|
||||||
const {notify} = useNotification();
|
|
||||||
|
|
||||||
const AG_SEPARATOR = '.'
|
const AG_SEPARATOR = '.'
|
||||||
|
|
||||||
@@ -165,28 +163,29 @@ const ucFirst = (str) => {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const notification = (type, title, text, duration = 3000) => {
|
const notification = (type, title, text, duration = 3000) => {
|
||||||
let classes = ''
|
let method = '', options = {
|
||||||
|
timeout: duration,
|
||||||
|
}
|
||||||
|
|
||||||
switch (type.toLowerCase()) {
|
switch (type.toLowerCase()) {
|
||||||
case 'info':
|
case 'info':
|
||||||
default:
|
default:
|
||||||
classes = 'has-background-info has-text-white'
|
method = 'info'
|
||||||
break
|
break
|
||||||
case 'success':
|
case 'success':
|
||||||
classes = 'has-background-success has-text-white'
|
method = 'success'
|
||||||
break
|
break
|
||||||
case 'warning':
|
case 'warning':
|
||||||
classes = 'has-background-warning has-text-white'
|
method = 'warning'
|
||||||
break
|
break
|
||||||
case 'error':
|
case 'error':
|
||||||
classes = 'has-background-danger has-text-white'
|
method = 'error'
|
||||||
if (duration === 3000) {
|
if (3000 === duration) {
|
||||||
duration = 10000
|
options.timeout = 10000
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
toast[method](text, options)
|
||||||
return notify({title, text, type: classes, duration})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
1742
frontend/yarn.lock
1742
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user