编程

支持 Laravel TALL 栈的 Toast 通知扩展包

1516 2022-01-01 01:16:32

TALL Toasts 是 Laravel TALL栈(Tailwind, Alpine.js, Laravel, Livewire)下的 toast 通知库。该包可以从前台和后台渲染自定义 toast 通知消息。同时,也能发布 CSS/JS 文件。

以下是触发 toast 消息的前端 API:

// Frontend
Toast.info(
  'Notification from the frontend...',
  'The Title'
);
 
Toast.success('A toast without a title also works');
 
Toast.warning('Watch out!');
 
Toast.danger('I warned you!', 'Yikes');

后端示例:

// backend
toast()
    ->info('Notification from the backend...', 'The Title')
    ->push();
 
toast()
    ->success('A toast without a title also works')
    ->push();
 
toast()
    ->warning('Watch out!')
    ->push();
 
toast()
    ->danger('I warned you!', 'Yikes')
    ->push();

另外,你可以修改 blade 文件控制修改消息框的展示样式。