@demos-europe/dp-consent

中文文档
1.3.0发布于 2024/08/07MITESM + CJS零依赖近 30 天下载 3570

A cookie consent solution.

原始使用文档

DP Cookie Consent

This is a small script that allows to manage cookie consent for optional cookies.

Usage

import { dpConsent } from 'cookie-consent/dist/dp-consent.es.min.js'

// initializing dp consent
const consent = dpConsent({
  notice: '', // text to be shown in the cookie slideout
  optionalCookies: [
    {
      name: '', // the cookie's name
      explanation: '' // what does this cookie do
    },
    { ... }
  ], // an array of optional cookies
  necessaryCookies: [ /* same structure as above */ ], // an array of necessary cookies
  onGrantConsent: () => {}, // callback to be executed when consent is granted
  onRevokeConsent: () => {} // callback to be executed when consent is revoked
})

// adjusting consent settings
consent.adjustSettings()

How it works?

Dp-Cookie-Consent will show a slideout providing options to accept all cookies or to change cookie settings. If all cookies are accepted the onGrantConsent-callback will be executed and all optional cookies can be set. If the user opts to change cookie settings a modal will be opened that presents the user with a list of all necessary and all optional cookies. If the user selects optional cookies and saves these settings, the onGrantConsent-callback will be executed. If the user doesn't select optional cookies the onRevokeConsent-callback will be executed. A cookie will be set that remembers the user's choice. The cookie expires within one year.

版本与发布记录

@demos-europe/dp-consent 共发布 3 个版本,首次发布于 2022/09/21;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.3.0latest2024/08/072 年前
1.2.02024/08/062 年前
1.1.22022/09/214 年前

关于 @demos-europe/dp-consent 的常见问题

@demos-europe/dp-consent 是什么?

A cookie consent solution.

如何安装 @demos-europe/dp-consent?

在项目目录运行 npm install @demos-europe/dp-consent,或使用 pnpm add / yarn add / bun add。

@demos-europe/dp-consent 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/demos-europe__dp-consent 是否存在。

@demos-europe/dp-consent 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@demos-europe/dp-consent 可以商用吗?

@demos-europe/dp-consent 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@demos-europe/dp-consent 的下载量有多少?

根据 npm 官方下载统计,@demos-europe/dp-consent 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,570 次,日均约 119 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@demos-europe/dp-consent 还在维护吗?

最新版本 1.3.0 发布于 2024/08/07(2 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/09/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。