Files
2026-06-24 17:20:43 +09:00

42 lines
1.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { NotificationOptions } from 'naive-ui';
/**
* Обёртка над discrete notification API NaiveUI с удобными хелперами.
* Перенесено и упрощено из проекта onboard (Composables/useNotification.js).
*/
export function useNotification() {
const showNotification = (options: NotificationOptions) => {
return window.$notification?.create(options) ?? null;
};
const success = (
title: string,
description = '',
options: Partial<NotificationOptions> = {},
) => {
return showNotification({
title,
description,
meta: options.meta ?? new Date().toLocaleDateString(),
...options,
type: 'success',
});
};
const error = (
title = 'Произошла ошибка',
description = '',
options: Partial<NotificationOptions> = {},
) => {
return showNotification({
title,
description,
meta: options.meta ?? new Date().toLocaleDateString(),
...options,
type: 'error',
});
};
return { success, error };
}