owenoj/underconstruction

安装: 0

依赖者: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 70

语言:JavaScript

5.0 2019-09-09 14:32 UTC

This package is auto-updated.

Last update: 2024-09-16 14:42:23 UTC


README

StyleCI Packagist Total Downloads

Buy Me A Coffee

这个Laravel包可以使您的网站进入“施工中”模式。只有拥有正确4位密码的用户才能访问您的网站。此包例如可用于向特定客户展示您的网站。一切配置都默认完成,并且可以完全自定义。

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

underconstruction

安装

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

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,
];

用法

您必须设置一个4位密码(您可以在配置文件中将此密码更改为最多6位)。您可以通过运行此自定义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即可。 (不必担心,由于它是开发依赖项,它不会安装到您的生产环境中。)