gestazion/建设中

安装次数: 1,008

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 70

语言:JavaScript

11.0.0 2024-08-13 10:34 UTC

This package is auto-updated.

Last update: 2024-09-13 10:48:52 UTC


README

StyleCI Packagist Total Downloads

Buy Me A Coffee

此Laravel包可以将您的网站设置为“建设中”模式。只有拥有正确四位密码的用户才能访问您的网站。此包可用于向特定客户展示您的网站。一切都将自动完成,并且可完全自定义。

如果您欣赏我的工作,请为这个仓库点个赞或买我一杯咖啡 ^ 🤗。

underconstruction

安装

首先通过Composer安装此包(兼容Laravel 6、7、8和9)!

composer require larsjanssen6/underconstruction

必须将 \LarsJanssen\UnderConstruction\UnderConstruction::class 中间件注册到内核中

//app/Http/Kernel.php

protected $routeMiddleware = [
  // ...
  'under-construction' => \LarsJanssen\UnderConstruction\UnderConstruction::class,
];

默认设置

发布默认配置文件。

php artisan vendor:publish

# Or...

php artisan vendor:publish --provider="LarsJanssen\UnderConstruction\UnderConstructionServiceProvider"

此包可完全自定义。这是已发布的配置文件 under-construction.php 的内容

<?php

return [

    /*
     * Activate under construction mode.
     */
    'enabled' => env('UNDER_CONSTRUCTION_ENABLED', true),

    /*
     * Hash for the current pin code
     */
    'hash' => env('UNDER_CONSTRUCTION_HASH', null),

    /*
     * Under construction title.
     */
    'title' => 'Under Construction',

    /*
     * Custom Route Prefix
     * */
    'route-prefix' => env('UNDER_CONSTRUCTION_ROUTE_PREFIX','under'),

    /*
     * Custom Endpoint if you don't want to use 'construction'
     * e.g. if you change to 'checkpoint', the route prefix
     * above will be appended giving you 'under/checkpoint'
     * */
    'custom-endpoint' => env('UNDER_CONSTRUCTION_CUSTOM_ENDPOINT','construction'),


    /*
     * Back button translation.
     */
    'back-button' => 'back',

    /*
    * Show button translation.
    */
    'show-button' => 'show',

    /*
     * Hide button translation.
     */
    'hide-button' => 'hide',

    /*
     * Show loader.
     */
    'show-loader' => true,

    /*
     * Redirect url after a successful login.
     */
    'redirect-url' => '/',

    /*
     * Enable throttle (max login attempts).
     */
    'throttle' => true,

        /*
        |--------------------------------------------------------------------------
        | Throttle settings (only when throttle is true)
        |--------------------------------------------------------------------------
        |
        */

        /*
        * Set the amount of digits (max 6).
        */
        'total_digits' => 4,

        /*
         * Set the maximum number of attempts to allow.
         */
        'max_attempts' => 3,

        /*
         * Show attempts left.
         */
        'show_attempts_left' => true,

        /*
         * Attempts left message.
         */
        'attempts_message' => 'Attempts left: %i',

        /*
         * Too many attempts message.
         */
        'seconds_message' => 'Too many attempts please try again in %i seconds.',

        /*
         * Set the number of minutes to disable login.
         */
        'decay_minutes' => 5,

        /*
         * Prevent the site from being indexed by Robots when locked
         */
        'lock_robots' => true,
];

使用方法

您需要设置一个四位密码(您可以在配置文件中将此值更改为最多六位)。您可以运行此自定义Artisan命令(在此示例中密码为 1234,您当然可以设置其他密码)。它将生成一个哈希值,该值将存储在您的 .env 文件中。

php artisan code:set 1234

您可以通过在路由上使用 under-construction 中间件来设置路由为“建设中”模式。

Route::group(['middleware' => 'under-construction'], function () {
    Route::get('/live-site', function() {
        echo 'content!';
    });
});

更新日志

有关最近更改的更多信息,请参阅 更新日志

测试

composer test

贡献

我很乐意听取您改进我的编码风格和约定的想法。请自由贡献。

安全

如果您发现任何安全相关的问题,请通过电子邮件 larsjanssen64@gmail.com 联系我。您也可以创建一个问题。

鸣谢

关于我

我是来自荷兰的Lars Janssen,喜欢从事网络项目。您可以在 Twitter 上关注我。

许可证

MIT许可证(MIT)。有关更多信息,请参阅 许可证文件

❤️开源软件 - 给⭐️

我们已将出色的 symfony/thanks Composer 包作为开发依赖项包含在内。通过为使用的包点个赞来告知您的操作系统包维护者您对此表示感谢。只需安装此包后运行composer thanks即可。(不用担心,由于它是开发依赖项,它不会安装到您的生产环境中。)