сервис уведомлений
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import {h} from "vue";
|
||||
import {NCode, NLog} from "naive-ui"
|
||||
|
||||
export function useNotification() {
|
||||
const showNotification = (options) => {
|
||||
if (window.$notification) {
|
||||
@@ -11,12 +14,20 @@ export function useNotification() {
|
||||
|
||||
}
|
||||
|
||||
const errorApi = (content = '', options = {}) => {
|
||||
const errorApi = (data, content = '', options = {}) => {
|
||||
return showNotification(
|
||||
{
|
||||
title: 'Произошла ошибка',
|
||||
description: 'При обращении к API серверу',
|
||||
content,
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user