🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

dingtalk-qr-code

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dingtalk-qr-code

Generate DingTalk style qr code, for node.js/web worker/dom

latest
npmnpm
Version
1.0.3
Version published
Weekly downloads
1
-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

DingTalk QR Code

钉钉风格的二维码生成器

使用方法

node.js

import { createCanvas, loadImage } from '@napi-rs/canvas';
import qr from 'dingtalk-qr-code';
import fs from 'fs/promises';

async function main() {
  const url = 'https://www.dingtalk.com';
  const defaultImgUrl =
    'https://gw.alicdn.com/imgextra/i4/O1CN01djwPhA29ICfjOWcA1_!!6000000008044-2-tps-192-192.png';
  const canvas = createCanvas(1, 1);
  const ctx = (canvas.getContext('2d') as any) as CanvasRenderingContext2D;
  const logo = ((await loadImage(defaultImgUrl)) as any) as HTMLImageElement;

  qr.generate(ctx, url, { logo, });

  const data = canvas.toBuffer('image/png');
  await fs.writeFile('./qrcode.test.png', data);
}

main();

前端

import qr from 'dingtalk-qr-code';

async function main() {
  const url = 'https://www.dingtalk.com';
  const defaultImgUrl =
    'https://gw.alicdn.com/imgextra/i4/O1CN01djwPhA29ICfjOWcA1_!!6000000008044-2-tps-192-192.png';
  const logo = document.createElement('img');
  logo.src = defaultImgUrl;
  await new Promise(r=>logo.onload = r);

  const canvas = document.createElement('canvas');
  const ctx = canvas.getContext('2d');

  qr.generate(ctx, url, { logo, });

  document.body.appendChild(canvas);
}

main();

FAQs

Package last updated on 16 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts