diff --git a/packages/taro-code-demo/src/pages/index/index.tsx b/packages/taro-code-demo/src/pages/index/index.tsx index dc30524..4323e56 100644 --- a/packages/taro-code-demo/src/pages/index/index.tsx +++ b/packages/taro-code-demo/src/pages/index/index.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef, useState } from 'react' import { View } from '@tarojs/components' -import { Barcode, QRCode } from '../../../../taro-code/lib' +import { Barcode, QRCode } from '../../../../taro-code/dist' import './index.css' const Index: React.FC = () => { diff --git a/packages/taro-code/package.json b/packages/taro-code/package.json index 0313323..28422f7 100644 --- a/packages/taro-code/package.json +++ b/packages/taro-code/package.json @@ -1,6 +1,6 @@ { "name": "taro-code", - "version": "3.5.0", + "version": "3.5.1", "description": "Taro.js barcode & qrcode", "browser": "dist/index.umd.js", "module": "dist/index.esm.js", diff --git a/packages/taro-code/src/common/types/image.ts b/packages/taro-code/src/common/types/image.ts new file mode 100644 index 0000000..07e2957 --- /dev/null +++ b/packages/taro-code/src/common/types/image.ts @@ -0,0 +1,8 @@ +import { ImageProps, StandardProps } from '@tarojs/components' + +export interface CommonImageProps + extends Pick< + ImageProps, + 'lazyLoad' | 'showMenuByLongpress' | 'onLoad' | 'onError' + >, + StandardProps {} diff --git a/packages/taro-code/src/components/Barcode/index.tsx b/packages/taro-code/src/components/Barcode/index.tsx index 7218bf9..2d4a8ce 100644 --- a/packages/taro-code/src/components/Barcode/index.tsx +++ b/packages/taro-code/src/components/Barcode/index.tsx @@ -4,22 +4,22 @@ import React, { useImperativeHandle, useMemo, } from 'react' -import { Image, ImageProps } from '@tarojs/components' +import { Image } from '@tarojs/components' +import { CommonImageProps } from '../../common/types/image' import barcode from '../../common/barcode' -const Barcode = forwardRef< - { image: string }, - { - className?: string - text: string - scale?: number - width?: number - height?: number - style?: CSSProperties - foregroundColor?: string - backgroundColor?: string - } & Omit ->( +export interface BarcodeProps extends CommonImageProps { + className?: string + text: string + scale?: number + width?: number + height?: number + style?: CSSProperties + foregroundColor?: string + backgroundColor?: string +} + +const Barcode = forwardRef<{ image: string }, BarcodeProps>( ( { className, diff --git a/packages/taro-code/src/components/QRCode/index.tsx b/packages/taro-code/src/components/QRCode/index.tsx index 18e0daa..b2da6f6 100644 --- a/packages/taro-code/src/components/QRCode/index.tsx +++ b/packages/taro-code/src/components/QRCode/index.tsx @@ -5,7 +5,7 @@ import React, { useImperativeHandle, } from 'react' import { Image } from '@tarojs/components' -import { ImageProps } from '@tarojs/components/types/Image' +import { CommonImageProps } from '../../common/types/image' import { createQrCodeImg } from '../../common/qrcode' type TypeNumber = @@ -50,20 +50,19 @@ type TypeNumber = | 39 | 40 -const QRCode = forwardRef< - { image: string }, - { - className?: string - text: string - size?: number - scale?: number - style?: CSSProperties - errorCorrectLevel?: 'L' | 'M' | 'Q' | 'H' - typeNumber?: TypeNumber - foregroundColor?: string - backgroundColor?: string - } & Omit ->( +export interface QRCodeProps extends CommonImageProps { + className?: string + text: string + size?: number + scale?: number + style?: CSSProperties + errorCorrectLevel?: 'L' | 'M' | 'Q' | 'H' + typeNumber?: TypeNumber + foregroundColor?: string + backgroundColor?: string +} + +const QRCode = forwardRef<{ image: string }, QRCodeProps>( ( { className,