fix: 视频播放添加 图片od
This commit is contained in:
parent
b14cb22285
commit
8d1d7bfa1c
@ -52,14 +52,16 @@ export const WindowToggle: React.FC<WindowToggleProps> = (props) => {
|
|||||||
<div className='body'>
|
<div className='body'>
|
||||||
{
|
{
|
||||||
dataSource?.map((item, index) => {
|
dataSource?.map((item, index) => {
|
||||||
|
|
||||||
if (size === "large" && index > 0) return
|
if (size === "large" && index > 0) return
|
||||||
return (
|
return (
|
||||||
<VideoPlayerCard
|
<VideoPlayerCard
|
||||||
key={item.windowKey}
|
key={item.windowKey}
|
||||||
selectedWindowKey={selectedWindowKey}
|
selectedWindowKey={selectedWindowKey}
|
||||||
size={size} {...item}
|
size={size}
|
||||||
handleWindowClick={handleWindowClick}
|
handleWindowClick={handleWindowClick}
|
||||||
handleCloseButtonClick={handleCloseButtonClick}
|
handleCloseButtonClick={handleCloseButtonClick}
|
||||||
|
{...item}
|
||||||
/>)
|
/>)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -48,15 +48,15 @@ export default () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDownloadImg = (imageKey?: string) => {
|
const handleDownloadImg = (imgSrc?: string) => {
|
||||||
console.log(imageKey)
|
console.log(imgSrc)
|
||||||
// 可以调用 下面 方法关闭弹窗
|
// 可以调用 下面 方法关闭弹窗
|
||||||
// viewLargerImageModalRef.current?.handleCancel()
|
// viewLargerImageModalRef.current?.handleCancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onRecordClick = (record?: IRecord) => {
|
const onRecordClick = (record?: IRecord) => {
|
||||||
// 点击的时候把数据 拿过来处理一下传给大图弹框
|
// 点击的时候把数据 拿过来处理一下传给大图弹框
|
||||||
const { imageKey, warningType, boxId, position, cabietId, warningTime, warningTimestamp, warningTimeFormat = 'YYYY-MM-DD HH:mm:ss' } = record || {}
|
const { imgSrc, warningType, boxId, position, cabietId, warningTime, warningTimestamp, warningTimeFormat = 'YYYY-MM-DD HH:mm:ss',odRect= [] } = record || {}
|
||||||
const formattedDate = warningTimestamp ? dayjs(warningTimestamp).format(warningTimeFormat) : '';
|
const formattedDate = warningTimestamp ? dayjs(warningTimestamp).format(warningTimeFormat) : '';
|
||||||
const warningTimeShow = warningTime ? warningTime : formattedDate
|
const warningTimeShow = warningTime ? warningTime : formattedDate
|
||||||
//用于渲染右侧的 信息
|
//用于渲染右侧的 信息
|
||||||
@ -68,7 +68,7 @@ export default () => {
|
|||||||
{ label: '柜子ID', value: cabietId },
|
{ label: '柜子ID', value: cabietId },
|
||||||
]
|
]
|
||||||
// 调用这个方法打开弹框
|
// 调用这个方法打开弹框
|
||||||
viewLargerImageModalRef?.current?.show({ imageKey: imageKey, warningData: warningData })
|
viewLargerImageModalRef?.current?.show({ imgSrc: imgSrc, warningData: warningData ,odRect:odRect})
|
||||||
|
|
||||||
setSelectedRecordId(record?.id)
|
setSelectedRecordId(record?.id)
|
||||||
}
|
}
|
||||||
@ -89,7 +89,8 @@ export default () => {
|
|||||||
// 模拟 视频数据请求
|
// 模拟 视频数据请求
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// 对后端返回数据进行处理 组装一套符合属性的 数据
|
// 对后端返回数据进行处理 组装一套符合属性的 数据
|
||||||
const newVideoData: VideoPlayerCardProps = { imageKey: videoData.imageKey, title: videoData.title, }
|
debugger
|
||||||
|
const newVideoData: VideoPlayerCardProps = { imgSrc: videoData.imgSrc, title: videoData.title, odRect: videoData.odRect }
|
||||||
setVideoDataSource((pre) => {
|
setVideoDataSource((pre) => {
|
||||||
const newVideoDataSource: VideoPlayerCardProps[] = pre.map((item) => {
|
const newVideoDataSource: VideoPlayerCardProps[] = pre.map((item) => {
|
||||||
// 传给 选中的视频窗口
|
// 传给 选中的视频窗口
|
||||||
@ -121,7 +122,7 @@ export default () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const newWarningDataSource: IRecord[] = warningData.map(o => {
|
const newWarningDataSource: IRecord[] = warningData.map(o => {
|
||||||
return {
|
return {
|
||||||
imageKey: o.imageKey,
|
imgSrc: o.imgSrc,
|
||||||
id: o.id,
|
id: o.id,
|
||||||
warningType: o.warningType,
|
warningType: o.warningType,
|
||||||
boxId: o.boxId,
|
boxId: o.boxId,
|
||||||
@ -131,6 +132,7 @@ export default () => {
|
|||||||
warningInfo: [`盒子${o.boxId}`, `位置${o.position}`, `柜子ID${o.cabietId}`],
|
warningInfo: [`盒子${o.boxId}`, `位置${o.position}`, `柜子ID${o.cabietId}`],
|
||||||
// cabietText: `柜子ID: ${o.cabietId}`,
|
// cabietText: `柜子ID: ${o.cabietId}`,
|
||||||
warningTimestamp: o.warningTimestamp,
|
warningTimestamp: o.warningTimestamp,
|
||||||
|
odRect: o.odRect
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setWarningDataSource(newWarningDataSource)
|
setWarningDataSource(newWarningDataSource)
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
export const videoData = {
|
export const videoData = {
|
||||||
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
||||||
// videoSrc: 'ws://10.0.0.7:9033/flv/File/test/test_h264_1.mp4.flv?ip=127.0.0.1',
|
// videoSrc: 'ws://10.0.0.7:9033/flv/File/test/test_h264_1.mp4.flv?ip=127.0.0.1',
|
||||||
title: `盒子1 点位1`
|
title: `盒子1 点位1`,
|
||||||
|
odRect: [{
|
||||||
|
// "id": "456",
|
||||||
|
"x": 0.1519352,
|
||||||
|
"y": 0.2965385,
|
||||||
|
"w": 0.05185461,
|
||||||
|
"h": 0.24698898,
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const warningData = [
|
export const warningData = [
|
||||||
@ -15,6 +22,13 @@ export const warningData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
|
odRect: [{
|
||||||
|
// "id": "456",
|
||||||
|
"x": 0.1519352,
|
||||||
|
"y": 0.2965385,
|
||||||
|
"w": 0.05185461,
|
||||||
|
"h": 0.24698898,
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
||||||
@ -26,6 +40,13 @@ export const warningData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
|
odRect: [{
|
||||||
|
// "id": "456",
|
||||||
|
"x": 0.1519352,
|
||||||
|
"y": 0.2965385,
|
||||||
|
"w": 0.05185461,
|
||||||
|
"h": 0.24698898,
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
||||||
@ -37,6 +58,13 @@ export const warningData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
|
odRect: [{
|
||||||
|
// "id": "456",
|
||||||
|
"x": 0.1519352,
|
||||||
|
"y": 0.2965385,
|
||||||
|
"w": 0.05185461,
|
||||||
|
"h": 0.24698898,
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
||||||
@ -48,6 +76,13 @@ export const warningData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
|
odRect: [{
|
||||||
|
// "id": "456",
|
||||||
|
"x": 0.1519352,
|
||||||
|
"y": 0.2965385,
|
||||||
|
"w": 0.05185461,
|
||||||
|
"h": 0.24698898,
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
imgSrc: 'https://i.yourimageshare.com/lRHiD2UnAT.png',
|
||||||
@ -59,6 +94,13 @@ export const warningData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
|
odRect: [{
|
||||||
|
// "id": "456",
|
||||||
|
"x": 0.1519352,
|
||||||
|
"y": 0.2965385,
|
||||||
|
"w": 0.05185461,
|
||||||
|
"h": 0.24698898,
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Card, Space, CardProps, Spin, Button } from 'antd';
|
import { Card, Space, CardProps, Spin, Button } from 'antd';
|
||||||
import { theme } from 'antd/lib';
|
import { theme } from 'antd/lib';
|
||||||
import { ConfigProvider, VideoPlayer, type VideoViewRef, } from '@zhst/meta';
|
import { ConfigProvider, VideoPlayer, CropperImage, type VideoViewRef, } from '@zhst/meta';
|
||||||
|
|
||||||
import React, { useState, useEffect, ReactNode, useRef, useContext } from 'react';
|
import React, { useState, useEffect, ReactNode, useRef, useContext } from 'react';
|
||||||
import { CloseOutlined, LoadingOutlined } from '@ant-design/icons';
|
import { CloseOutlined, LoadingOutlined } from '@ant-design/icons';
|
||||||
import './index.less'
|
import './index.less'
|
||||||
@ -18,6 +19,14 @@ export interface VideoPlayerCardProps {
|
|||||||
title?: string | ReactNode
|
title?: string | ReactNode
|
||||||
handleCloseButtonClick?: (key?: string) => void;
|
handleCloseButtonClick?: (key?: string) => void;
|
||||||
handleWindowClick?: (key?: string) => void;
|
handleWindowClick?: (key?: string) => void;
|
||||||
|
odRect?: {
|
||||||
|
id?: string;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
w: number;
|
||||||
|
h: number;
|
||||||
|
selectAble?: boolean;
|
||||||
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const VideoPlayerCard: React.FC<VideoPlayerCardProps> = (props) => {
|
export const VideoPlayerCard: React.FC<VideoPlayerCardProps> = (props) => {
|
||||||
@ -25,12 +34,16 @@ export const VideoPlayerCard: React.FC<VideoPlayerCardProps> = (props) => {
|
|||||||
|
|
||||||
const { ConfigContext } = ConfigProvider;
|
const { ConfigContext } = ConfigProvider;
|
||||||
const { getPrefixCls } = useContext(ConfigContext);
|
const { getPrefixCls } = useContext(ConfigContext);
|
||||||
const { prefixCls: customizePrefixCls, showType, imgSrc, videoSrc, cardProps, isWindowLoading, errorReasonText, size, title, handleCloseButtonClick, handleWindowClick, windowKey, selectedWindowKey = '' } = props;
|
const { prefixCls: customizePrefixCls, showType, imgSrc, videoSrc, cardProps, isWindowLoading, errorReasonText, size, title, handleCloseButtonClick, handleWindowClick, windowKey, selectedWindowKey = '',odRect = [] } = props;
|
||||||
const componentName = getPrefixCls('biz-video-player-card', customizePrefixCls);
|
const componentName = getPrefixCls('biz-video-player-card', customizePrefixCls);
|
||||||
const [cardContent, setCardContent] = useState<JSX.Element | null>(null);
|
const [cardContent, setCardContent] = useState<JSX.Element | null>(null);
|
||||||
const { useToken } = theme
|
const { useToken } = theme
|
||||||
const { token } = useToken()
|
const { token } = useToken()
|
||||||
const videoRef = useRef<VideoViewRef>(null)
|
const videoRef = useRef<VideoViewRef>(null)
|
||||||
|
const odRectDefault = odRect?.map(rect => ({
|
||||||
|
...rect,
|
||||||
|
selectAble: rect.hasOwnProperty('selectAble') ? rect.selectAble : false
|
||||||
|
}));
|
||||||
const selectedBorderStyle = {
|
const selectedBorderStyle = {
|
||||||
border: `2px solid ${token.colorPrimary}`, boxShadow: " 0px 2px 9px 0px rgba(0,0,0,0.16)"
|
border: `2px solid ${token.colorPrimary}`, boxShadow: " 0px 2px 9px 0px rgba(0,0,0,0.16)"
|
||||||
}
|
}
|
||||||
@ -51,11 +64,15 @@ export const VideoPlayerCard: React.FC<VideoPlayerCardProps> = (props) => {
|
|||||||
|
|
||||||
} else if (imgSrc) {
|
} else if (imgSrc) {
|
||||||
contentElement = (
|
contentElement = (
|
||||||
<img
|
|
||||||
alt="首帧图"
|
<div style={{ width: "100%", height: "100%", display: 'block' }}>
|
||||||
src={imgSrc}
|
<CropperImage
|
||||||
style={{ width: "100%", height: "100%", display: 'block' }}
|
// editAble={true}
|
||||||
|
odList={odRectDefault}
|
||||||
|
url={imgSrc}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
setCardContent(contentElement);
|
setCardContent(contentElement);
|
||||||
|
@ -7,7 +7,7 @@ import { ConfigProvider,CropperImage} from '@zhst/meta';
|
|||||||
import './index.less'
|
import './index.less'
|
||||||
|
|
||||||
type ViewLargerImageModalParams = {
|
type ViewLargerImageModalParams = {
|
||||||
imageKey?: string;
|
imgSrc?: string;
|
||||||
warningData?: {
|
warningData?: {
|
||||||
label?: string;
|
label?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
@ -30,7 +30,7 @@ export interface ViewLargerImageModalRef {
|
|||||||
export interface ViewLargerImageModalProps {
|
export interface ViewLargerImageModalProps {
|
||||||
prefixCls?: string
|
prefixCls?: string
|
||||||
imgStyle?: React.CSSProperties;
|
imgStyle?: React.CSSProperties;
|
||||||
downloadImg?: (imageKey?: string) => void;
|
downloadImg?: (imgSrc?: string) => void;
|
||||||
title?: string;
|
title?: string;
|
||||||
downloadText?: string;
|
downloadText?: string;
|
||||||
modalProps?: ModalProps
|
modalProps?: ModalProps
|
||||||
@ -49,7 +49,7 @@ export const ViewLargerImageModal = forwardRef<ViewLargerImageModalRef, ViewLarg
|
|||||||
const { useToken } = theme
|
const { useToken } = theme
|
||||||
const { token } = useToken()
|
const { token } = useToken()
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
const [imageKey, setimageKey] = useState<string>();
|
const [imgSrc, setimgSrc] = useState<string>();
|
||||||
const [odRect, setOdRect] = useState<ViewLargerImageModalParams['odRect']>();
|
const [odRect, setOdRect] = useState<ViewLargerImageModalParams['odRect']>();
|
||||||
const [warningData, setWarningData] = useState<ViewLargerImageModalParams['warningData']>();
|
const [warningData, setWarningData] = useState<ViewLargerImageModalParams['warningData']>();
|
||||||
const odRectDefault = odRect?.map(rect => ({
|
const odRectDefault = odRect?.map(rect => ({
|
||||||
@ -65,7 +65,7 @@ export const ViewLargerImageModal = forwardRef<ViewLargerImageModalRef, ViewLarg
|
|||||||
return {
|
return {
|
||||||
show: (_params) => {
|
show: (_params) => {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
setimageKey(_params?.imageKey)
|
setimgSrc(_params?.imgSrc)
|
||||||
setWarningData(_params?.warningData)
|
setWarningData(_params?.warningData)
|
||||||
setOdRect(_params?.odRect)
|
setOdRect(_params?.odRect)
|
||||||
},
|
},
|
||||||
@ -90,7 +90,7 @@ export const ViewLargerImageModal = forwardRef<ViewLargerImageModalRef, ViewLarg
|
|||||||
<CropperImage
|
<CropperImage
|
||||||
// editAble={true}
|
// editAble={true}
|
||||||
odList={odRectDefault}
|
odList={odRectDefault}
|
||||||
url={imageKey}
|
url={imgSrc}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -101,7 +101,7 @@ export const ViewLargerImageModal = forwardRef<ViewLargerImageModalRef, ViewLarg
|
|||||||
{value}
|
{value}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{imageKey && downloadImg && <div className='img-download' style={{ color: token.colorPrimary }} onClick={() => downloadImg?.(imageKey)} ><DownloadOutlined /><span style={{ paddingLeft: 3 }}>{downloadText}</span></div>}
|
{imgSrc && downloadImg && <div className='img-download' style={{ color: token.colorPrimary }} onClick={() => downloadImg?.(imgSrc)} ><DownloadOutlined /><span style={{ paddingLeft: 3 }}>{downloadText}</span></div>}
|
||||||
</div>
|
</div>
|
||||||
</Space>
|
</Space>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
Loading…
Reference in New Issue
Block a user