Skip to content

Commit

Permalink
fix: 修复类型问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Miaonster committed Apr 1, 2022
1 parent 1b5b5e2 commit c194f3c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/taro-code-demo/src/pages/index/index.tsx
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-code/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 8 additions & 0 deletions packages/taro-code/src/common/types/image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ImageProps, StandardProps } from '@tarojs/components'

export interface CommonImageProps
extends Pick<
ImageProps,
'lazyLoad' | 'showMenuByLongpress' | 'onLoad' | 'onError'
>,
StandardProps {}
28 changes: 14 additions & 14 deletions packages/taro-code/src/components/Barcode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageProps, 'style' | 'src'>
>(
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,
Expand Down
29 changes: 14 additions & 15 deletions packages/taro-code/src/components/QRCode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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<ImageProps, 'style' | 'src'>
>(
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,
Expand Down

0 comments on commit c194f3c

Please sign in to comment.