nicecode-v2/packages/biz/src/BigImage/demo/index.tsx

72 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useEffect, useRef, useState } from 'react';
import { BigImage } from '@zhst/biz'
import { Space, Switch } from '@zhst/meta'
import { pick, get } from '@zhst/func'
import { BIG_IMAGE_DATA, attributeList } from '../mock'
import Img from './imgs/photo-1503185912284-5271ff81b9a8.webp'
const BigModal = (props: any) => {
const {
} = props
const [dataSource, setDataSource] = useState(BIG_IMAGE_DATA)
const [showDesc, setShowDesc] = useState(true)
const [type, setType] = useState('normal')
const modalRef = useRef(null)
return (
<div style={{ padding: '32px', border: '1px solid #09f' }}>
<Space>
<span><Switch value={showDesc} onChange={e => setShowDesc(pre => !pre)} /></span>
</Space>
<BigImage
type={type}
ref={modalRef}
width={896}
viewHeight={'440px'}
showModeChange
onTabChange={(newVal) => setType(newVal === '1'? 'normal': 'compater')}
// ------------ 属性列表 -----------------
showDescription={showDesc}
descriptionList={attributeList}
// ------------ 图片/视频切换 -----------------
viewTopModeButtonList={[
{
key: 'image',
label: '图片'
},
{
key: 'video',
label: '视频'
}
]}
modeButtonGroupProps={{
defaultValue: 'image',
onChange: e => console.log('模式切换', e)
}}
// ------------ 导航功能 -----------------
showNavigation
onPrevButtonClick={val => console.log('pre', val)}
onNextButtonClick={val => console.log('next', val)}
// ------------ 场景图功能 -----------------
cropperImageProps={{
url: Img,
score: 50,
odList: get(dataSource, 'odRect', []),
attachImageData: get(dataSource, 'attachImg', []),
}}
// ------------ 对比图模式 -----------------
combineImageProps={{
data: pick(dataSource, 'compaterImage', 'imgSummary', 'imageKey', 'score'),
}}
// ------------ 视频模块 -----------------
videoProps={{
url: get(dataSource, 'flvUrl', '')
}}
>
</BigImage>
</div>
)
}
export default BigModal