• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript qrcode.toDataURL函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中qrcode.toDataURL函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toDataURL函数的具体用法?TypeScript toDataURL怎么用?TypeScript toDataURL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了toDataURL函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: async

export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
	// Get 'password' parameter
	const [password, passwordErr] = $.str.get(params.password);
	if (passwordErr) return rej('invalid password param');

	// Compare password
	const same = await bcrypt.compare(password, user.password);

	if (!same) {
		return rej('incorrect password');
	}

	// Generate user's secret key
	const secret = speakeasy.generateSecret({
		length: 32
	});

	await User.update(user._id, {
		$set: {
			twoFactorTempSecret: secret.base32
		}
	});

	// Get the data URL of the authenticator URL
	QRCode.toDataURL(speakeasy.otpauthURL({
		secret: secret.base32,
		encoding: 'base32',
		label: user.username,
		issuer: config.host
	}), (err, data_url) => {
		res({
			qr: data_url,
			secret: secret.base32,
			label: user.username,
			issuer: config.host
		});
	});
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:38,代码来源:register.ts


示例2: convertObjectToQRCodeDataURL

export async function convertObjectToQRCodeDataURL(object: any): Promise<string> {
  const string = JSON.stringify(object);

  return await QRCode.toDataURL(string);
}
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:5,代码来源:string-encoding.ts


示例3: function

/// <reference path="qrcode.d.ts" />

import * as QRCode from 'qrcode';

QRCode.toDataURL('i am a pony!', function (err, url) {
    console.log(url);
});

var qrcodedraw = new QRCodeLib.QRCodeDraw();

qrcodedraw.draw(document.getElementById('test') as HTMLCanvasElement, "this text will be in the code!", function (error, canvas) {
    if (error) {
        return console.log('Error =( ', error);
    }
    console.log('success!');
});
开发者ID:CNManning,项目名称:DefinitelyTyped,代码行数:16,代码来源:qrcode-tests.ts


示例4:

import * as QRCode from 'qrcode';

const canvas = document.getElementById('canvas') as HTMLCanvasElement;

QRCode.toCanvas(canvas, 'sample text', (error) => {
    if (error) console.error(error);
    console.log('success!');
});

QRCode.toDataURL('I am a pony!', (err, url) => {
    console.log(url);
});

QRCode.toDataURL('some text', { errorCorrectionLevel: 'H' }, (err, url) => {
    console.log(url);
});

QRCode.toDataURL('some text', { version: 2 }, (err, url) => {
    console.log(url);
});

QRCode.toDataURL([
    { data: 'ABCDEFG', mode: 'alphanumeric' },
    { data: '0123456', mode: 'numeric' }
], (err, url) => {
    console.log(url);
});

QRCode.toCanvas('text', { errorCorrectionLevel: 'H' }, (err, canvas) => {
    if (err) throw err;
});
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:qrcode-tests.ts


示例5: async

const buildRenderParams = async (user?: User, cards?: any[], data?: any) => ({
  site: {
    title: siteTitle,
    admin: adminEmail,
    source: sourceCodeUrl,
    reg: openRegister,
  },
  user: user
    ? {
        ...user,
        ss: {
          ...shadowsocks,
          port: user.connPort,
          encryption: user.connEnc,
          password: user.connPassword,
          uri: new Buffer(
            `${user.connEnc}:${user.connPassword}@${shadowsocks.host}:${
              user.connPort
            }`
          ).toString("base64"),
          qrcode: await makeQrCode(
            "ss://" +
              Buffer.from(
                `${user.connEnc}:${user.connPassword}@${shadowsocks.host}:${
                  user.connPort
                }`
              ).toString("base64")
          ),
        },
        vmess: {
          ...vmess,
          webSocket: {
            ...vmess.webSocket,
            headersJson: JSON.stringify(vmess.webSocket.headers),
          },
          tcpHeaderJson: JSON.stringify(vmess.tcp.header),
          remark: siteTitle,
          id: user.vmessUid,
          aid: user.vmessAlterId,
          link: {
            android: Buffer.from(
              JSON.stringify({
                add: proxyHost,
                aid: user.vmessAlterId,
                host: `${vmess.webSocket.path};${proxyHost}`,
                id: user.vmessUid,
                net: vmess.network,
                port: vmess.port,
                ps: siteTitle,
                tls: vmess.tls.status === "off" ? "" : "tls",
                type:
                  vmess.network === "tcp"
                    ? vmess.tcp.header.type
                    : vmess.network === "kcp"
                    ? vmess.kcp.header.type
                    : "none",
              })
            ).toString("base64"),
            win: Buffer.from(
              JSON.stringify({
                add: proxyHost,
                aid: user.vmessAlterId,
                host: `${vmess.webSocket.path};${proxyHost}`,
                id: user.vmessUid,
                net: vmess.network,
                port: vmess.port,
                ps: siteTitle,
                tls: vmess.tls.status === "off" ? "" : "tls",
                type:
                  vmess.network === "tcp"
                    ? vmess.tcp.header.type
                    : vmess.network === "kcp"
                    ? vmess.kcp.header.type
                    : "none",
              })
            ).toString("base64"),
            shadowrocket: `${Buffer.from(
              `chacha20-poly1305:${user.vmessUid}@${proxyHost}:${vmess.port}`
            ).toString("base64")}?obfsParam=${vmess.webSocket.host}&path=${
              vmess.network === "ws"
                ? vmess.webSocket.path
                : vmess.tcp.header.type
            }&obfs=${
              vmess.network === "ws"
                ? "websocket"
                : vmess.network === "tcp"
                ? vmess.tcp.header.type
                : "none"
            }&tls=${vmess.tls.status === "off" ? 0 : 1}`,
          },
          qrcode: {
            kitsunebi: await makeQrCode(
              "vmess://" +
                Buffer.from(
                  `chacha20-poly1305:${user.vmessUid}@${proxyHost}:${
                    vmess.port
                  }`
                ).toString("base64") +
                `?network=${vmess.network}` +
                (vmess.network === "ws"
//.........这里部分代码省略.........
开发者ID:coderfox,项目名称:Another-SS-Panel,代码行数:101,代码来源:index.ts


示例6: async

const getGuide = async (user: IUser, siteName?: string): Promise<IGuide> => {
  const ssUri =
    "ss://" +
    Buffer.from(
      `${user.ss.encryption}:${user.ss.password}@${user.ss.host}:${
        user.ss.port
      }`
    ).toString("base64");
  const ssQr = await makeQrCode(ssUri);
  return {
    vmess: [
      {
        os: "Android",
        descriptions: [
          {
            title: "下载应用",
            content: "下载客户端并安装(app-universal-release.apk)。",
            links: [
              {
                name: "GitHub",
                href: "https://github.com/2dust/v2rayNG/releases",
              },
            ],
          },
          {
            title: "添加配置",
            content:
              "点击下面的按钮,按照系统提示用应用 v2rayNG 打开,并按照应用提示确认添加。",
            links: [
              {
                name: "配置",
                href:
                  "vmess://" +
                  Buffer.from(
                    JSON.stringify({
                      add: user.vmess.host,
                      aid: user.vmess.aid,
                      host: `${user.vmess.webSocket.path};${
                        user.vmess.webSocket.host
                      }`,
                      id: user.vmess.id,
                      net: user.vmess.network,
                      port: user.vmess.port,
                      ps: siteName,
                      tls: user.vmess.tls.status === "off" ? "" : "tls",
                      type:
                        user.vmess.network === "tcp"
                          ? user.vmess.tcp.header.type
                          : user.vmess.network === "kcp"
                          ? user.vmess.kcp.header.type
                          : "none",
                    })
                  ).toString("base64"),
              },
            ],
          },
          {
            title: "改善配置(可选)",
            content:
              "点击新增的配置文件右侧编辑图标,在弹出的面板内,修改「security」为「chacha20-poly1305」,点击右上角对号保存。",
          },
          {
            title: "设置路由",
            content:
              "点击右上角菜单,选择「Settings」;打开「Bypass Mainland」,(可选)打开「Enable Mux」;返回首页。",
          },
          {
            title: "启动代理",
            content:
              "点击下方纸飞机,待提示「Start Server Success」后即可开始使用网络。个别系统可能会询问权限,请一律允许。",
          },
        ],
      },
      {
        os: "iOS(Kitsunebi)",
        descriptions: [
          {
            title: "下载应用",
            content:
              "在 App Store 购买应用 Kitsunebi(¥12),或申请免费的测试版(需要挂代理访问)。",
            links: [
              {
                name: "App Store",
                href: "https://itunes.apple.com/cn/app/kitsunebi/id1275446921",
              },
              {
                name: "TestFlight",
                href:
                  "https://docs.google.com/forms/d/e/1FAIpQLSekOGRE7cXk3vBTVjlHiv6RJRXfeItZvjQCDRxyigKYq6ChmA/viewform",
              },
            ],
          },
          {
            title: "添加配置",
            content:
              "打开应用,点击左上角📷图标扫描下方二维码;移动设备可以长按保存二维码后,点击左上角📷图标,再点击右上角文件夹图标,从相册中选择二维码图片。",
            qrcode: await makeQrCode(
              "vmess://" +
                Buffer.from(
                  `chacha20-poly1305:${user.vmess.id}@${user.vmess.host}:${
//.........这里部分代码省略.........
开发者ID:coderfox,项目名称:Another-SS-Panel,代码行数:101,代码来源:guide.ts



注:本文中的qrcode.toDataURL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript qrcode-terminal.generate函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs.write函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap