dotmarn/laravel-error-views

一组使用TailwindCSS设计的自定义错误页面/屏幕,适用于Laravel项目。

v1.0.0 2024-07-21 14:01 UTC

This package is auto-updated.

Last update: 2024-09-26 20:35:50 UTC


README

Latest Stable Version License PHP Version Require Build Status

这是一个Laravel包,它提供使用TailwindCSS设计的自定义且美观的错误屏幕。

屏幕截图

Screenshot

安装

首先通过Composer安装此包。编辑你的项目中的composer.json文件以要求该包,或者简单地运行以下命令

composer require dotmarn/laravel-error-views

发布视图

此命令将所有必要的资源发布到你的项目中的public/resources/views/目录。

php artisan vendor:publish --tag=laravel-error-views:assets

发布配置

以下命令将配置文件laravel-error-views.php发布到你的项目中的config/目录,并带有一些默认设置。

php artisan vendor:publish --tag=laravel-error-views:config
<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Page Title
    |--------------------------------------------------------------------------
    |
    | Here you may specify the title that will be displayed for each of the error pages
    |
    */
    'title' => [
        '403' => env('LARAVEL_ERROR_VIEWS_403_TITLE', 'Action or Page not authorized!!!'),
        '404' => env('LARAVEL_ERROR_VIEWS_404_TITLE', 'Page Not Found!'),
        '500' => env('LARAVEL_ERROR_VIEWS_500_TITLE', 'Whoops!!! Something went wrong.'),
        '503' => env('LARAVEL_ERROR_VIEWS_503_TITLE', 'Whoops!!! Service is currently unavailable')
    ],

    /*
    |--------------------------------------------------------------------------
    | Default Messages
    |--------------------------------------------------------------------------
    |
    | Here you may specify the message that will be displayed for each of the error pages
    |
    */
    'message' => [
        '403' => env('LARAVEL_ERROR_VIEWS_403_MESSAGE', 'Sorry, You do not have access to this page or resource.'),
        '404' => env('LARAVEL_ERROR_VIEWS_404_MESSAGE', 'It seems the page or resource you are looking for doesn\'t exist or has been moved.'),
        '500' => env('LARAVEL_ERROR_VIEWS_500_MESSAGE', 'Whoops!!! It\'s not you, it\'s us. Please try again.'),
        '503' => env('LARAVEL_ERROR_VIEWS_503_MESSAGE', 'Sorry, we are doing some maintenance. Please try again in few minutes.')
    ],

    /*
    |--------------------------------------------------------------------------
    | Customizing the colors for both the title, message and, back button
    |--------------------------------------------------------------------------
    |
    | Here you may specify the text colors for both the title & message
    |
    */
    'colors' => [
        'text' => [
            'title' => env('LARAVEL_ERROR_VIEWS_COLORS_TITLE', 'text-gray-700'),
            'message' => env('LARAVEL_ERROR_VIEWS_COLORS_MESSAGE', 'text-gray-500')
        ],
        'button' => [
            'text' => env('LARAVEL_ERROR_VIEWS_COLORS_BUTTON_TEXT', 'text-purple-600')
        ]
    ],

];

(可选)

如果你想要覆盖包的默认标题和消息,你可以编辑.env文件并添加以下内容

LARAVEL_ERROR_VIEWS_404_TITLE="My Custom Title"
LARAVEL_ERROR_VIEWS_404_MESSAGE="My Custom Message"

贡献

请随意fork这个包,并通过提交pull request来增强其功能。

如何感谢您呢?

为什么不给github仓库加个星标呢?我会很高兴得到关注!为什么不分享这个仓库的链接到Twitter。

别忘了在Twitter上关注我

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。