qrcode-alipay 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LEGAL.md ADDED
@@ -0,0 +1,7 @@
1
+ Legal Disclaimer
2
+
3
+ Within this source code, the comments in Chinese shall be the original, governing version. Any comment in other languages are for reference only. In the event of any conflict between the Chinese language version comments and other language version comments, the Chinese language version shall prevail.
4
+
5
+ 法律免责声明
6
+
7
+ 关于代码注释部分,中文注释为官方版本,其它语言注释仅做参考。中文注释可能与其它语言注释存在不一致,当中文注释与其它语言注释存在不一致时,请以中文注释为准。
package/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ Proprietary Limited Use License
2
+
3
+ Copyright (c) Ant Group and/or its affiliates.
4
+ All rights reserved.
5
+
6
+ Permission is hereby granted to install, run, and integrate the packaged
7
+ qrcode-alipay npm artifact solely for generating and displaying
8
+ Alipay-branded QR codes in products or services that are authorized to use
9
+ Alipay payment or checkout capabilities.
10
+
11
+ This license does not grant permission to:
12
+
13
+ 1. copy, publish, redistribute, sublicense, sell, or otherwise make the package
14
+ or any substantial portion of it available as a standalone library;
15
+ 2. modify, reverse engineer, decompile, or create derivative works from the
16
+ package, except to the extent such restriction is prohibited by applicable
17
+ law;
18
+ 3. remove, obscure, or alter any proprietary notice, trademark notice, or
19
+ attribution included in the package;
20
+ 4. use Alipay names, logos, icons, or brand assets except as permitted by the
21
+ applicable Alipay brand, payment, checkout, or integration agreements.
22
+
23
+ The package is provided "as is", without warranty of any kind, express or
24
+ implied, including but not limited to the warranties of merchantability,
25
+ fitness for a particular purpose, and noninfringement. In no event shall the
26
+ copyright holders or their affiliates be liable for any claim, damages, or
27
+ other liability arising from or in connection with the package or its use.
28
+
29
+ If you have a separate written agreement governing use of this package or
30
+ Alipay brand assets, that agreement controls to the extent of any conflict.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # qrcode-alipay
2
+
3
+ 支付宝品牌二维码生成器。默认输出符合支付场景视觉的 SVG 二维码:三个定位点使用支付宝蓝,中间带支付宝「支」logo,核心 API 不依赖 React、Vue 或浏览器 DOM。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add qrcode-alipay
9
+ ```
10
+
11
+ ## 快速使用
12
+
13
+ ```ts
14
+ import { toSvg, toDataURL, createAlipayQRCode } from 'qrcode-alipay';
15
+
16
+ const svg = toSvg('https://qr.alipay.com/example', {
17
+ size: 240,
18
+ title: '支付宝支付二维码',
19
+ });
20
+
21
+ const dataUrl = toDataURL('https://qr.alipay.com/example', {
22
+ size: 240,
23
+ });
24
+
25
+ const descriptor = createAlipayQRCode('https://qr.alipay.com/example');
26
+ ```
27
+
28
+ ## React
29
+
30
+ ```tsx
31
+ import { AlipayQRCode } from 'qrcode-alipay/react';
32
+
33
+ export function PaymentQRCode({ value }: { value: string }) {
34
+ return <AlipayQRCode value={value} size={240} ariaLabel="支付宝支付二维码" />;
35
+ }
36
+ ```
37
+
38
+ ## Vue 3
39
+
40
+ ```vue
41
+ <script setup lang="ts">
42
+ import { AlipayQRCode } from 'qrcode-alipay/vue';
43
+ </script>
44
+
45
+ <template>
46
+ <AlipayQRCode :value="value" :size="240" aria-label="支付宝支付二维码" />
47
+ </template>
48
+ ```
49
+
50
+ ## 配置项
51
+
52
+ 公开配置只覆盖通用渲染能力:
53
+
54
+ | 参数 | 类型 | 默认值 | 说明 |
55
+ | --- | --- | --- | --- |
56
+ | `size` | `number \| string` | `240` | SVG 的宽高。不传时是固定 `240`,不会自动变成 `100%`。 |
57
+ | `margin` | `number` | `0` | 二维码 quiet zone,单位为二维码模块。 |
58
+ | `title` | `string` | - | 写入 SVG 内部的 `<title>`。 |
59
+ | `ariaLabel` | `string` | `Alipay QR code` | SVG 根节点的可访问性描述。 |
60
+ | `className` | `string` | - | SVG 根节点 class。 |
61
+
62
+ 品牌色、中心 logo 和纠错等级默认固定,避免不同业务接入后出现不一致的支付宝支付二维码。
63
+
64
+ 扫码安全建议:如果二维码外层没有白色 padding 或白色卡片容器,建议传 `margin: 1` 或更高;如果外层已经有足够白色留白,保持默认 `margin: 0` 更符合组件布局习惯。
65
+
66
+ 响应式建议:`size` 不传默认是 `240`。如需自适应父容器,请显式传 `size: '100%'`,并确保父容器有稳定的宽高或 `aspect-ratio: 1`。
67
+
68
+ ## 文档
69
+
70
+ 公开使用说明见 [publicDocs/usage.md](./publicDocs/usage.md)。
71
+
72
+ ## 本地开发
73
+
74
+ ```bash
75
+ pnpm install
76
+ pnpm typecheck
77
+ pnpm test
78
+ pnpm build
79
+ pnpm demo
80
+ ```
81
+
82
+ `docs/` 是内部设计与实现文档,不会随 npm 包发布。