mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-23 16:30:45 +01:00
chore(plugins): use return provide
This commit is contained in:
@@ -24,9 +24,11 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
nuxtApp.provide('clipboard', {
|
return {
|
||||||
copy
|
provide: {
|
||||||
})
|
copy
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
declare module '#app' {
|
declare module '#app' {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Ref } from 'vue'
|
|||||||
import { defineNuxtPlugin, useState } from '#app'
|
import { defineNuxtPlugin, useState } from '#app'
|
||||||
import { ToastNotification, ToastPlugin } from '../types'
|
import { ToastNotification, ToastPlugin } from '../types'
|
||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin(() => {
|
||||||
const notifications: Ref<ToastNotification[]> = useState('notifications', () => [])
|
const notifications: Ref<ToastNotification[]> = useState('notifications', () => [])
|
||||||
|
|
||||||
function addNotification (notification: Partial<ToastNotification>) {
|
function addNotification (notification: Partial<ToastNotification>) {
|
||||||
@@ -23,42 +23,44 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
notifications.value = notifications.value.filter((n: ToastNotification) => n.id !== id)
|
notifications.value = notifications.value.filter((n: ToastNotification) => n.id !== id)
|
||||||
}
|
}
|
||||||
|
|
||||||
nuxtApp.provide('toast', {
|
return {
|
||||||
addNotification,
|
provide: {
|
||||||
removeNotification,
|
addNotification,
|
||||||
success ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
|
removeNotification,
|
||||||
addNotification({
|
success ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
|
||||||
type: 'success',
|
addNotification({
|
||||||
title,
|
type: 'success',
|
||||||
description,
|
title,
|
||||||
timeout
|
description,
|
||||||
})
|
timeout
|
||||||
},
|
})
|
||||||
info ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
|
},
|
||||||
addNotification({
|
info ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
|
||||||
type: 'info',
|
addNotification({
|
||||||
title,
|
type: 'info',
|
||||||
description,
|
title,
|
||||||
timeout
|
description,
|
||||||
})
|
timeout
|
||||||
},
|
})
|
||||||
warning ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
|
},
|
||||||
addNotification({
|
warning ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
|
||||||
type: 'warning',
|
addNotification({
|
||||||
title,
|
type: 'warning',
|
||||||
description,
|
title,
|
||||||
timeout
|
description,
|
||||||
})
|
timeout
|
||||||
},
|
})
|
||||||
error ({ title = 'An error occurred!', description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
|
},
|
||||||
addNotification({
|
error ({ title = 'An error occurred!', description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
|
||||||
type: 'error',
|
addNotification({
|
||||||
title,
|
type: 'error',
|
||||||
description,
|
title,
|
||||||
timeout
|
description,
|
||||||
})
|
timeout
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
declare module '#app' {
|
declare module '#app' {
|
||||||
|
|||||||
Reference in New Issue
Block a user