mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-13 04:53:11 +08:00
feat: use rc-qrcode instead of qrcode.react (#49454)
* feat: use rc-qrcode instead of qrcode.react * feat: optimize code * feat: update test case --------- Signed-off-by: kiner-tang <1127031143@qq.com>
This commit is contained in:
parent
a5d308b408
commit
ff12f47d18
@ -35,6 +35,7 @@ Array [
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -60,6 +61,7 @@ exports[`renders components/qr-code/demo/base.tsx extend context correctly 1`] =
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -93,6 +95,7 @@ exports[`renders components/qr-code/demo/customColor.tsx extend context correctl
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -106,6 +109,7 @@ exports[`renders components/qr-code/demo/customColor.tsx extend context correctl
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -193,9 +197,11 @@ Array [
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
|
crossorigin="anonymous"
|
||||||
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
||||||
style="display: none;"
|
style="display: none;"
|
||||||
/>
|
/>
|
||||||
@ -215,8 +221,14 @@ exports[`renders components/qr-code/demo/download.tsx extend context correctly 1
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
|
<img
|
||||||
|
crossorigin="anonymous"
|
||||||
|
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
||||||
|
style="display: none;"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-primary"
|
class="ant-btn ant-btn-primary"
|
||||||
@ -239,6 +251,7 @@ Array [
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>,
|
</div>,
|
||||||
@ -319,9 +332,11 @@ exports[`renders components/qr-code/demo/icon.tsx extend context correctly 1`] =
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
|
crossorigin="anonymous"
|
||||||
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
||||||
style="display: none;"
|
style="display: none;"
|
||||||
/>
|
/>
|
||||||
@ -370,6 +385,7 @@ exports[`renders components/qr-code/demo/status.tsx extend context correctly 1`]
|
|||||||
</div>
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -419,6 +435,7 @@ exports[`renders components/qr-code/demo/status.tsx extend context correctly 1`]
|
|||||||
</div>
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -437,6 +454,7 @@ exports[`renders components/qr-code/demo/status.tsx extend context correctly 1`]
|
|||||||
</div>
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -458,6 +476,7 @@ exports[`renders components/qr-code/demo/type.tsx extend context correctly 1`] =
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -471,6 +490,7 @@ exports[`renders components/qr-code/demo/type.tsx extend context correctly 1`] =
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
viewBox="0 0 25 25"
|
viewBox="0 0 25 25"
|
||||||
width="160"
|
width="160"
|
||||||
>
|
>
|
||||||
|
@ -24,6 +24,7 @@ exports[`renders components/qr-code/demo/base.tsx correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -55,6 +56,7 @@ exports[`renders components/qr-code/demo/customColor.tsx correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -68,6 +70,7 @@ exports[`renders components/qr-code/demo/customColor.tsx correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -153,9 +156,11 @@ Array [
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
|
crossorigin="anonymous"
|
||||||
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
||||||
style="display:none"
|
style="display:none"
|
||||||
/>
|
/>
|
||||||
@ -173,8 +178,14 @@ exports[`renders components/qr-code/demo/download.tsx correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
|
<img
|
||||||
|
crossorigin="anonymous"
|
||||||
|
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
||||||
|
style="display:none"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="ant-btn ant-btn-primary"
|
class="ant-btn ant-btn-primary"
|
||||||
@ -195,6 +206,7 @@ Array [
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>,
|
</div>,
|
||||||
@ -273,9 +285,11 @@ exports[`renders components/qr-code/demo/icon.tsx correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
|
crossorigin="anonymous"
|
||||||
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
||||||
style="display:none"
|
style="display:none"
|
||||||
/>
|
/>
|
||||||
@ -322,6 +336,7 @@ exports[`renders components/qr-code/demo/status.tsx correctly 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -371,6 +386,7 @@ exports[`renders components/qr-code/demo/status.tsx correctly 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -389,6 +405,7 @@ exports[`renders components/qr-code/demo/status.tsx correctly 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -408,6 +425,7 @@ exports[`renders components/qr-code/demo/type.tsx correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -421,6 +439,7 @@ exports[`renders components/qr-code/demo/type.tsx correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
viewBox="0 0 25 25"
|
viewBox="0 0 25 25"
|
||||||
width="160"
|
width="160"
|
||||||
>
|
>
|
||||||
|
@ -10,6 +10,7 @@ exports[`QRCode test should correct render 1`] = `
|
|||||||
>
|
>
|
||||||
<canvas
|
<canvas
|
||||||
height="160"
|
height="160"
|
||||||
|
role="img"
|
||||||
width="160"
|
width="160"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,7 +16,12 @@ const downloadQRCode = () => {
|
|||||||
|
|
||||||
const App: React.FC = () => (
|
const App: React.FC = () => (
|
||||||
<div id="myqrcode">
|
<div id="myqrcode">
|
||||||
<QRCode value="https://ant.design/" bgColor="#fff" style={{ marginBottom: 16 }} />
|
<QRCode
|
||||||
|
value="https://ant.design/"
|
||||||
|
bgColor="#fff"
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
icon="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
||||||
|
/>
|
||||||
<Button type="primary" onClick={downloadQRCode}>
|
<Button type="primary" onClick={downloadQRCode}>
|
||||||
Download
|
Download
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import ReloadOutlined from '@ant-design/icons/ReloadOutlined';
|
import ReloadOutlined from '@ant-design/icons/ReloadOutlined';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { QRCodeCanvas, QRCodeSVG } from 'qrcode.react';
|
import { QRCodeCanvas, QRCodeSVG } from '@rc-component/qrcode';
|
||||||
|
|
||||||
import { devUseWarning } from '../_util/warning';
|
import { devUseWarning } from '../_util/warning';
|
||||||
import Button from '../button';
|
import Button from '../button';
|
||||||
@ -45,6 +45,7 @@ const QRCode: React.FC<QRCodeProps> = (props) => {
|
|||||||
height: typeof iconSize === 'number' ? iconSize : iconSize?.height ?? 40,
|
height: typeof iconSize === 'number' ? iconSize : iconSize?.height ?? 40,
|
||||||
width: typeof iconSize === 'number' ? iconSize : iconSize?.width ?? 40,
|
width: typeof iconSize === 'number' ? iconSize : iconSize?.width ?? 40,
|
||||||
excavate: true,
|
excavate: true,
|
||||||
|
crossOrigin: 'anonymous',
|
||||||
};
|
};
|
||||||
|
|
||||||
const qrCodeProps = {
|
const qrCodeProps = {
|
||||||
|
@ -1,30 +1,15 @@
|
|||||||
import type { CSSProperties } from 'react';
|
import type { QRProps } from '@rc-component/qrcode';
|
||||||
|
|
||||||
interface ImageSettings {
|
type ImageSettings = QRProps['imageSettings'];
|
||||||
src: string;
|
|
||||||
height: number;
|
|
||||||
width: number;
|
|
||||||
excavate: boolean;
|
|
||||||
x?: number;
|
|
||||||
y?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface QRProps {
|
export type { QRProps, ImageSettings };
|
||||||
value: string;
|
|
||||||
type?: 'canvas' | 'svg';
|
|
||||||
size?: number;
|
|
||||||
color?: string;
|
|
||||||
style?: CSSProperties;
|
|
||||||
includeMargin?: boolean;
|
|
||||||
imageSettings?: ImageSettings;
|
|
||||||
bgColor?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type QRPropsCanvas = QRProps & React.CanvasHTMLAttributes<HTMLCanvasElement>;
|
export type QRPropsCanvas = QRProps & React.CanvasHTMLAttributes<HTMLCanvasElement>;
|
||||||
|
|
||||||
export type QRPropsSvg = QRProps & React.SVGAttributes<SVGSVGElement>;
|
export type QRPropsSvg = QRProps & React.SVGAttributes<SVGSVGElement>;
|
||||||
|
|
||||||
export interface QRCodeProps extends QRProps, React.HTMLAttributes<HTMLDivElement> {
|
export interface QRCodeProps extends QRProps, React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
type?: 'canvas' | 'svg';
|
||||||
className?: string;
|
className?: string;
|
||||||
rootClassName?: string;
|
rootClassName?: string;
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
|
@ -124,12 +124,12 @@
|
|||||||
"@ctrl/tinycolor": "^3.6.1",
|
"@ctrl/tinycolor": "^3.6.1",
|
||||||
"@rc-component/color-picker": "~1.5.3",
|
"@rc-component/color-picker": "~1.5.3",
|
||||||
"@rc-component/mutate-observer": "^1.1.0",
|
"@rc-component/mutate-observer": "^1.1.0",
|
||||||
|
"@rc-component/qrcode": "~1.0.0",
|
||||||
"@rc-component/tour": "~1.15.0",
|
"@rc-component/tour": "~1.15.0",
|
||||||
"@rc-component/trigger": "^2.2.0",
|
"@rc-component/trigger": "^2.2.0",
|
||||||
"classnames": "^2.5.1",
|
"classnames": "^2.5.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
"dayjs": "^1.11.11",
|
"dayjs": "^1.11.11",
|
||||||
"qrcode.react": "^3.1.0",
|
|
||||||
"rc-cascader": "~3.27.0",
|
"rc-cascader": "~3.27.0",
|
||||||
"rc-checkbox": "~3.3.0",
|
"rc-checkbox": "~3.3.0",
|
||||||
"rc-collapse": "~3.7.3",
|
"rc-collapse": "~3.7.3",
|
||||||
|
Loading…
Reference in New Issue
Block a user