first commit
This commit is contained in:
41
resources/js/Composables/useNotification.js
Normal file
41
resources/js/Composables/useNotification.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import {h} from "vue";
|
||||
import {NCode, NLog} from "naive-ui"
|
||||
|
||||
export function useNotification() {
|
||||
const showNotification = (options) => {
|
||||
if (window.$notification) {
|
||||
return window.$notification.create(options)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
const success = () => {
|
||||
|
||||
}
|
||||
|
||||
const errorApi = (data, content = '', options = {}) => {
|
||||
return showNotification(
|
||||
{
|
||||
title: 'Произошла ошибка',
|
||||
description: `Код: ${data.code}\nURL: ${data.response.config.url}\nМетод: ${data.response.config.method.toUpperCase()}`,
|
||||
content: () => {
|
||||
return h(
|
||||
NLog,
|
||||
{
|
||||
rows: 4,
|
||||
log: data.response.config.data,
|
||||
}
|
||||
)
|
||||
},
|
||||
meta: options.meta || new Date().toLocaleDateString(),
|
||||
...options,
|
||||
type: 'error'
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
errorApi
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user