ez-laravel/cookie-consent

简单易用的Laravel Cookie Consent

v1.0.1 2020-06-25 18:07 UTC

This package is auto-updated.

Last update: 2024-09-26 22:55:58 UTC


README

这是一个简单的包,用于在您的Laravel应用程序中显示cookie同意对话框。

安装

在项目目录中运行以下命令来安装此包

composer require ez-laravel/cookie-consent

运行以下命令以发布包的Vue组件和视图,以便您可以对这些组件进行自定义

php artisan vendor:publish --provider="EZ\\CookieConsent\\Providers\\CookieConsentServiceProvider" --tag=frontend

确保Vue.js组件已加载;我通常在app.js中使用以下代码来自动加载所有可用组件

// Automatically load all vue components
const files = require.context('./', true, /\.vue$/i);
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));

讽刺的是,此包使用cookie来存储用户的答案;如果您想自定义cookie的名称,应发布配置文件并重写cookie_name属性。

php artisan vendor:publish --provider="EZ\\CookieConsent\\Providers\\CookieConsentServiceProvider" --tag=config

使用方法

现在您只需在布局中包含cookie同意对话框的部分,它就会显示给用户,直到他们同意或不同意对话框。

@include("cookieconsent::dialog")

贡献

如果您想贡献,请随时提交一个pull request!