feat: 暂存
This commit is contained in:
parent
1fdceb89b1
commit
3cdb025883
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -3,6 +3,7 @@
|
||||
"ahooks",
|
||||
"antd",
|
||||
"COMPATER",
|
||||
"constract",
|
||||
"favicons",
|
||||
"flvjs",
|
||||
"indicatorsize",
|
||||
|
@ -1,9 +1,9 @@
|
||||
// @ts-nocheck
|
||||
import React, { useRef, useState } from 'react'
|
||||
import { ConfigProvider, Descriptions, Modal, Tabs, Button, BigImagePreview } from '@zhst/meta';
|
||||
import React, { forwardRef, useImperativeHandle, useRef, useState, useEffect } from 'react'
|
||||
import { ConfigProvider, Descriptions, Modal, Tabs, Button, BigImagePreview, VideoPlayer } from '@zhst/meta';
|
||||
import classNames from 'classnames'
|
||||
import type { ModalProps, DescriptionsProps, TabsProps } from '@zhst/meta'
|
||||
import { get } from '@zhst/func';
|
||||
import type { ModalProps, DescriptionsProps, TabsProps, VideoViewRef, ImgViewRef } from '@zhst/meta'
|
||||
import { get, isEmpty } from '@zhst/func';
|
||||
import { MODEL_TYPE, TAB_TYPE } from '@zhst/types';
|
||||
import './index.less'
|
||||
import Navigation from './components/navigation';
|
||||
@ -16,208 +16,270 @@ export const componentPrefix = 'zhst-image'
|
||||
|
||||
export interface BigImageModalProps extends ModalProps {
|
||||
visible: boolean // 弹框显示隐藏
|
||||
descriptionConfig: {
|
||||
data: { // 描述列表
|
||||
title: string; // 标题
|
||||
children: Pick<DescriptionsProps, 'items'> // 描述项
|
||||
}[]
|
||||
activeTab?: TAB_TYPE // 当前 tab
|
||||
attributeList: {
|
||||
title: string;
|
||||
children: Pick<DescriptionsProps, 'items'>
|
||||
}
|
||||
tabsConfig: { // 导航栏配置
|
||||
tabs: { // 导航栏配置
|
||||
data: Pick<TabsProps, 'items'> & {
|
||||
key: TAB_TYPE
|
||||
key: TAB_TYPE // !! TRACK 模式已废弃、新增:VIDEO 模式
|
||||
} // 导航栏列表
|
||||
}
|
||||
dataSource: any
|
||||
imageData: any
|
||||
|
||||
relatedData: any
|
||||
mode?: MODEL_TYPE
|
||||
changeMode?: (mode: MODEL_TYPE) => void
|
||||
isRelated?: boolean
|
||||
|
||||
footer?: React.ReactNode
|
||||
showCarousel?: boolean
|
||||
|
||||
onTabChange?: (newVal?: TAB_TYPE, oldVal?: TAB_TYPE) => void
|
||||
onIndexChange?: (newVal?: number, oldVal?: number) => void
|
||||
transformPropFunc: (data: any) => void // 格式化数据方法
|
||||
}
|
||||
|
||||
interface BigModalRef {
|
||||
tab: TAB_TYPE
|
||||
setTab: (tab: TAB_TYPE) => void
|
||||
modalRef: ModalProps
|
||||
activeKey: string
|
||||
setActiveKey: (val: string) => void
|
||||
videoPlayerRef: VideoViewRef
|
||||
combineImageRef: any
|
||||
bigImagePreviewRef: ImgViewRef
|
||||
}
|
||||
|
||||
const initialStyle ={
|
||||
fontSize: '12px'
|
||||
}
|
||||
|
||||
const BigImageModal: React.FC<BigImageModalProps> = (props) => {
|
||||
const BigImageModal: React.FC<BigImageModalProps, BigModalRef> = forwardRef((props, ref) => {
|
||||
const {
|
||||
// 配置
|
||||
title = '-',
|
||||
open,
|
||||
visible,
|
||||
children,
|
||||
descriptionConfig = {
|
||||
data: []
|
||||
},
|
||||
dataSource = [],
|
||||
activeTab,
|
||||
attributeList = [],
|
||||
isRelated = false,
|
||||
tabs = {},
|
||||
footer = null,
|
||||
showCarousel = true,
|
||||
// 数据
|
||||
dataSource = [], // 总数据源,只允许有一份
|
||||
imageData = [],
|
||||
relatedData = [],
|
||||
mode = 'IMAGE',
|
||||
changeMode
|
||||
// 事件
|
||||
onIndexChange,
|
||||
onTabChange,
|
||||
transformPropFunc
|
||||
} = props
|
||||
|
||||
const tabsConfig = {
|
||||
const combineImageRef = useRef(null)
|
||||
const bigImagePreviewRef = useRef(null)
|
||||
const videoPlayerRef = useRef(null)
|
||||
const modalRef = useRef(null)
|
||||
|
||||
// ========================== 头切换 =========================
|
||||
const [tab, setTab] = useState<TAB_TYPE>(activeTab || get(tabsConfig, 'data[0].key'));
|
||||
const [activeKey, setActiveKey] = useState<string>('related');
|
||||
|
||||
// ========================= 预览切换下标 =========================
|
||||
const [currentIndex, setCurrentIndex] = useState<number>(0)
|
||||
|
||||
const tabsConfig = !isEmpty(tabs) ? tabs : {
|
||||
data: [
|
||||
{
|
||||
label: '对比图模式',
|
||||
key: '1',
|
||||
key: 'COMPATER',
|
||||
children: (
|
||||
<CombineImage
|
||||
targetData={dataSource}
|
||||
compareData={dataSource}
|
||||
ref={combineImageRef}
|
||||
data={dataSource[currentIndex] || {}}
|
||||
/>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: '场景图模式',
|
||||
key: '2',
|
||||
key: 'NORMAL',
|
||||
children: (
|
||||
<BigImagePreview
|
||||
ref={bigImagePreviewRef}
|
||||
height={'500px'}
|
||||
dataSource={BIG_IMAGE_DATA}
|
||||
data={dataSource[currentIndex]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const showCropRef = useRef(false);
|
||||
const scaleRef = useRef(0);
|
||||
|
||||
// ========================== 头切换 =========================
|
||||
const [tab, setTab] = useState<TAB_TYPE>(get(tabsConfig, 'data[0].key'));
|
||||
const [activeKey, setActiveKey] = useState<string>('related');
|
||||
// TODO: 页面初始化
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
let data: any = {};
|
||||
// if (isRelated) {
|
||||
// data = await transformPropFunc(imageData[currentIndex]);
|
||||
// } else {
|
||||
// data = await transformPropFunc(dataSource[currentIndex]);
|
||||
// }
|
||||
// setAttributeList(get(data, 'attributeList', []));
|
||||
//防背推
|
||||
// if (currentIndex === latestSelectIndex.current) {
|
||||
// setSelectItem(data);
|
||||
// }
|
||||
})();
|
||||
}, [currentIndex, dataSource, imageData, isRelated]);
|
||||
|
||||
// ========================= 预览切换下标 =========================
|
||||
const [previewIndex, setPreviewIndex] = useState<number>(0)
|
||||
const [isRelated, setIsRelated] = useState<number>(false)
|
||||
|
||||
// ========================= 模式切换 ============================
|
||||
const [currentMode, setCurrentMode] = useState(mode)
|
||||
// 暴露 ref 实例
|
||||
useImperativeHandle(ref, () => ({
|
||||
ref,
|
||||
tab,
|
||||
setTab,
|
||||
modalRef,
|
||||
activeKey,
|
||||
setActiveKey,
|
||||
videoPlayerRef,
|
||||
combineImageRef,
|
||||
bigImagePreviewRef,
|
||||
}));
|
||||
|
||||
return (
|
||||
<Modal
|
||||
destroyOnClose
|
||||
open={open || visible}
|
||||
footer={null}
|
||||
open={open}
|
||||
ref={modalRef}
|
||||
footer={footer}
|
||||
className={componentPrefix}
|
||||
title={title}
|
||||
{...props}
|
||||
>
|
||||
<ConfigProvider
|
||||
theme={{
|
||||
token: {
|
||||
colorTextSecondary: 'rgba(0,0,0,0.45)'
|
||||
},
|
||||
components: {
|
||||
Descriptions: {
|
||||
titleMarginBottom: '20px',
|
||||
viewBg: '#f6f6f6',
|
||||
titleColor: 'rgba(0,0,0,0.45)',
|
||||
colorTextLabel: 'rgba(0,0,0,0.45)',
|
||||
contentColor: 'rgba(0,0,0,0.88)',
|
||||
},
|
||||
},
|
||||
<div
|
||||
style={{
|
||||
marginTop: '16px'
|
||||
}}
|
||||
>
|
||||
{descriptionConfig.data.map(descriptions => (
|
||||
<Descriptions
|
||||
key={descriptions.title}
|
||||
title={
|
||||
<p style={{ margin: '12px 0 0', fontSize: initialStyle.fontSize }}>
|
||||
{descriptions.title}
|
||||
</p>
|
||||
}
|
||||
column={8}
|
||||
style={{ padding: '0 64px' }}
|
||||
>
|
||||
{descriptions?.children?.map(item => (
|
||||
<DescriptionsItem
|
||||
key={item.key}
|
||||
label={item.label}
|
||||
span={1}
|
||||
contentStyle={{ fontSize: initialStyle.fontSize }}
|
||||
labelStyle={{ fontSize: initialStyle.fontSize }}
|
||||
>{item.children}</DescriptionsItem>
|
||||
))}
|
||||
</Descriptions>
|
||||
))}
|
||||
</ConfigProvider>
|
||||
<div
|
||||
className={classNames(`${componentPrefix}-view-container`)}
|
||||
style={
|
||||
tab === 'TRACK'
|
||||
? {
|
||||
height: '718px',
|
||||
marginBottom: '0px',
|
||||
<ConfigProvider
|
||||
theme={{
|
||||
token: {
|
||||
colorTextSecondary: 'rgba(0,0,0,0.45)'
|
||||
},
|
||||
components: {
|
||||
Descriptions: {
|
||||
titleMarginBottom: '20px',
|
||||
viewBg: '#f6f6f6',
|
||||
titleColor: 'rgba(0,0,0,0.45)',
|
||||
colorTextLabel: 'rgba(0,0,0,0.45)',
|
||||
contentColor: 'rgba(0,0,0,0.88)',
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
{attributeList.map(descriptions => (
|
||||
<Descriptions
|
||||
key={descriptions.title}
|
||||
title={
|
||||
<p style={{ margin: '12px 0 0', fontSize: initialStyle.fontSize }}>
|
||||
{descriptions.title}
|
||||
</p>
|
||||
}
|
||||
: {}
|
||||
}
|
||||
>
|
||||
<Tabs
|
||||
activeKey={tab}
|
||||
centered
|
||||
onChange={v => setTab(v)}
|
||||
tabBarStyle={{ fontSize: '18px', fontWeight:'bold' }}
|
||||
items={tabsConfig.data}
|
||||
{...tabsConfig}
|
||||
/>
|
||||
{/* 切换按钮组件 */}
|
||||
{
|
||||
tab !== 'TRACK' && (
|
||||
<>
|
||||
{/* ----------------------------------- 上一张按钮 ---------------------------------- */}
|
||||
<Navigation
|
||||
className={classNames(
|
||||
`${componentPrefix}-view-container__nav`,
|
||||
previewIndex <= 0 && `${componentPrefix}-view-container__nav--disabled`,
|
||||
`${componentPrefix}-view-container__nav--left`
|
||||
)}
|
||||
show={isRelated ? (imageData.length > 1) : (dataSource.length > 1)}
|
||||
disabled={previewIndex <= 0}
|
||||
prev
|
||||
onClick={() => {
|
||||
setPreviewIndex((pre) => pre - 1);
|
||||
column={8}
|
||||
style={{ padding: '0 64px' }}
|
||||
>
|
||||
{descriptions?.children?.map(item => (
|
||||
<DescriptionsItem
|
||||
key={item.key}
|
||||
label={item.label}
|
||||
span={1}
|
||||
contentStyle={{ fontSize: initialStyle.fontSize }}
|
||||
labelStyle={{ fontSize: initialStyle.fontSize }}
|
||||
>{item.children}</DescriptionsItem>
|
||||
))}
|
||||
</Descriptions>
|
||||
))}
|
||||
</ConfigProvider>
|
||||
<div
|
||||
className={classNames(`${componentPrefix}-view-container`)}
|
||||
>
|
||||
<Tabs
|
||||
activeKey={tab}
|
||||
centered
|
||||
destroyInactiveTabPane
|
||||
onChange={v => {
|
||||
setTab(pre => {
|
||||
onTabChange?.(v, pre)
|
||||
return v
|
||||
})
|
||||
}}
|
||||
tabBarStyle={{ fontSize: '18px', fontWeight:'bold' }}
|
||||
items={tabsConfig.data}
|
||||
{...tabsConfig}
|
||||
/>
|
||||
{/* --------------------------------- 视频播放模式 --------------------------------- */}
|
||||
{tab === 'VIDEO' && (
|
||||
<VideoPlayer ref={videoPlayerRef} url={dataSource[currentIndex]?.flvUrl} />
|
||||
)}
|
||||
{/* 切换按钮组件 */}
|
||||
{/* ----------------------------------- 上一张按钮 ---------------------------------- */}
|
||||
<Navigation
|
||||
className={classNames(
|
||||
`${componentPrefix}-view-container__nav`,
|
||||
currentIndex <= 0 && `${componentPrefix}-view-container__nav--disabled`,
|
||||
`${componentPrefix}-view-container__nav--left`
|
||||
)}
|
||||
show={isRelated ? (imageData.length > 1) : (dataSource.length > 1)}
|
||||
disabled={currentIndex <= 0}
|
||||
prev
|
||||
onClick={() => {
|
||||
setCurrentIndex((pre) => {
|
||||
onIndexChange?.(pre - 1, pre)
|
||||
return pre - 1
|
||||
});
|
||||
}}
|
||||
/>
|
||||
{/* ----------------------------------- 下一张按钮 ---------------------------------- */}
|
||||
<Navigation
|
||||
className={classNames(
|
||||
`${componentPrefix}-view-container__nav`,
|
||||
((currentIndex >= imageData.length - 1) || (currentIndex >= dataSource.length - 1)) && `${componentPrefix}-view-container__nav--disabled`,
|
||||
`${componentPrefix}-view-container__nav--right`
|
||||
)}
|
||||
show={isRelated ? (imageData.length > 1) : (dataSource.length > 1)}
|
||||
disabled={((currentIndex >= imageData.length - 1) || (currentIndex >= dataSource.length - 1))}
|
||||
next
|
||||
onClick={async (e) => {
|
||||
setCurrentIndex((pre) => {
|
||||
onIndexChange?.(pre + 1, pre)
|
||||
return pre + 1
|
||||
});
|
||||
}}
|
||||
/>
|
||||
{/* --------------------------------- 模型碰撞组件 --------------------------------- */}
|
||||
{/* {isRelated && (
|
||||
<div className="relatedWrapper">
|
||||
<Tabs
|
||||
className="relatedTabs"
|
||||
tabPosition={'left'}
|
||||
activeKey={activeKey}
|
||||
onChange={(key: string) => {
|
||||
setActiveKey(key);
|
||||
}}
|
||||
items={tabList.map((item) => {
|
||||
return {
|
||||
label: item.label,
|
||||
key: item.key,
|
||||
children: item.children,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
{/* ----------------------------------- 下一张按钮 ---------------------------------- */}
|
||||
<Navigation
|
||||
className={classNames(
|
||||
`${componentPrefix}-view-container__nav`,
|
||||
((previewIndex >= imageData.length - 1) || (previewIndex >= dataSource.length - 1)) && `${componentPrefix}-view-container__nav--disabled`,
|
||||
`${componentPrefix}-view-container__nav--right`
|
||||
)}
|
||||
show={isRelated ? (imageData.length > 1) : (dataSource.length > 1)}
|
||||
disabled={((previewIndex >= imageData.length - 1) || (previewIndex >= dataSource.length - 1))}
|
||||
next
|
||||
onClick={async (e) => {
|
||||
setPreviewIndex((pre) => pre + 1);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
{/* --------------------------------- 模型碰撞组件 --------------------------------- */}
|
||||
{isRelated && tab !== 'TRACK' && (
|
||||
<div className="relatedWrapper">
|
||||
<Tabs
|
||||
className="relatedTabs"
|
||||
tabPosition={'left'}
|
||||
activeKey={activeKey}
|
||||
onChange={(key: string) => {
|
||||
setActiveKey(key);
|
||||
}}
|
||||
items={tabList.map((item) => {
|
||||
return {
|
||||
label: item.label,
|
||||
key: item.key,
|
||||
children: item.children,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)} */}
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
export default BigImageModal
|
||||
|
@ -1,28 +1,51 @@
|
||||
|
||||
import React, { FC } from 'react';
|
||||
import React, { FC, useRef, forwardRef, useImperativeHandle, useState } from 'react';
|
||||
import { CompareImage, Flex, Score } from '@zhst/meta'
|
||||
|
||||
interface ComBineImageProps {
|
||||
targetData: {
|
||||
url: string;
|
||||
data: {
|
||||
imgSummary: string;
|
||||
compaterImages: string[];
|
||||
imageKey: string;
|
||||
score: number;
|
||||
}[]
|
||||
compareData: {
|
||||
url: string;
|
||||
score: number
|
||||
}[]
|
||||
}
|
||||
}
|
||||
|
||||
const ComBineImage: FC<ComBineImageProps> = (props) => {
|
||||
const { targetData = [], compareData = [] } = props
|
||||
const ComBineImage: FC<ComBineImageProps> = forwardRef((props, ref) => {
|
||||
const { data } = props
|
||||
const { imgSummary, compaterImages = [] } = data
|
||||
const targetImageRef = useRef(null)
|
||||
const compareImageRef = useRef(null)
|
||||
const [targetIndex, setTargetIndex] = useState(compaterImages.findIndex(_url => imgSummary === _url) || 0)
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
compareImageRef,
|
||||
targetImageRef
|
||||
}));
|
||||
|
||||
return (
|
||||
<Flex justify='space-evenly' align='center' style={{ padding:'0 32px' }}>
|
||||
<CompareImage dataSource={targetData} label="目标图" />
|
||||
<Score score={0.2} />
|
||||
<CompareImage dataSource={compareData} openRoll={false} label="对比图" />
|
||||
<CompareImage
|
||||
ref={targetImageRef}
|
||||
preDisable={targetIndex === 0}
|
||||
nextDisable={targetIndex >= compaterImages.length - 1}
|
||||
onNext={() => setTargetIndex(targetIndex + 1)}
|
||||
onPre={() => setTargetIndex(targetIndex - 1)}
|
||||
showScore={false}
|
||||
openRoll={!!compaterImages.length}
|
||||
url={compaterImages[targetIndex] || imgSummary}
|
||||
label="目标图"
|
||||
/>
|
||||
<Score score={data.score} />
|
||||
<CompareImage
|
||||
ref={compareImageRef}
|
||||
url={data.imageKey}
|
||||
openRoll={false}
|
||||
score={data.score}
|
||||
label="对比图"
|
||||
/>
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
export default ComBineImage
|
||||
|
@ -1,66 +1,51 @@
|
||||
|
||||
import React from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { BigImageModal } from '@zhst/biz'
|
||||
import { DescriptionsProps } from '@zhst/meta'
|
||||
import { IMAGE_DATA, BIG_IMAGE_DATA } from '../mock'
|
||||
import { bigImageModalAdapter } from '@zhst/biz'
|
||||
import { Button, Space } from '@zhst/meta'
|
||||
import { BIG_IMAGE_DATA, attributeList } from '../mock'
|
||||
|
||||
const descriptionList: DescriptionsProps['items'] = [
|
||||
{
|
||||
title: '人员属性',
|
||||
children: [
|
||||
{
|
||||
key: '1',
|
||||
label: '性别',
|
||||
children: '男',
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '年龄',
|
||||
children: '成年',
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
label: '帽子',
|
||||
children: '无',
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
label: '上身颜色',
|
||||
children: '灰',
|
||||
},
|
||||
{
|
||||
key: '5',
|
||||
label: '下身颜色',
|
||||
children: '蓝色',
|
||||
},
|
||||
{
|
||||
key: '6',
|
||||
label: '附着物',
|
||||
children: '无',
|
||||
},
|
||||
{
|
||||
key: '7',
|
||||
label: '骑行',
|
||||
children: '否',
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
export default () => {
|
||||
const imageDataAdapter = bigImageModalAdapter(IMAGE_DATA)
|
||||
|
||||
console.log(imageDataAdapter)
|
||||
const BigModal = (props) => {
|
||||
const {
|
||||
} = props
|
||||
const [visible, setVisible] = useState(true)
|
||||
const [dataSource, setDataSource] = useState(BIG_IMAGE_DATA)
|
||||
const modalRef = useRef(null)
|
||||
|
||||
useEffect(() => {
|
||||
console.log(modalRef.current)
|
||||
}, [modalRef.current?.currentIndex])
|
||||
|
||||
useEffect(() => {
|
||||
console.log(modalRef.current)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<BigImageModal
|
||||
title="查看大图"
|
||||
open
|
||||
dataSource={IMAGE_DATA.dataSource}
|
||||
imageData={IMAGE_DATA.dataSource}
|
||||
width={1098}
|
||||
descriptionConfig={{ data: descriptionList }}
|
||||
/>
|
||||
<div>
|
||||
<Button onClick={() => setVisible(true)} >查看大图</Button>
|
||||
<BigImageModal
|
||||
title="查看大图"
|
||||
footer={(
|
||||
<Space>
|
||||
<Button onClick={() => modalRef.current?.setTab('VIDEO')} >查看视频</Button>
|
||||
<Button onClick={() => modalRef.current?.bigImagePreviewRef.current.setShowCrop(true)} >编辑模式</Button>
|
||||
<Button onClick={() => modalRef.current?.bigImagePreviewRef.current.setShowCrop(false)} >取消编辑</Button>
|
||||
</Space>
|
||||
)}
|
||||
open={visible}
|
||||
ref={modalRef}
|
||||
onCancel={() => setVisible(false)}
|
||||
dataSource={dataSource}
|
||||
imageData={dataSource}
|
||||
onIndexChange={(oldVal, newVal) => console.log(oldVal, newVal)}
|
||||
onTabChange={(oldVal, newVal) => console.log(oldVal, newVal)}
|
||||
width={1098}
|
||||
attributeList={attributeList}
|
||||
>
|
||||
</BigImageModal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BigModal
|
||||
|
128
packages/biz/src/BigImageModal/demo/oldData.tsx
Normal file
128
packages/biz/src/BigImageModal/demo/oldData.tsx
Normal file
@ -0,0 +1,128 @@
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { BigImageModal } from '@zhst/biz'
|
||||
import { Button, DescriptionsProps } from '@zhst/meta'
|
||||
import { IMAGE_DATA, BIG_IMAGE_DATA } from '../mock'
|
||||
import bigImageModalAdapter from '../util/bigImageModalAdapter'
|
||||
import { get } from '@zhst/func';
|
||||
|
||||
const descriptionList: DescriptionsProps['items'] = [
|
||||
{
|
||||
title: '人员属性',
|
||||
children: [
|
||||
{
|
||||
key: '1',
|
||||
label: '性别',
|
||||
children: '男',
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '年龄',
|
||||
children: '成年',
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
label: '帽子',
|
||||
children: '无',
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
label: '上身颜色',
|
||||
children: '灰',
|
||||
},
|
||||
{
|
||||
key: '5',
|
||||
label: '下身颜色',
|
||||
children: '蓝色',
|
||||
},
|
||||
{
|
||||
key: '6',
|
||||
label: '附着物',
|
||||
children: '无',
|
||||
},
|
||||
{
|
||||
key: '7',
|
||||
label: '骑行',
|
||||
children: '否',
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// 适配器,适配老接口
|
||||
const NewImageModal = bigImageModalAdapter(BigImageModal, {
|
||||
oldMode: true
|
||||
})
|
||||
|
||||
const BigModal = (props) => {
|
||||
const {
|
||||
onClose,
|
||||
isArchiveDetail = false,
|
||||
specialTitle = '对比图2',
|
||||
transformPropFunc,
|
||||
screenshotButtonRender,
|
||||
showLowFaceTip = false
|
||||
} = props
|
||||
const [visible, setVisible] = useState(false)
|
||||
const [selectIndex, setSelectIndex] = useState(0)
|
||||
const [dataSource, setDataSource] = useState(IMAGE_DATA.dataSource)
|
||||
const [dataSources, setDataSources] = useState(IMAGE_DATA.dataSource)
|
||||
const [selectItem, setSelectItem] = useState({})
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button onClick={() => setVisible(true)} >查看大图</Button>
|
||||
<NewImageModal
|
||||
title="查看大图"
|
||||
dataSource={dataSource}
|
||||
imageData={dataSource}
|
||||
width={1098}
|
||||
onClose={() => onClose}
|
||||
descriptionConfig={{ data: descriptionList }}
|
||||
visible={visible}
|
||||
isArchiveDetail={isArchiveDetail}
|
||||
ToolProps={{
|
||||
// renderLeft: leftOperateBar({ disableBtn, onActionClick: onBigImageActionClick }),
|
||||
// renderRight: rightOperateBar({
|
||||
// disableBtn,
|
||||
// onActionClick: onBigImageActionClick,
|
||||
// isArchiveDetail,
|
||||
// }),
|
||||
// renderVideoBtn: !disableBtn.includes(OPT['PLAY_VIDEO']),
|
||||
// disableVideo: disableVideo,
|
||||
}}
|
||||
selectIndex={selectIndex}
|
||||
onSelectIndexChange={(index: number) => {
|
||||
index > 0 && index < dataSources.length && setSelectIndex(index);
|
||||
}}
|
||||
// tabsFilter={tabsFilter}
|
||||
specialTitle={specialTitle}
|
||||
transformPropFunc={async (item: any) => {
|
||||
let bigImageInfo = !!transformPropFunc && (await transformPropFunc(item));
|
||||
setSelectItem({ ...bigImageInfo });
|
||||
return { ...bigImageInfo };
|
||||
}}
|
||||
screenshotButtonRender={screenshotButtonRender}
|
||||
//@ts-ignore
|
||||
transformVideoPropFunc={async (item) => {
|
||||
const { maxDuration: duration = 20 } = item || {};
|
||||
const time = get(item, 'timestamp');
|
||||
const cameraId = get(item, 'cameraId');
|
||||
const { url: flvUrl } = {
|
||||
url: 'url',
|
||||
downloadUrl: 'url',
|
||||
};
|
||||
return {
|
||||
flvUrl,
|
||||
maxDuration: duration,
|
||||
};
|
||||
}}
|
||||
nullDialogProp={{
|
||||
emptyText: showLowFaceTip ? '目标图人脸质量较低,暂无聚类数据' : '暂无数据',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BigModal
|
@ -3,6 +3,10 @@
|
||||
box-shadow: 0 4px 12px rgb(0 0 0 / 20%);
|
||||
}
|
||||
|
||||
.zhst-tabs .zhst-tabs-nav-wrap {
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
|
||||
&-view-container {
|
||||
position: relative;
|
||||
@ -508,3 +512,78 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.relatedWrapper {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
padding: 0 30px;
|
||||
margin-bottom: 30px;
|
||||
box-sizing: border-box;
|
||||
|
||||
.relatedTabs {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.relatedContent {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
|
||||
display: flex;
|
||||
|
||||
.relatedPics {
|
||||
width: 742px;
|
||||
height: 100px;
|
||||
// display: flex;
|
||||
// box-sizing: border-box;
|
||||
// background: #fafafa;
|
||||
// border-radius: 2px;
|
||||
// border: 1px solid #f0f0f0;
|
||||
// .LeftBtn,
|
||||
// .RighttBtn {
|
||||
// width: 34px;
|
||||
// height: 100%;
|
||||
// display: flex;
|
||||
// justify-content: center;
|
||||
// align-items: center;
|
||||
// }
|
||||
// .ListContent {
|
||||
// flex: 1;
|
||||
// height: 100%;
|
||||
// }
|
||||
}
|
||||
|
||||
.disabled {
|
||||
color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.relatedBtn {
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: #0099ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-tabs-left>.ant-tabs-content-holder>.ant-tabs-content>.ant-tabs-tabpane {
|
||||
padding-left: 16px;
|
||||
}
|
||||
|
||||
.ant-tabs-tab {
|
||||
padding: 8px 12px !important;
|
||||
text-align: right !important;
|
||||
}
|
||||
|
||||
.ant-tabs .ant-tabs-tab {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
---
|
||||
nav:
|
||||
title: 业务组件
|
||||
group:
|
||||
title: 数据展示
|
||||
order: 1
|
||||
group: 数据展示
|
||||
category: Components
|
||||
subtitle: 大图预览组件
|
||||
title: BigImagePreview 大图预览组件
|
||||
demo:
|
||||
cols: 2
|
||||
---
|
||||
|
||||
|
||||
# 大图弹框
|
||||
|
||||
<code src="./demo/index.tsx">基本</code>
|
||||
<code src="./demo/oldData.tsx">老数据版本</code>
|
||||
|
||||
|
@ -1,452 +1,11 @@
|
||||
import { DescriptionsProps } from "@zhst/meta";
|
||||
|
||||
export const IMAGE_DATA = {
|
||||
"enAbleDeleteFeature": true,
|
||||
"tabsFilter": [
|
||||
"COMPATER",
|
||||
"NORMAL"
|
||||
],
|
||||
"dataSources": [
|
||||
{
|
||||
"objectId": "1742110565582518272",
|
||||
"condition": {
|
||||
"featureInfo": null,
|
||||
"featureData": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"imageData": "",
|
||||
"alg": "VERSION_REID_HEAD_ATTR",
|
||||
"rect": {
|
||||
"x": 0.271875,
|
||||
"y": 0.32222223,
|
||||
"w": 0.2859375,
|
||||
"h": 0.67777777
|
||||
},
|
||||
"objectImageUrl": "singer-20240102/1/129529/1742047651878156288.jpg",
|
||||
"srcImageUrl": "singer-20240102/1/129529/1742047652511496192.jpg"
|
||||
},
|
||||
"score": 0.7163062,
|
||||
"timestamp": 1704186491979,
|
||||
"deviceId": "129533",
|
||||
"id": "129533",
|
||||
"name": "4楼门口过道人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.125,
|
||||
"latitude": 30.280500411987305,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "38",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
},
|
||||
"objectIndex": {
|
||||
"objectId": "1742110565582518272",
|
||||
"solutionId": "1",
|
||||
"deviceId": "129533",
|
||||
"fragmentId": "0"
|
||||
},
|
||||
"objectType": "OBJECT_TYPE_PEDESTRAIN",
|
||||
"isObjectTrack": true,
|
||||
"pathId": "1742110532019697664",
|
||||
"frameInfo": {
|
||||
"frameId": "0",
|
||||
"frameTimestamp": "1704186491979",
|
||||
"width": 0,
|
||||
"height": 0,
|
||||
"originWidth": 1920,
|
||||
"originHeight": 1080,
|
||||
"offsetTime": "24714687",
|
||||
"skipNumber": "0"
|
||||
},
|
||||
"level": 1,
|
||||
"bboxInFrame": {
|
||||
"x": 0.603125,
|
||||
"y": 0.3314815,
|
||||
"w": 0.0578125,
|
||||
"h": 0.2712963
|
||||
},
|
||||
"bboxExtInFrame": {
|
||||
"x": 0.546875,
|
||||
"y": 0.2638889,
|
||||
"w": 0.17135416,
|
||||
"h": 0.40648147
|
||||
},
|
||||
"objectImageKey": "",
|
||||
"objectExtImageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129533/1742110565582518272.jpg",
|
||||
"frameImageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129533/1742110565603489792.jpg",
|
||||
"confidence": 0.817271,
|
||||
"sourceObjectId": "1742110565603489792",
|
||||
"storeTimestamp": "0",
|
||||
"gbNumber": "",
|
||||
"qualityScore": 0,
|
||||
"subObjectCount": 1,
|
||||
"subObjectType": [
|
||||
"OBJECT_TYPE_FACE"
|
||||
],
|
||||
"subObjectIds": [
|
||||
"1742110532015503360"
|
||||
],
|
||||
"cameraInfo": {
|
||||
"id": "129533",
|
||||
"name": "4楼门口过道人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.125,
|
||||
"latitude": 30.280500411987305,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "38",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
}
|
||||
},
|
||||
"solutionId": "1",
|
||||
"fragmentId": "0",
|
||||
"contrastKey": "singer-20240102/1/129533/1742110565582518272.jpg",
|
||||
"compaterImages": [
|
||||
"http://10.0.0.7:30003/file/singer-20240102/1/129529/1742047651878156288.jpg"
|
||||
],
|
||||
"imgSummary": "singer-20240102/1/129533/1742110565582518272.jpg",
|
||||
"imageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129533/1742110565582518272.jpg",
|
||||
"srcImageUrl": "http://10.0.0.7:30003/file/singer-20240102/1/129533/1742110565603489792.jpg",
|
||||
"algorithmVersion": "VERSION_REID_HEAD_ATTR",
|
||||
"cameraId": "129533",
|
||||
"cameraName": "4楼门口过道人脸"
|
||||
},
|
||||
{
|
||||
"objectId": "1742092780462684161",
|
||||
"condition": {
|
||||
"featureInfo": null,
|
||||
"featureData": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"imageData": "",
|
||||
"alg": "VERSION_REID_HEAD_ATTR",
|
||||
"rect": {
|
||||
"x": 0.271875,
|
||||
"y": 0.32222223,
|
||||
"w": 0.2859375,
|
||||
"h": 0.67777777
|
||||
},
|
||||
"objectImageUrl": "singer-20240102/1/129529/1742047651878156288.jpg",
|
||||
"srcImageUrl": "singer-20240102/1/129529/1742047652511496192.jpg"
|
||||
},
|
||||
"score": 0.70154816,
|
||||
"timestamp": 1704182251640,
|
||||
"deviceId": "129533",
|
||||
"id": "129533",
|
||||
"name": "4楼门口过道人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.125,
|
||||
"latitude": 30.280500411987305,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "38",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
},
|
||||
"objectIndex": {
|
||||
"objectId": "1742092780462684161",
|
||||
"solutionId": "1",
|
||||
"deviceId": "129533",
|
||||
"fragmentId": "0"
|
||||
},
|
||||
"objectType": "OBJECT_TYPE_PEDESTRAIN",
|
||||
"isObjectTrack": true,
|
||||
"pathId": "1742092746237163520",
|
||||
"frameInfo": {
|
||||
"frameId": "0",
|
||||
"frameTimestamp": "1704182251640",
|
||||
"width": 0,
|
||||
"height": 0,
|
||||
"originWidth": 1920,
|
||||
"originHeight": 1080,
|
||||
"offsetTime": "20474348",
|
||||
"skipNumber": "0"
|
||||
},
|
||||
"level": 1,
|
||||
"bboxInFrame": {
|
||||
"x": 0.63177085,
|
||||
"y": 0.38333333,
|
||||
"w": 0.078125,
|
||||
"h": 0.3537037
|
||||
},
|
||||
"bboxExtInFrame": {
|
||||
"x": 0.55885416,
|
||||
"y": 0.29537037,
|
||||
"w": 0.22447917,
|
||||
"h": 0.5314815
|
||||
},
|
||||
"objectImageKey": "",
|
||||
"objectExtImageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129533/1742092780462684161.jpg",
|
||||
"frameImageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129533/1742092780768868352.jpg",
|
||||
"confidence": 0.888334,
|
||||
"sourceObjectId": "1742092780768868352",
|
||||
"storeTimestamp": "0",
|
||||
"gbNumber": "",
|
||||
"qualityScore": 0,
|
||||
"subObjectCount": 1,
|
||||
"subObjectType": [
|
||||
"OBJECT_TYPE_FACE"
|
||||
],
|
||||
"subObjectIds": [
|
||||
"1742092746232969217"
|
||||
],
|
||||
"cameraInfo": {
|
||||
"id": "129533",
|
||||
"name": "4楼门口过道人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.125,
|
||||
"latitude": 30.280500411987305,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "38",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
}
|
||||
},
|
||||
"solutionId": "1",
|
||||
"fragmentId": "0",
|
||||
"contrastKey": "singer-20240102/1/129533/1742092780462684161.jpg",
|
||||
"compaterImages": [
|
||||
"http://10.0.0.7:30003/file/singer-20240102/1/129529/1742047651878156288.jpg"
|
||||
],
|
||||
"imgSummary": "singer-20240102/1/129533/1742092780462684161.jpg",
|
||||
"imageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129533/1742092780462684161.jpg",
|
||||
"srcImageUrl": "http://10.0.0.7:30003/file/singer-20240102/1/129533/1742092780768868352.jpg",
|
||||
"algorithmVersion": "VERSION_REID_HEAD_ATTR",
|
||||
"cameraId": "129533",
|
||||
"cameraName": "4楼门口过道人脸"
|
||||
},
|
||||
{
|
||||
"objectId": "1742092514409592832",
|
||||
"condition": {
|
||||
"featureInfo": null,
|
||||
"featureData": "AAAAAAAAAAAAAAA==",
|
||||
"imageData": "",
|
||||
"alg": "VERSION_REID_HEAD_ATTR",
|
||||
"rect": {
|
||||
"x": 0.271875,
|
||||
"y": 0.32222223,
|
||||
"w": 0.2859375,
|
||||
"h": 0.67777777
|
||||
},
|
||||
"objectImageUrl": "singer-20240102/1/129529/1742047651878156288.jpg",
|
||||
"srcImageUrl": "singer-20240102/1/129529/1742047652511496192.jpg"
|
||||
},
|
||||
"score": 0.703765,
|
||||
"timestamp": 1704182186451,
|
||||
"deviceId": "129529",
|
||||
"id": "129529",
|
||||
"name": "4入口人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.12100219726562,
|
||||
"latitude": 30.280099868774414,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "34",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
},
|
||||
"objectIndex": {
|
||||
"objectId": "1742092514409592832",
|
||||
"solutionId": "1",
|
||||
"deviceId": "129529",
|
||||
"fragmentId": "0"
|
||||
},
|
||||
"objectType": "OBJECT_TYPE_PEDESTRAIN",
|
||||
"isObjectTrack": true,
|
||||
"pathId": "1742092482440607744",
|
||||
"frameInfo": {
|
||||
"frameId": "0",
|
||||
"frameTimestamp": "1704182186451",
|
||||
"width": 0,
|
||||
"height": 0,
|
||||
"originWidth": 2560,
|
||||
"originHeight": 1440,
|
||||
"offsetTime": "20409182",
|
||||
"skipNumber": "0"
|
||||
},
|
||||
"level": 1,
|
||||
"bboxInFrame": {
|
||||
"x": 0.6195313,
|
||||
"y": 0.24583334,
|
||||
"w": 0.09804688,
|
||||
"h": 0.41944444
|
||||
},
|
||||
"bboxExtInFrame": {
|
||||
"x": 0.53515625,
|
||||
"y": 0.14027777,
|
||||
"w": 0.26640624,
|
||||
"h": 0.63125
|
||||
},
|
||||
"objectImageKey": "",
|
||||
"objectExtImageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129529/1742092514409592832.jpg",
|
||||
"frameImageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129529/1742092515508500480.jpg",
|
||||
"confidence": 0.92494,
|
||||
"sourceObjectId": "1742092515508500480",
|
||||
"storeTimestamp": "0",
|
||||
"gbNumber": "",
|
||||
"qualityScore": 0,
|
||||
"subObjectCount": 1,
|
||||
"subObjectType": [
|
||||
"OBJECT_TYPE_FACE"
|
||||
],
|
||||
"subObjectIds": [
|
||||
"1742092482432219136"
|
||||
],
|
||||
"cameraInfo": {
|
||||
"id": "129529",
|
||||
"name": "4入口人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.12100219726562,
|
||||
"latitude": 30.280099868774414,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "34",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
}
|
||||
},
|
||||
"solutionId": "1",
|
||||
"fragmentId": "0",
|
||||
"contrastKey": "singer-20240102/1/129529/1742092514409592832.jpg",
|
||||
"compaterImages": [
|
||||
"http://10.0.0.7:30003/file/singer-20240102/1/129529/1742047651878156288.jpg"
|
||||
],
|
||||
"imgSummary": "singer-20240102/1/129529/1742092514409592832.jpg",
|
||||
"imageKey": "http://10.0.0.7:30003/file/singer-20240102/1/129529/1742092514409592832.jpg",
|
||||
"srcImageUrl": "http://10.0.0.7:30003/file/singer-20240102/1/129529/1742092515508500480.jpg",
|
||||
"algorithmVersion": "VERSION_REID_HEAD_ATTR",
|
||||
"cameraId": "129529",
|
||||
"cameraName": "4入口人脸"
|
||||
}
|
||||
],
|
||||
"selectIndex": 4,
|
||||
"disableBtn": [
|
||||
0,
|
||||
@ -483,30 +42,6 @@ export const IMAGE_DATA = {
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "38",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
},
|
||||
"objectIndex": {
|
||||
"objectId": "1742110565582518272",
|
||||
"solutionId": "1",
|
||||
@ -554,41 +89,6 @@ export const IMAGE_DATA = {
|
||||
"subObjectIds": [
|
||||
"1742110532015503360"
|
||||
],
|
||||
"cameraInfo": {
|
||||
"id": "129533",
|
||||
"name": "4楼门口过道人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.125,
|
||||
"latitude": 30.280500411987305,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "38",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
}
|
||||
},
|
||||
"solutionId": "1",
|
||||
"fragmentId": "0",
|
||||
"contrastKey": "singer-20240102/1/129533/1742110565582518272.jpg",
|
||||
@ -630,30 +130,6 @@ export const IMAGE_DATA = {
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "38",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
},
|
||||
"objectIndex": {
|
||||
"objectId": "1742092680994764802",
|
||||
"solutionId": "1",
|
||||
@ -697,41 +173,6 @@ export const IMAGE_DATA = {
|
||||
"subObjectCount": 0,
|
||||
"subObjectType": [],
|
||||
"subObjectIds": [],
|
||||
"cameraInfo": {
|
||||
"id": "129533",
|
||||
"name": "4楼门口过道人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.125,
|
||||
"latitude": 30.280500411987305,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "38",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
}
|
||||
},
|
||||
"solutionId": "1",
|
||||
"fragmentId": "0",
|
||||
"contrastKey": "singer-20240102/1/129533/1742092680994764802.jpg",
|
||||
@ -773,30 +214,6 @@ export const IMAGE_DATA = {
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "34",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
},
|
||||
"objectIndex": {
|
||||
"objectId": "1742092514409592832",
|
||||
"solutionId": "1",
|
||||
@ -844,41 +261,6 @@ export const IMAGE_DATA = {
|
||||
"subObjectIds": [
|
||||
"1742092482432219136"
|
||||
],
|
||||
"cameraInfo": {
|
||||
"id": "129529",
|
||||
"name": "4入口人脸",
|
||||
"dirid": "0",
|
||||
"status": "1",
|
||||
"longitude": 120.12100219726562,
|
||||
"latitude": 30.280099868774414,
|
||||
"caseId": "0",
|
||||
"caseGroup": "",
|
||||
"isDeleted": "DEVICEMANAGER_BOOL_DEFAULT",
|
||||
"extendInfo": {
|
||||
"vmsPlatformId": "29",
|
||||
"vmsChannel": "34",
|
||||
"vmsCameraDecoderTag": "hikvision",
|
||||
"platformPluginType": "PLATFORM_PLUGIN_TYPE_HAIKANG_NVR",
|
||||
"deviceVender": "0",
|
||||
"type": "DEVICEMANAGER_CAMERA_TYPE_NORMAL",
|
||||
"ip": "",
|
||||
"port": "0",
|
||||
"username": "",
|
||||
"passwd": "",
|
||||
"rtspAddress": "",
|
||||
"facesnapChannel": "",
|
||||
"edgeDeviceSn": "",
|
||||
"platform1400Id": 0,
|
||||
"useRtspAddress": false,
|
||||
"frameCheck": false,
|
||||
"frameRectX": 0,
|
||||
"frameRectY": 0,
|
||||
"frameRectW": 0,
|
||||
"frameRectH": 0,
|
||||
"edgeNodeId": "0",
|
||||
"processStatus": "FILTER_REALTIME_DEFAULT"
|
||||
}
|
||||
},
|
||||
"solutionId": "1",
|
||||
"fragmentId": "0",
|
||||
"contrastKey": "singer-20240102/1/129529/1742092514409592832.jpg",
|
||||
@ -904,7 +286,13 @@ export const IMAGE_DATA = {
|
||||
export const BIG_IMAGE_DATA = [
|
||||
{
|
||||
imageKey: 'http://10.0.0.120:30003/file/singer-20240110/1/5/1744894622934503424.jpg',
|
||||
odRect:{
|
||||
imgSummary: "http://10.0.0.120:30003/file/singer-20240117/1/5/1747536346412488704.jpg",
|
||||
flvUrl: 'ws://10.0.0.120:9033/flv/Sip/34020000001310000301.flv?ip=10.0.0.120&stime=1704815972&etime=1704815992',
|
||||
compaterImages: [
|
||||
'http://10.0.0.120:30003/file/singer-20240117/1/5/1747536346412488704.jpg',
|
||||
"http://10.0.0.120:30003/file/public/public_20240117/file/dfdd3340-53c8-4dc4-9921-f13230aa0355.jpg"
|
||||
],
|
||||
odRect: {
|
||||
"x":0.5445312,
|
||||
"y":0.19166666,
|
||||
"w":0.08671875,
|
||||
@ -912,7 +300,8 @@ export const BIG_IMAGE_DATA = [
|
||||
},
|
||||
attachImg: [
|
||||
{
|
||||
"url": "http://10.0.0.120:30003/file/singer-20240110/1/5/1744894622695428096.jpg","label": "形体"
|
||||
"url": "http://10.0.0.120:30003/file/singer-20240110/1/5/1744894622695428096.jpg",
|
||||
"label": "形体"
|
||||
},{
|
||||
"url": "http://10.0.0.120:30003/file/singer-20240110/1/5/1744894588427964418.jpg",
|
||||
"label": "人脸"
|
||||
@ -962,6 +351,7 @@ export const BIG_IMAGE_DATA = [
|
||||
},
|
||||
{
|
||||
imageKey: 'http://10.0.0.120:30003/file/singer-20240115/1/9/1746795581994436608.jpg',
|
||||
imgSummary: "http://10.0.0.120:30003/file/singer-20240117/1/5/1747536346412488704.jpg",
|
||||
odRect:{
|
||||
"x":0.553125,"y":0.29722223,"w":0.048958335,"h":0.2462963
|
||||
},
|
||||
@ -973,6 +363,7 @@ export const BIG_IMAGE_DATA = [
|
||||
"label": "人脸"
|
||||
}
|
||||
],
|
||||
flvUrl: 'ws://10.0.0.120:9033/flv/HaikangNvr/34.flv?ip=10.0.2.103&stime=1705302394&etime=1705302414',
|
||||
score: 0.815207, // 人脸质量分
|
||||
showScore: true, // 人脸质量分
|
||||
cameraPosition: 'string', // 摄像头位置
|
||||
@ -1048,4 +439,87 @@ export const BIG_IMAGE_DATA = [
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
export const attributeList: DescriptionsProps['items'] = [
|
||||
{
|
||||
title: '人员属性',
|
||||
children: [
|
||||
{
|
||||
key: '1',
|
||||
label: '性别',
|
||||
children: '男',
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '年龄',
|
||||
children: '成年',
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
label: '帽子',
|
||||
children: '无',
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
label: '上身颜色',
|
||||
children: '灰',
|
||||
},
|
||||
{
|
||||
key: '5',
|
||||
label: '下身颜色',
|
||||
children: '蓝色',
|
||||
},
|
||||
{
|
||||
key: '6',
|
||||
label: '附着物',
|
||||
children: '无',
|
||||
},
|
||||
{
|
||||
key: '7',
|
||||
label: '骑行',
|
||||
children: '否',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '社区规范',
|
||||
children: [
|
||||
{
|
||||
key: '1',
|
||||
label: '性别',
|
||||
children: '男',
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '年龄',
|
||||
children: '成年',
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
label: '帽子',
|
||||
children: '无',
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
label: '上身颜色',
|
||||
children: '灰',
|
||||
},
|
||||
{
|
||||
key: '5',
|
||||
label: '下身颜色',
|
||||
children: '蓝色',
|
||||
},
|
||||
{
|
||||
key: '6',
|
||||
label: '附着物',
|
||||
children: '无',
|
||||
},
|
||||
{
|
||||
key: '7',
|
||||
label: '骑行',
|
||||
children: '否',
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
196
packages/biz/src/BigImageModal/util/bigImageModalAdapter.tsx
Normal file
196
packages/biz/src/BigImageModal/util/bigImageModalAdapter.tsx
Normal file
@ -0,0 +1,196 @@
|
||||
/**
|
||||
* 适配老的大屏组件数据格式传入
|
||||
*/
|
||||
import React, { FC } from 'react';
|
||||
import { AlgorithmVersionStr, HumanProperty, ObjectType, Rect, IScreenshotButtonProp } from '@zhst/types'
|
||||
import { VideoViewProps, ImgViewProps, VideoViewRef, ImgViewRef } from '@zhst/meta'
|
||||
import { IMAGE_DATA } from '../mock';
|
||||
|
||||
export type TAB_TYPE = 'COMPATER' | 'NORMAL' | 'TRACK';
|
||||
export type MODEL_TYPE = 'VIDEO' | 'IMAGE';
|
||||
|
||||
export interface CarouselProps {
|
||||
hasPre?: boolean;
|
||||
hasNext?: boolean;
|
||||
selectIndex: number;
|
||||
setSelectIndex: React.Dispatch<React.SetStateAction<number>>;
|
||||
dataSource: Array<{
|
||||
key: string;
|
||||
url: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export type ISelectItem = Partial<Omit<ImgViewProps, 'screenshotButtonRender'>> &
|
||||
Partial<Omit<VideoViewProps, 'screenshotButtonRender'>>;
|
||||
|
||||
/**
|
||||
* 描述列表 description
|
||||
*/
|
||||
export interface HeaderProps {
|
||||
value: TAB_TYPE;
|
||||
onChange: (type: TAB_TYPE) => void;
|
||||
tabsFilter: TAB_TYPE[];
|
||||
}
|
||||
|
||||
export interface ParamProps {
|
||||
tab: string;
|
||||
selectItem: ISelectItem;
|
||||
imgViewRef: React.MutableRefObject<ImgViewRef>;
|
||||
VideoViewRef: React.MutableRefObject<VideoViewRef>;
|
||||
model: MODEL_TYPE;
|
||||
setModel: React.Dispatch<React.SetStateAction<MODEL_TYPE>>;
|
||||
/* 可观测值 */
|
||||
scale$: number;
|
||||
showCrop$: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 工具栏
|
||||
*/
|
||||
export interface ToolProps {
|
||||
renderRight?: (props: ParamProps) => React.ReactNode;
|
||||
renderLeft?: (props: ParamProps) => React.ReactNode;
|
||||
renderVideoBtn?: boolean;
|
||||
param: ParamProps;
|
||||
disableVideo: boolean;
|
||||
}
|
||||
|
||||
|
||||
export interface BigImageData {
|
||||
//imageKey 小图
|
||||
extendRectList: (Rect & { algorithmVersion: AlgorithmVersionStr; imageKey: string })[];
|
||||
rectList: (Rect & { algorithmVersion: AlgorithmVersionStr; imageKey: string })[];
|
||||
attachImg: { url: string; label: '形体' | '人脸' }[];
|
||||
odRect: Rect;
|
||||
compaterImages: string[] // 目标图列表
|
||||
constractKey: string; // 当前比较中的目标图
|
||||
frameImageKey: string; // 场景图
|
||||
imageKey?: string; // 大图
|
||||
imgSummary: string; // 摘要图
|
||||
objectExtImageKey: string; //比对到的目标图扩展图 === imgSummary
|
||||
|
||||
attributeList: { label: string; list: any[] }[];
|
||||
archiveImages?: any;
|
||||
spaceName: string;
|
||||
|
||||
objectIndex?: {
|
||||
deviceId: string;
|
||||
fragmentId: string;
|
||||
objectId: string;
|
||||
solutionId: string;
|
||||
}
|
||||
|
||||
objectType: ObjectType;
|
||||
objectId: string; //这张摘要本身的Id
|
||||
bodyObjectId?: string;
|
||||
faceObjectId?: string; //这张摘要下的人脸Id(如果有)
|
||||
sourceObjectId?: string; //这张摘要上游的形体Id(如果有)
|
||||
cameraId: string;
|
||||
cameraName: string;
|
||||
selectIndex: number;
|
||||
humanProperty: HumanProperty;
|
||||
qualityScore?: number; //人脸质量分
|
||||
score: number; // 相似度
|
||||
timestamp: string;
|
||||
bodyImageUrl: string;
|
||||
faceImageUrl: string;
|
||||
algorithmVersion: AlgorithmVersionStr;
|
||||
|
||||
bodySpaceName: string;
|
||||
faceSpaceName: string;
|
||||
position: {
|
||||
lat: number
|
||||
lng: number
|
||||
}
|
||||
|
||||
solutionId?: string;
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
|
||||
interface IOldImageData {
|
||||
visible?: boolean; // 显示隐藏弹框
|
||||
defaultModel?: MODEL_TYPE; // 视频模式 | 图片模式
|
||||
onClose?: () => void; // 关闭弹框
|
||||
isLoading?: boolean; // 是否加载中
|
||||
hasPre?: boolean; // 向前翻页
|
||||
hasNext?: boolean; // 向后翻页
|
||||
selectIndex?: number; // 选中的数据(dataSource为数组情况下)
|
||||
onSelectIndexChange?: (i: number) => void; // 修改当前下标
|
||||
dataSource: BigImageData[]; // 数据1
|
||||
dataSources: BigImageData[]; // 数据2
|
||||
relatedData?: BigImageData[]; // 数据3
|
||||
transformPropFunc: (item: any) => ISelectItem; // 格式化数据方法
|
||||
transformVideoPropFunc: (
|
||||
item: ISelectItem
|
||||
) => Promise<Omit<VideoViewProps, 'screenshotButtonRender'>>; // 视频模式格式化数据方法
|
||||
screenshotButtonRender?: (screenshotButtonProp: IScreenshotButtonProp) => React.ReactElement;
|
||||
showTool?: boolean; // 是否显示底部菜单
|
||||
showCarousel?: boolean; //
|
||||
imgViewProp?: Partial<ImgViewProps>; // 图片模式的配置
|
||||
videoViewProp?: Partial<VideoViewProps>; // 视频模式的配置
|
||||
ToolProps?: Partial<ToolProps>; // 底部菜单的配置
|
||||
nullDialogProp?: {
|
||||
emptyText?: string;
|
||||
}; // 暂无数据的配置
|
||||
showHeader?: boolean; // 是否显示 description
|
||||
tabsFilter?: TAB_TYPE[]; // tabs 过滤
|
||||
useVirtual?: boolean; // 是否显示虚拟
|
||||
loadNext?: (i: number) => Promise<void>; // 下一个
|
||||
loadPre?: (i: number) => Promise<void>; // 前一个
|
||||
children: React.ReactNode; // 子元素
|
||||
title?: string; // 标题
|
||||
specialTitle?: string; // 对比图模式下标题
|
||||
isRelated?: boolean;
|
||||
carouselProp?: Partial<CarouselProps>;
|
||||
}
|
||||
|
||||
|
||||
export interface ImageModalDataProps {
|
||||
targetData: BigImageData[]
|
||||
compactData: BigImageData[]
|
||||
}
|
||||
|
||||
export interface ModalAdapterConfigProps {
|
||||
oldMode?: boolean; // 是否是老模式
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容老数据格式
|
||||
* @param _data 老数据格式
|
||||
* @returns newData
|
||||
*/
|
||||
const translateOldImageData = (_data: IOldImageData) => {
|
||||
return {
|
||||
..._data,
|
||||
open: _data.visible,
|
||||
onCancel: _data.onClose
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 大图组件适配器,兼容老接口
|
||||
* @param Cmp 大图组件
|
||||
* @param config 额外配置
|
||||
* @returns 大图组件
|
||||
*/
|
||||
const adapter = (Cmp: any, config: ModalAdapterConfigProps): any => {
|
||||
const { oldMode = false } = config
|
||||
|
||||
return (props: IOldImageData) => {
|
||||
const newProps = oldMode ? translateOldImageData(props) : props
|
||||
console.log('adapter----适配数据', props, newProps)
|
||||
|
||||
// 该属性已经废弃
|
||||
delete newProps.visible
|
||||
|
||||
return (
|
||||
<Cmp
|
||||
{...newProps}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default adapter
|
@ -1,140 +0,0 @@
|
||||
/**
|
||||
* 适配老的大屏组件数据格式传入
|
||||
*/
|
||||
import React from 'react';
|
||||
import { AlgorithmVersionStr, HumanProperty, ObjectType, Rect, IScreenshotButtonProp } from '@zhst/types'
|
||||
import { VideoViewProps, ImgViewProps, VideoViewRef, ImgViewRef } from '@zhst/meta'
|
||||
|
||||
export type TAB_TYPE = 'COMPATER' | 'NORMAL' | 'TRACK';
|
||||
export type MODEL_TYPE = 'VIDEO' | 'IMAGE';
|
||||
|
||||
export interface CarouselProps {
|
||||
hasPre?: boolean;
|
||||
hasNext?: boolean;
|
||||
selectIndex: number;
|
||||
setSelectIndex: React.Dispatch<React.SetStateAction<number>>;
|
||||
dataSource: Array<{
|
||||
key: string;
|
||||
url: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export type ISelectItem = Partial<Omit<ImgViewProps, 'screenshotButtonRender'>> &
|
||||
Partial<Omit<VideoViewProps, 'screenshotButtonRender'>>;
|
||||
|
||||
export interface HeaderProps {
|
||||
value: TAB_TYPE;
|
||||
onChange: (type: TAB_TYPE) => void;
|
||||
tabsFilter: TAB_TYPE[];
|
||||
}
|
||||
|
||||
export interface ParamProps {
|
||||
tab: string;
|
||||
selectItem: ISelectItem;
|
||||
imgViewRef: React.MutableRefObject<ImgViewRef>;
|
||||
VideoViewRef: React.MutableRefObject<VideoViewRef>;
|
||||
model: MODEL_TYPE;
|
||||
setModel: React.Dispatch<React.SetStateAction<MODEL_TYPE>>;
|
||||
/* 可观测值 */
|
||||
scale$: number;
|
||||
showCrop$: boolean;
|
||||
}
|
||||
|
||||
|
||||
export interface BigImageData {
|
||||
//imageKey 小图
|
||||
extendRectList: (Rect & { algorithmVersion: AlgorithmVersionStr; imageKey: string })[];
|
||||
rectList: (Rect & { algorithmVersion: AlgorithmVersionStr; imageKey: string })[];
|
||||
attachImg: { url: string; label: '形体' | '人脸' }[];
|
||||
odRect: Rect;
|
||||
imageKey: string; //大图
|
||||
imgSummary: string; //摘要图
|
||||
|
||||
objectExtImageKey: string; //比对到的目标图扩展图 === imgSummary
|
||||
attributeList: { label: string; list: any[] }[];
|
||||
archiveImages?: any;
|
||||
spaceName: string;
|
||||
|
||||
objectType: ObjectType;
|
||||
objectId: string; //这张摘要本身的Id
|
||||
bodyObjectId?: string;
|
||||
faceObjectId?: string; //这张摘要下的人脸Id(如果有)
|
||||
sourceObjectId?: string; //这张摘要上游的形体Id(如果有)
|
||||
cameraId: string;
|
||||
cameraName: string;
|
||||
selectIndex: number;
|
||||
humanProperty: HumanProperty;
|
||||
qualityScore?: number; //人脸质量分
|
||||
score: number; //相似度
|
||||
timestamp: string;
|
||||
bodyImageUrl: string;
|
||||
faceImageUrl: string;
|
||||
algorithmVersion: AlgorithmVersionStr;
|
||||
|
||||
bodySpaceName: string;
|
||||
faceSpaceName: string;
|
||||
|
||||
solutionId?: string;
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
interface IOldImageData {
|
||||
visible?: boolean;
|
||||
defaultModel?: MODEL_TYPE;
|
||||
onClose?: () => void;
|
||||
isLoading?: boolean;
|
||||
hasPre?: boolean;
|
||||
hasNext?: boolean;
|
||||
selectIndex?: number;
|
||||
onSelectIndexChange?: (i: number) => void;
|
||||
dataSource: BigImageData[];
|
||||
dataSources: BigImageData[];
|
||||
relatedData?: BigImageData[];
|
||||
transformPropFunc: (item: any) => ISelectItem;
|
||||
transformVideoPropFunc: (
|
||||
item: ISelectItem
|
||||
) => Promise<Omit<VideoViewProps, 'screenshotButtonRender'>>;
|
||||
screenshotButtonRender?: (screenshotButtonProp: IScreenshotButtonProp) => React.ReactElement;
|
||||
showTool?: boolean;
|
||||
showCarousel?: boolean;
|
||||
imgViewProp?: Partial<ImgViewProps>;
|
||||
videoViewProp?: Partial<VideoViewProps>;
|
||||
ToolProps?: Partial<ToolProps>;
|
||||
nullDialogProp?: {
|
||||
emptyText?: string;
|
||||
};
|
||||
showHeader?: boolean;
|
||||
tabsFilter?: TAB_TYPE[];
|
||||
useVirtual?: boolean;
|
||||
loadNext?: (i: number) => Promise<void>;
|
||||
loadPre?: (i: number) => Promise<void>;
|
||||
children: React.ReactNode;
|
||||
title?: string;
|
||||
specialTitle?: string;
|
||||
isRelated?: boolean;
|
||||
carouselProp?: Partial<CarouselProps>;
|
||||
}
|
||||
|
||||
export interface ToolProps {
|
||||
renderRight?: (props: ParamProps) => React.ReactNode;
|
||||
renderLeft?: (props: ParamProps) => React.ReactNode;
|
||||
renderVideoBtn?: boolean;
|
||||
param: ParamProps;
|
||||
disableVideo: boolean;
|
||||
}
|
||||
|
||||
export interface ImageModalDataProps {
|
||||
targetData: []
|
||||
compactData: []
|
||||
}
|
||||
|
||||
const adapter = (data: IOldImageData): ImageModalDataProps => {
|
||||
|
||||
return {
|
||||
targetData: [],
|
||||
compactData: [],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default adapter
|
@ -1 +0,0 @@
|
||||
export { default as bigImageModalAdapter } from './bigImageModalAdapter'
|
@ -1,3 +1,2 @@
|
||||
export { default as Demo } from './Demo';
|
||||
export * from './adapter'
|
||||
export { default as BigImageModal } from './BigImageModal'
|
||||
|
41
packages/func/es/camera/constants.d.ts
vendored
41
packages/func/es/camera/constants.d.ts
vendored
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* 设备类型枚举
|
||||
*/
|
||||
export declare const DeviceType: {
|
||||
VMS: string;
|
||||
DIR: string;
|
||||
CAMERA: string;
|
||||
};
|
||||
export declare const LOCAL_KEY = "local";
|
||||
export declare const DIRE_CONNECT_KEY = "direconnect";
|
||||
export declare const BOX_LIST_KEY = "boxlist";
|
||||
export declare enum VmsplatformOpt {
|
||||
VMSPLATFORMOPT_ID = 0,
|
||||
VMSPLATFORMOPT_PLATFORMNAME = 1,
|
||||
VMSPLATFORMOPT_PLUGINNAME = 2,
|
||||
VMSPLATFORMOPT_IP = 3,
|
||||
VMSPLATFORMOPT_PORT = 4,
|
||||
VMSPLATFORMOPT_USERNAME = 5,
|
||||
VMSPLATFORMOPT_PASSWORD = 6
|
||||
}
|
||||
export declare enum OPT {
|
||||
OR = 0,
|
||||
AND = 1,
|
||||
ORNOT = 2,
|
||||
ANDNOT = 3
|
||||
}
|
||||
export declare enum DevicemanagerCameraType {
|
||||
DEVICEMANAGER_CAMERA_TYPE_DEFAULT = 0,
|
||||
DEVICEMANAGER_CAMERA_TYPE_NORMAL = 1,
|
||||
DEVICEMANAGER_CAMERA_TYPE_1400 = 97,
|
||||
DEVICEMANAGER_CAMERA_TYPE_DHGRABBER = 98,
|
||||
DEVICEMANAGER_CAMERA_TYPE_HKGRABBER = 99,
|
||||
DEVICEMANAGER_CAMERA_TYPE_LOCAL = 100
|
||||
}
|
||||
export declare const BOX_DIRECONNECT_PLATFORM_FILTER: {
|
||||
filtervmsplatformList: {
|
||||
opt: OPT;
|
||||
vmsplatformOpt: VmsplatformOpt;
|
||||
value: string;
|
||||
}[];
|
||||
};
|
40
packages/func/es/camera/index.d.ts
vendored
40
packages/func/es/camera/index.d.ts
vendored
@ -1,40 +0,0 @@
|
||||
import { DevicemanagerCameraType } from './constants';
|
||||
export declare const isFaceCamera: (type: DevicemanagerCameraType) => boolean;
|
||||
/**
|
||||
*
|
||||
* @param value 传入的数据 可以是 item(camera/vms/dirs)/ deviceID
|
||||
* @param isId
|
||||
*/
|
||||
export declare function getDeviceType(value: {
|
||||
[x: string]: any;
|
||||
id: any;
|
||||
} | string): any;
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param id 设备id
|
||||
* @param type 设备类型
|
||||
*/
|
||||
export declare function deviceIDToDeviceKey(id: any, type: string, vmsId?: any): string;
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param item camera/vms/dirs
|
||||
*/
|
||||
export declare function deviceToDeviceKey(item: {
|
||||
[x: string]: any;
|
||||
id: any;
|
||||
}): string;
|
||||
/**
|
||||
* 设备树key 转 后端设备原始id dirid是string/vms&camera 是number 和后端保持一致
|
||||
* @param deviceKey 设备树的id
|
||||
*/
|
||||
export declare function deviceKeyToDeviceId(deviceKey: {
|
||||
split: (arg0: string) => [any, any];
|
||||
}): any;
|
||||
export declare const getVmsIdByDeviceId: (key: string) => string;
|
||||
/**
|
||||
* 通过设备id或设备key在树里面找摄像头
|
||||
* @param ids cameraId
|
||||
* @param deviceTree 树
|
||||
* @param type "id" | "key"
|
||||
*/
|
||||
export declare const findCamerasByInDeviceTree: (ids: never[] | undefined, deviceTree: any, type?: string) => any[];
|
75
packages/func/es/file/index.d.ts
vendored
75
packages/func/es/file/index.d.ts
vendored
@ -1,75 +0,0 @@
|
||||
import { Rect } from '@zhst/types';
|
||||
/**
|
||||
*
|
||||
* @param url 需要转为图片的链接
|
||||
* @returns 图片的 dom
|
||||
*/
|
||||
export declare const urlToImg: (url: string) => Promise<HTMLImageElement>;
|
||||
export declare const base64DecodeImageKey: (base64ImgKey: string) => string;
|
||||
/**
|
||||
* 通过url获取图片的base64字符串
|
||||
* @param src 图片链接
|
||||
* @param outputFormat 图片格式
|
||||
* @returns base64 @string
|
||||
*/
|
||||
export declare const getBase64ByUrl: (src: string | URL, outputFormat?: string) => Promise<unknown>;
|
||||
/**
|
||||
* 把文件转base64
|
||||
* @param file @file 文件
|
||||
* @returns @string
|
||||
*/
|
||||
export declare const fileToBase64: (file: any) => Promise<string>;
|
||||
/**
|
||||
*
|
||||
* @param image @file 图片文件
|
||||
* @param width @number 宽度
|
||||
* @param height @number 高度
|
||||
* @returns @string base64
|
||||
*/
|
||||
export declare const getBase64Image: (image: any, width?: any, height?: any) => string;
|
||||
/**
|
||||
* 通过图片获取base64
|
||||
* @param src 图片地址
|
||||
* @returns @string
|
||||
*/
|
||||
export declare const getBase64ByImage: (src: string) => Promise<unknown>;
|
||||
/**
|
||||
* url转base64
|
||||
* @param {String} url - url地址
|
||||
*/
|
||||
export declare const urlToBase64V2: (url: string) => Promise<unknown>;
|
||||
/**
|
||||
* base64转Blob
|
||||
* @param {String} base64 - base64
|
||||
*/
|
||||
export declare function base64toBlob(base64: string): Blob | undefined;
|
||||
/**
|
||||
* 图片集打包压缩下载
|
||||
* 1. url -> base64 -> blob
|
||||
* 2. 将blob加入jsZip文件夹内,用file-saver保存
|
||||
* @param {Array<{url:string,name:string}>} imgDataList
|
||||
* @param {string} zipName
|
||||
*/
|
||||
export declare const downloadPackageImages: (imgDataList: string | any[], zipName: string) => Promise<void>;
|
||||
export declare function getFileSize(size: number): string;
|
||||
export declare const dataURLToBlob: (dataurl: string) => Blob;
|
||||
/**
|
||||
* key 转 http 链接
|
||||
* @param originImgkey 图片的值 ,可以是 base64 也可以是 http链接
|
||||
* @param host 图片的域值
|
||||
* @returns {string}
|
||||
*/
|
||||
export declare const generateImg: (imgKey: string, host?: string) => string;
|
||||
/**
|
||||
* 获取指定字符串后面的部分
|
||||
* @param imageKey v1_开头的字符串
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageKey: (imageKey: string, preFix?: string) => string;
|
||||
/**
|
||||
* 获取图片
|
||||
* @param img 图片的url链接
|
||||
* @param odRect
|
||||
* @returns file
|
||||
*/
|
||||
export declare const getFileByRect: (img: string, odRect: Rect) => Promise<File>;
|
11
packages/func/es/index.d.ts
vendored
11
packages/func/es/index.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
export * from 'lodash-es';
|
||||
export * from './file';
|
||||
export * from './map';
|
||||
export * from './performance';
|
||||
export * from './string';
|
||||
export * from './number';
|
||||
export * from './time';
|
||||
export * from './utils';
|
||||
export * from './camera';
|
||||
export * from './math';
|
||||
export * from './upload';
|
10
packages/func/es/map/index.d.ts
vendored
10
packages/func/es/map/index.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
/**
|
||||
* 获取经纬信息
|
||||
* @param lngLat 位置信息
|
||||
* @returns @object { long, lat }
|
||||
*/
|
||||
export declare const fixedLngLat: (lngLat?: string) => string;
|
||||
export declare const transformLngLat: (lngLat?: string) => {
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
} | null;
|
70
packages/func/es/math/index.d.ts
vendored
70
packages/func/es/math/index.d.ts
vendored
@ -1,70 +0,0 @@
|
||||
import { IOdRectOrigin, Rect } from '@zhst/types';
|
||||
export declare const ALGORITHM_VERSION: {
|
||||
7: string;
|
||||
4: string;
|
||||
6: string;
|
||||
};
|
||||
export declare const algorithmVersions: string[];
|
||||
export declare const getBikeExtendRect: (rect: Rect, maxW: number) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getOtherExtendRect: (srcRect: Rect, maxW: number, maxH: number, type: string) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getNormalization: (srcRect: Rect, maxW: number, maxH: number) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getExtendRect: (normalizationRect: Rect, imgW: number, imgH: number, type: string) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getTransformRect: (image: {
|
||||
height: number;
|
||||
width: number;
|
||||
}, transform: {
|
||||
translateX: any;
|
||||
translateY: any;
|
||||
scale: any;
|
||||
rotate: any;
|
||||
}, rect: Rect) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getRotateImg: (image: HTMLImageElement, rotate: number) => File;
|
||||
/**
|
||||
* 格式化工具
|
||||
* @param originData
|
||||
* @returns
|
||||
*/
|
||||
export declare const getOdRect: (originData: IOdRectOrigin) => {
|
||||
x: any;
|
||||
y: any;
|
||||
w: any;
|
||||
h: any;
|
||||
id: any;
|
||||
qualityScore: any;
|
||||
algorithmVersion: string;
|
||||
featureData: any;
|
||||
objectRectIndex: number;
|
||||
objectType: any;
|
||||
objectId: any;
|
||||
frameTimestamp: any;
|
||||
sourceObjectId: any;
|
||||
extendBox: any;
|
||||
}[];
|
||||
export declare const getOdRectV2: (originData: {
|
||||
odv2Result: any[];
|
||||
}) => any;
|
14
packages/func/es/number/index.d.ts
vendored
14
packages/func/es/number/index.d.ts
vendored
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* 设置数据的精度
|
||||
* @param originNumber
|
||||
* @param accuracy 精度 以原点为中心向左为正,向右为负,
|
||||
* @param isCeil 是否为向上取整
|
||||
* @returns number
|
||||
*/
|
||||
export declare const setNumberAccuracy: (originNumber: number, accuracy?: number, isCeil?: boolean) => number;
|
||||
/**
|
||||
* 获取数字
|
||||
* @param number 需要校验的数值
|
||||
* @returns @number
|
||||
*/
|
||||
export declare const toRealNumber: (number: any) => any;
|
1
packages/func/es/performance/index.d.ts
vendored
1
packages/func/es/performance/index.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare const speedConvert: (bps: number, contertUnit?: number) => string;
|
7
packages/func/es/string/index.d.ts
vendored
7
packages/func/es/string/index.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
export declare const getStrLength: (str: string) => number;
|
||||
/**
|
||||
* js截取字符串,中英文都能用
|
||||
* @param str:需要截取的字符串
|
||||
* @param len: 需要截取的长度
|
||||
*/
|
||||
export declare const cutStr: (str: string, len: number) => string | String | undefined;
|
11
packages/func/es/time/index.d.ts
vendored
11
packages/func/es/time/index.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
export declare const formateDuration: (diff: number) => string;
|
||||
export declare function generateTime(): {
|
||||
startDateTime: number;
|
||||
endDateTime: number;
|
||||
};
|
||||
/**
|
||||
* 格式化时间为 00:00
|
||||
* @param seconds 时间,单位秒
|
||||
* @returns
|
||||
*/
|
||||
export declare function formatDurationTime(seconds: number): string;
|
8
packages/func/es/upload/index.d.ts
vendored
8
packages/func/es/upload/index.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
type uploadOption = {
|
||||
bucket?: string;
|
||||
dir?: string;
|
||||
withSuFuffix?: boolean;
|
||||
};
|
||||
export declare const commonUpload: (file: File, option: uploadOption | undefined, type: string) => Promise<unknown>;
|
||||
export declare const upload: (file: File, option?: uploadOption) => Promise<unknown>;
|
||||
export {};
|
36
packages/func/es/utils/index.d.ts
vendored
36
packages/func/es/utils/index.d.ts
vendored
@ -1,36 +0,0 @@
|
||||
export { default as isChrome } from './isChrome';
|
||||
export declare const matchS3Prefix: (str: string) => boolean;
|
||||
/**
|
||||
* 通过文件名获取文件类型
|
||||
* @param fileName 文件名称
|
||||
* @returns 文件类型
|
||||
*/
|
||||
export declare const getFileSuffix: (fileName: string) => string;
|
||||
/**
|
||||
* 通过类型获取文件名
|
||||
* @param type 类型
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageSuffixByFileType: (type: string) => string;
|
||||
export declare function getChromeVersion(): number | false;
|
||||
export declare const nextTick: (func: (value: void) => void | PromiseLike<void>) => void;
|
||||
export declare const loop: (items: string | any[], callback: (arg0: any) => any) => void;
|
||||
export declare const addEventListenerWrapper: (target: any, eventType: string, cb: any, option?: any) => {
|
||||
remove: () => void;
|
||||
};
|
||||
/**
|
||||
* Get transforms base on the given object.
|
||||
* @param {Object} obj - The target object.
|
||||
* @returns {string} A string contains transform values.
|
||||
*/
|
||||
export declare function getTransforms({ rotate, scaleX, scaleY, translateX, translateY, }: {
|
||||
rotate?: number;
|
||||
scaleX?: number;
|
||||
scaleY?: number;
|
||||
translateX?: number;
|
||||
translateY?: number;
|
||||
}): {
|
||||
WebkitTransform: string;
|
||||
msTransform: string;
|
||||
transform: string;
|
||||
};
|
3
packages/func/es/utils/isChrome.d.ts
vendored
3
packages/func/es/utils/isChrome.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export declare const isBrowser: boolean;
|
||||
declare const isChrome: () => boolean;
|
||||
export default isChrome;
|
41
packages/func/lib/camera/constants.d.ts
vendored
41
packages/func/lib/camera/constants.d.ts
vendored
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* 设备类型枚举
|
||||
*/
|
||||
export declare const DeviceType: {
|
||||
VMS: string;
|
||||
DIR: string;
|
||||
CAMERA: string;
|
||||
};
|
||||
export declare const LOCAL_KEY = "local";
|
||||
export declare const DIRE_CONNECT_KEY = "direconnect";
|
||||
export declare const BOX_LIST_KEY = "boxlist";
|
||||
export declare enum VmsplatformOpt {
|
||||
VMSPLATFORMOPT_ID = 0,
|
||||
VMSPLATFORMOPT_PLATFORMNAME = 1,
|
||||
VMSPLATFORMOPT_PLUGINNAME = 2,
|
||||
VMSPLATFORMOPT_IP = 3,
|
||||
VMSPLATFORMOPT_PORT = 4,
|
||||
VMSPLATFORMOPT_USERNAME = 5,
|
||||
VMSPLATFORMOPT_PASSWORD = 6
|
||||
}
|
||||
export declare enum OPT {
|
||||
OR = 0,
|
||||
AND = 1,
|
||||
ORNOT = 2,
|
||||
ANDNOT = 3
|
||||
}
|
||||
export declare enum DevicemanagerCameraType {
|
||||
DEVICEMANAGER_CAMERA_TYPE_DEFAULT = 0,
|
||||
DEVICEMANAGER_CAMERA_TYPE_NORMAL = 1,
|
||||
DEVICEMANAGER_CAMERA_TYPE_1400 = 97,
|
||||
DEVICEMANAGER_CAMERA_TYPE_DHGRABBER = 98,
|
||||
DEVICEMANAGER_CAMERA_TYPE_HKGRABBER = 99,
|
||||
DEVICEMANAGER_CAMERA_TYPE_LOCAL = 100
|
||||
}
|
||||
export declare const BOX_DIRECONNECT_PLATFORM_FILTER: {
|
||||
filtervmsplatformList: {
|
||||
opt: OPT;
|
||||
vmsplatformOpt: VmsplatformOpt;
|
||||
value: string;
|
||||
}[];
|
||||
};
|
@ -1,90 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/camera/constants.ts
|
||||
var constants_exports = {};
|
||||
__export(constants_exports, {
|
||||
BOX_DIRECONNECT_PLATFORM_FILTER: () => BOX_DIRECONNECT_PLATFORM_FILTER,
|
||||
BOX_LIST_KEY: () => BOX_LIST_KEY,
|
||||
DIRE_CONNECT_KEY: () => DIRE_CONNECT_KEY,
|
||||
DeviceType: () => DeviceType,
|
||||
DevicemanagerCameraType: () => DevicemanagerCameraType,
|
||||
LOCAL_KEY: () => LOCAL_KEY,
|
||||
OPT: () => OPT,
|
||||
VmsplatformOpt: () => VmsplatformOpt
|
||||
});
|
||||
module.exports = __toCommonJS(constants_exports);
|
||||
var DeviceType = {
|
||||
VMS: "vms",
|
||||
DIR: "dir",
|
||||
CAMERA: "camera"
|
||||
};
|
||||
var LOCAL_KEY = "local";
|
||||
var DIRE_CONNECT_KEY = "direconnect";
|
||||
var BOX_LIST_KEY = "boxlist";
|
||||
var VmsplatformOpt = /* @__PURE__ */ ((VmsplatformOpt2) => {
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_ID"] = 0] = "VMSPLATFORMOPT_ID";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_PLATFORMNAME"] = 1] = "VMSPLATFORMOPT_PLATFORMNAME";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_PLUGINNAME"] = 2] = "VMSPLATFORMOPT_PLUGINNAME";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_IP"] = 3] = "VMSPLATFORMOPT_IP";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_PORT"] = 4] = "VMSPLATFORMOPT_PORT";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_USERNAME"] = 5] = "VMSPLATFORMOPT_USERNAME";
|
||||
VmsplatformOpt2[VmsplatformOpt2["VMSPLATFORMOPT_PASSWORD"] = 6] = "VMSPLATFORMOPT_PASSWORD";
|
||||
return VmsplatformOpt2;
|
||||
})(VmsplatformOpt || {});
|
||||
var OPT = /* @__PURE__ */ ((OPT2) => {
|
||||
OPT2[OPT2["OR"] = 0] = "OR";
|
||||
OPT2[OPT2["AND"] = 1] = "AND";
|
||||
OPT2[OPT2["ORNOT"] = 2] = "ORNOT";
|
||||
OPT2[OPT2["ANDNOT"] = 3] = "ANDNOT";
|
||||
return OPT2;
|
||||
})(OPT || {});
|
||||
var DevicemanagerCameraType = /* @__PURE__ */ ((DevicemanagerCameraType2) => {
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_DEFAULT"] = 0] = "DEVICEMANAGER_CAMERA_TYPE_DEFAULT";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_NORMAL"] = 1] = "DEVICEMANAGER_CAMERA_TYPE_NORMAL";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_1400"] = 97] = "DEVICEMANAGER_CAMERA_TYPE_1400";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_DHGRABBER"] = 98] = "DEVICEMANAGER_CAMERA_TYPE_DHGRABBER";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_HKGRABBER"] = 99] = "DEVICEMANAGER_CAMERA_TYPE_HKGRABBER";
|
||||
DevicemanagerCameraType2[DevicemanagerCameraType2["DEVICEMANAGER_CAMERA_TYPE_LOCAL"] = 100] = "DEVICEMANAGER_CAMERA_TYPE_LOCAL";
|
||||
return DevicemanagerCameraType2;
|
||||
})(DevicemanagerCameraType || {});
|
||||
var BOX_DIRECONNECT_PLATFORM_FILTER = {
|
||||
filtervmsplatformList: [
|
||||
{
|
||||
opt: 0 /* OR */,
|
||||
vmsplatformOpt: 1 /* VMSPLATFORMOPT_PLATFORMNAME */,
|
||||
value: "direconnect"
|
||||
},
|
||||
{
|
||||
opt: 0 /* OR */,
|
||||
vmsplatformOpt: 1 /* VMSPLATFORMOPT_PLATFORMNAME */,
|
||||
value: "boxlist"
|
||||
}
|
||||
]
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BOX_DIRECONNECT_PLATFORM_FILTER,
|
||||
BOX_LIST_KEY,
|
||||
DIRE_CONNECT_KEY,
|
||||
DeviceType,
|
||||
DevicemanagerCameraType,
|
||||
LOCAL_KEY,
|
||||
OPT,
|
||||
VmsplatformOpt
|
||||
});
|
40
packages/func/lib/camera/index.d.ts
vendored
40
packages/func/lib/camera/index.d.ts
vendored
@ -1,40 +0,0 @@
|
||||
import { DevicemanagerCameraType } from './constants';
|
||||
export declare const isFaceCamera: (type: DevicemanagerCameraType) => boolean;
|
||||
/**
|
||||
*
|
||||
* @param value 传入的数据 可以是 item(camera/vms/dirs)/ deviceID
|
||||
* @param isId
|
||||
*/
|
||||
export declare function getDeviceType(value: {
|
||||
[x: string]: any;
|
||||
id: any;
|
||||
} | string): any;
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param id 设备id
|
||||
* @param type 设备类型
|
||||
*/
|
||||
export declare function deviceIDToDeviceKey(id: any, type: string, vmsId?: any): string;
|
||||
/**
|
||||
* 后端设备id/vmsid/dirid是三张表 合并在一起不保证唯一 前端生成唯一key
|
||||
* @param item camera/vms/dirs
|
||||
*/
|
||||
export declare function deviceToDeviceKey(item: {
|
||||
[x: string]: any;
|
||||
id: any;
|
||||
}): string;
|
||||
/**
|
||||
* 设备树key 转 后端设备原始id dirid是string/vms&camera 是number 和后端保持一致
|
||||
* @param deviceKey 设备树的id
|
||||
*/
|
||||
export declare function deviceKeyToDeviceId(deviceKey: {
|
||||
split: (arg0: string) => [any, any];
|
||||
}): any;
|
||||
export declare const getVmsIdByDeviceId: (key: string) => string;
|
||||
/**
|
||||
* 通过设备id或设备key在树里面找摄像头
|
||||
* @param ids cameraId
|
||||
* @param deviceTree 树
|
||||
* @param type "id" | "key"
|
||||
*/
|
||||
export declare const findCamerasByInDeviceTree: (ids: never[] | undefined, deviceTree: any, type?: string) => any[];
|
@ -1,143 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/camera/index.ts
|
||||
var camera_exports = {};
|
||||
__export(camera_exports, {
|
||||
deviceIDToDeviceKey: () => deviceIDToDeviceKey,
|
||||
deviceKeyToDeviceId: () => deviceKeyToDeviceId,
|
||||
deviceToDeviceKey: () => deviceToDeviceKey,
|
||||
findCamerasByInDeviceTree: () => findCamerasByInDeviceTree,
|
||||
getDeviceType: () => getDeviceType,
|
||||
getVmsIdByDeviceId: () => getVmsIdByDeviceId,
|
||||
isFaceCamera: () => isFaceCamera
|
||||
});
|
||||
module.exports = __toCommonJS(camera_exports);
|
||||
var import_lodash_es = require("lodash-es");
|
||||
var import_utils = require("../utils");
|
||||
var import_constants = require("./constants");
|
||||
var isFaceCamera = (type) => {
|
||||
return [
|
||||
import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_1400,
|
||||
import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_HKGRABBER,
|
||||
import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_DHGRABBER
|
||||
].includes(type);
|
||||
};
|
||||
function getDeviceType(value) {
|
||||
let type;
|
||||
let isDeviceKey = (0, import_lodash_es.isString)(value);
|
||||
if (isDeviceKey) {
|
||||
type = value.split("_")[0];
|
||||
} else {
|
||||
if ((0, import_lodash_es.has)(value, "longitude")) {
|
||||
type = import_constants.DeviceType["CAMERA"];
|
||||
}
|
||||
if ((0, import_lodash_es.has)(value, "ip")) {
|
||||
type = import_constants.DeviceType["VMS"];
|
||||
}
|
||||
if (!type) {
|
||||
type = import_constants.DeviceType["DIR"];
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
function deviceIDToDeviceKey(id, type, vmsId) {
|
||||
if (type == import_constants.DeviceType["DIR"]) {
|
||||
return `${type}_${id}_${vmsId}`;
|
||||
} else {
|
||||
return `${type}_${id}`;
|
||||
}
|
||||
}
|
||||
function deviceToDeviceKey(item) {
|
||||
let deviceKey = "";
|
||||
let type = getDeviceType(item);
|
||||
if (!type) {
|
||||
console.error("device type is null!");
|
||||
}
|
||||
switch (type) {
|
||||
case import_constants.DeviceType["DIR"]:
|
||||
{
|
||||
let dirId = item["dirid"] || item["dirId"];
|
||||
if (!dirId && dirId !== 0) {
|
||||
console.error("dirId type is null!");
|
||||
}
|
||||
let vmsId = (0, import_lodash_es.get)(item, "extendInfo.vmsPlatformId");
|
||||
if (!vmsId && vmsId !== 0) {
|
||||
console.error("vmsId type is null!");
|
||||
}
|
||||
deviceKey = `${type}_${dirId}_${vmsId}`;
|
||||
}
|
||||
break;
|
||||
case import_constants.DeviceType["VMS"]:
|
||||
deviceKey = `${type}_${item["id"]}`;
|
||||
break;
|
||||
case import_constants.DeviceType["CAMERA"]:
|
||||
{
|
||||
let vmsId = (0, import_lodash_es.get)(item, "extendInfo.vmsPlatformId");
|
||||
if (!vmsId && vmsId !== 0) {
|
||||
console.error("vmsId type is null!");
|
||||
}
|
||||
deviceKey = `${type}_${item.id}`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return deviceKey;
|
||||
}
|
||||
function deviceKeyToDeviceId(deviceKey) {
|
||||
let [type, id] = deviceKey.split("_");
|
||||
return type === import_constants.DeviceType["DIR"] ? id : Number(id);
|
||||
}
|
||||
var getVmsIdByDeviceId = (key) => {
|
||||
const type = getDeviceType(key);
|
||||
let vmsId = "";
|
||||
switch (type) {
|
||||
case import_constants.DeviceType["CAMERA"]:
|
||||
case import_constants.DeviceType["DIR"]:
|
||||
vmsId = key.split("_")[2];
|
||||
break;
|
||||
case import_constants.DeviceType["VMS"]:
|
||||
vmsId = key.split("_")[1];
|
||||
break;
|
||||
}
|
||||
if (!vmsId) {
|
||||
console.error("vmsid is null!");
|
||||
}
|
||||
return vmsId;
|
||||
};
|
||||
var findCamerasByInDeviceTree = (ids = [], deviceTree, type = "id") => {
|
||||
let cameraInfoList = [];
|
||||
let _ids = ids.map((v) => String(v));
|
||||
(0, import_utils.loop)(deviceTree, (item) => {
|
||||
let isCamera = getDeviceType((0, import_lodash_es.get)(item, "key", "")) === import_constants.DeviceType["CAMERA"];
|
||||
let isMatch = type === "key" ? _ids.includes((0, import_lodash_es.get)(item, "key")) : _ids.includes(`${(0, import_lodash_es.get)(item, "origin.id")}`);
|
||||
if (isCamera && isMatch) {
|
||||
cameraInfoList.push(item);
|
||||
}
|
||||
});
|
||||
return cameraInfoList;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
deviceIDToDeviceKey,
|
||||
deviceKeyToDeviceId,
|
||||
deviceToDeviceKey,
|
||||
findCamerasByInDeviceTree,
|
||||
getDeviceType,
|
||||
getVmsIdByDeviceId,
|
||||
isFaceCamera
|
||||
});
|
75
packages/func/lib/file/index.d.ts
vendored
75
packages/func/lib/file/index.d.ts
vendored
@ -1,75 +0,0 @@
|
||||
import { Rect } from '@zhst/types';
|
||||
/**
|
||||
*
|
||||
* @param url 需要转为图片的链接
|
||||
* @returns 图片的 dom
|
||||
*/
|
||||
export declare const urlToImg: (url: string) => Promise<HTMLImageElement>;
|
||||
export declare const base64DecodeImageKey: (base64ImgKey: string) => string;
|
||||
/**
|
||||
* 通过url获取图片的base64字符串
|
||||
* @param src 图片链接
|
||||
* @param outputFormat 图片格式
|
||||
* @returns base64 @string
|
||||
*/
|
||||
export declare const getBase64ByUrl: (src: string | URL, outputFormat?: string) => Promise<unknown>;
|
||||
/**
|
||||
* 把文件转base64
|
||||
* @param file @file 文件
|
||||
* @returns @string
|
||||
*/
|
||||
export declare const fileToBase64: (file: any) => Promise<string>;
|
||||
/**
|
||||
*
|
||||
* @param image @file 图片文件
|
||||
* @param width @number 宽度
|
||||
* @param height @number 高度
|
||||
* @returns @string base64
|
||||
*/
|
||||
export declare const getBase64Image: (image: any, width?: any, height?: any) => string;
|
||||
/**
|
||||
* 通过图片获取base64
|
||||
* @param src 图片地址
|
||||
* @returns @string
|
||||
*/
|
||||
export declare const getBase64ByImage: (src: string) => Promise<unknown>;
|
||||
/**
|
||||
* url转base64
|
||||
* @param {String} url - url地址
|
||||
*/
|
||||
export declare const urlToBase64V2: (url: string) => Promise<unknown>;
|
||||
/**
|
||||
* base64转Blob
|
||||
* @param {String} base64 - base64
|
||||
*/
|
||||
export declare function base64toBlob(base64: string): Blob | undefined;
|
||||
/**
|
||||
* 图片集打包压缩下载
|
||||
* 1. url -> base64 -> blob
|
||||
* 2. 将blob加入jsZip文件夹内,用file-saver保存
|
||||
* @param {Array<{url:string,name:string}>} imgDataList
|
||||
* @param {string} zipName
|
||||
*/
|
||||
export declare const downloadPackageImages: (imgDataList: string | any[], zipName: string) => Promise<void>;
|
||||
export declare function getFileSize(size: number): string;
|
||||
export declare const dataURLToBlob: (dataurl: string) => Blob;
|
||||
/**
|
||||
* key 转 http 链接
|
||||
* @param originImgkey 图片的值 ,可以是 base64 也可以是 http链接
|
||||
* @param host 图片的域值
|
||||
* @returns {string}
|
||||
*/
|
||||
export declare const generateImg: (imgKey: string, host?: string) => string;
|
||||
/**
|
||||
* 获取指定字符串后面的部分
|
||||
* @param imageKey v1_开头的字符串
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageKey: (imageKey: string, preFix?: string) => string;
|
||||
/**
|
||||
* 获取图片
|
||||
* @param img 图片的url链接
|
||||
* @param odRect
|
||||
* @returns file
|
||||
*/
|
||||
export declare const getFileByRect: (img: string, odRect: Rect) => Promise<File>;
|
@ -1,318 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/file/index.ts
|
||||
var file_exports = {};
|
||||
__export(file_exports, {
|
||||
base64DecodeImageKey: () => base64DecodeImageKey,
|
||||
base64toBlob: () => base64toBlob,
|
||||
dataURLToBlob: () => dataURLToBlob,
|
||||
downloadPackageImages: () => downloadPackageImages,
|
||||
fileToBase64: () => fileToBase64,
|
||||
generateImg: () => generateImg,
|
||||
getBase64ByImage: () => getBase64ByImage,
|
||||
getBase64ByUrl: () => getBase64ByUrl,
|
||||
getBase64Image: () => getBase64Image,
|
||||
getFileByRect: () => getFileByRect,
|
||||
getFileSize: () => getFileSize,
|
||||
getImageKey: () => getImageKey,
|
||||
urlToBase64V2: () => urlToBase64V2,
|
||||
urlToImg: () => urlToImg
|
||||
});
|
||||
module.exports = __toCommonJS(file_exports);
|
||||
var import_base_64 = __toESM(require("base-64"));
|
||||
var import_jszip = __toESM(require("jszip"));
|
||||
var import_file_saver = __toESM(require("file-saver"));
|
||||
var import_utils = require("../utils");
|
||||
var import_lodash_es = require("lodash-es");
|
||||
var urlToImg = (url) => {
|
||||
const resImage = new Promise((resolve) => {
|
||||
const image = new Image();
|
||||
image.crossOrigin = "";
|
||||
image.src = url;
|
||||
image.onload = () => {
|
||||
resolve(image);
|
||||
};
|
||||
});
|
||||
return resImage;
|
||||
};
|
||||
var base64DecodeImageKey = (base64ImgKey) => {
|
||||
let tempStr = base64ImgKey;
|
||||
if ((0, import_utils.matchS3Prefix)(tempStr)) {
|
||||
tempStr = tempStr.replace(/^v[0-9]_/, "");
|
||||
tempStr = import_base_64.default.decode(tempStr);
|
||||
}
|
||||
const [bucket, ...pathArr] = tempStr.split("_");
|
||||
return tempStr = `${bucket}/${pathArr.join("_")}`;
|
||||
};
|
||||
var getBase64ByUrl = function(src, outputFormat = "image/png") {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", src, true);
|
||||
xhr.responseType = "arraybuffer";
|
||||
xhr.onload = function(e) {
|
||||
if (Number(xhr.status) === 200) {
|
||||
const uInt8Array = new Uint8Array(xhr.response);
|
||||
let i = uInt8Array.length;
|
||||
const binaryString = new Array(i);
|
||||
while (i--) {
|
||||
binaryString[i] = String.fromCharCode(uInt8Array[i]);
|
||||
}
|
||||
const data = binaryString.join("");
|
||||
const base64 = window.btoa(data);
|
||||
const dataUrl = "data:" + (outputFormat || "image/png") + ";base64," + base64;
|
||||
resolve(dataUrl);
|
||||
} else {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
xhr.onerror = (e) => {
|
||||
reject(e);
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
};
|
||||
var fileToBase64 = (file) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = function(e) {
|
||||
resolve(e == null ? void 0 : e.target.result);
|
||||
};
|
||||
reader.onerror = function(e) {
|
||||
reject(e);
|
||||
};
|
||||
});
|
||||
};
|
||||
var getBase64Image = (image, width, height) => {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = width !== void 0 ? width : image.width;
|
||||
canvas.height = height !== void 0 ? height : image.height;
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx == null ? void 0 : ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||
const ext = image.src.substring(image.src.lastIndexOf(".") + 1).toLowerCase();
|
||||
const dataURL = canvas.toDataURL("image/" + ext);
|
||||
return dataURL;
|
||||
};
|
||||
var getBase64ByImage = function(src) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const image = new Image();
|
||||
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
||||
const imgUrl = src + "?" + timestamp;
|
||||
image.src = imgUrl;
|
||||
image.onload = function() {
|
||||
function getBase64Image2(img) {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = img.width;
|
||||
canvas.height = img.height;
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx == null ? void 0 : ctx.drawImage(img, 0, 0, img.width, img.height);
|
||||
const ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
|
||||
const dataURL = canvas.toDataURL("image/" + ext);
|
||||
return dataURL;
|
||||
}
|
||||
const base64 = getBase64Image2(image);
|
||||
resolve(base64);
|
||||
};
|
||||
image.onerror = (e) => {
|
||||
reject(e);
|
||||
};
|
||||
});
|
||||
};
|
||||
var urlToBase64V2 = (url) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let image = new Image();
|
||||
image.onload = function() {
|
||||
var _a;
|
||||
let canvas = document.createElement("canvas");
|
||||
canvas.width = image.naturalWidth;
|
||||
canvas.height = image.naturalHeight;
|
||||
(_a = canvas == null ? void 0 : canvas.getContext("2d")) == null ? void 0 : _a.drawImage(image, 0, 0);
|
||||
let result = canvas.toDataURL("image/png");
|
||||
resolve(result);
|
||||
};
|
||||
const imgUrl = url;
|
||||
image.setAttribute("crossOrigin", "Anonymous");
|
||||
image.src = imgUrl;
|
||||
image.onerror = () => {
|
||||
reject(new Error("Images fail to load"));
|
||||
};
|
||||
}).catch((error) => {
|
||||
throw new Error(error);
|
||||
});
|
||||
};
|
||||
function base64toBlob(base64) {
|
||||
if (!base64)
|
||||
return;
|
||||
var arr = base64.split(","), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new Blob([u8arr], { type: mime });
|
||||
}
|
||||
var downloadPackageImages = async (imgDataList, zipName) => {
|
||||
let imgDataDownLoadList = [];
|
||||
let imgBlobList = [];
|
||||
let imageSuffix = [];
|
||||
let zip = new import_jszip.default();
|
||||
let img = zip.folder(zipName);
|
||||
try {
|
||||
for (let i2 = 0; i2 < imgDataList.length; i2++) {
|
||||
let src = imgDataList[i2].url;
|
||||
let suffix = src.substring(src.lastIndexOf("."));
|
||||
let base64ByUrl = await urlToBase64V2(imgDataList[i2].url);
|
||||
if (!base64ByUrl)
|
||||
continue;
|
||||
let blob = base64toBlob(base64ByUrl);
|
||||
imgDataDownLoadList.push(imgDataList[i2]);
|
||||
imgBlobList.push(blob);
|
||||
imageSuffix.push(suffix);
|
||||
}
|
||||
if (imgBlobList.length === 0)
|
||||
throw new Error("The number of pictures is zero !");
|
||||
if (imgBlobList.length > 0) {
|
||||
for (var i = 0; i < imgBlobList.length; i++) {
|
||||
img == null ? void 0 : img.file(
|
||||
imgDataDownLoadList[i].name + (0, import_lodash_es.get)(imageSuffix, `.${i}`, imageSuffix[0]),
|
||||
// @ts-ignore
|
||||
imgBlobList[i],
|
||||
{
|
||||
base64: true
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
zip.generateAsync({ type: "blob" }).then(function(content) {
|
||||
import_file_saver.default.saveAs(content, zipName + ".zip");
|
||||
});
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
};
|
||||
function getFileSize(size) {
|
||||
if (!size)
|
||||
return "";
|
||||
var num = 1024;
|
||||
if (size < num)
|
||||
return size + "B";
|
||||
if (size < Math.pow(num, 2))
|
||||
return (size / num).toFixed(2) + "K";
|
||||
if (size < Math.pow(num, 3))
|
||||
return (size / Math.pow(num, 2)).toFixed(2) + "M";
|
||||
if (size < Math.pow(num, 4))
|
||||
return (size / Math.pow(num, 3)).toFixed(2) + "G";
|
||||
return (size / Math.pow(num, 4)).toFixed(2) + "T";
|
||||
}
|
||||
var dataURLToBlob = (dataurl) => {
|
||||
const arr = dataurl.split(",");
|
||||
const mime = arr[0].match(/:(.*?);/)[1];
|
||||
const bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
const u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new Blob([u8arr], { type: mime });
|
||||
};
|
||||
var generateImg = (_imgKey, host = "http://10.0.0.120") => {
|
||||
let imgKey = _imgKey;
|
||||
let imgUrl = "";
|
||||
if (!imgKey)
|
||||
return "";
|
||||
if (/(http|https):\/\/([\w.]+\/?)\S*/ig.test(imgKey)) {
|
||||
return imgKey;
|
||||
}
|
||||
console.log("imgKey", imgKey);
|
||||
try {
|
||||
if ((0, import_utils.matchS3Prefix)(imgKey)) {
|
||||
imgKey = base64DecodeImageKey(imgKey);
|
||||
if (imgKey.endsWith("/")) {
|
||||
const i = imgKey.substring(0, imgKey.length - 1);
|
||||
imgKey = i;
|
||||
}
|
||||
}
|
||||
imgUrl = `${host}/file/${imgKey}`;
|
||||
if (_imgKey.includes("v3")) {
|
||||
imgUrl = `${host}/minio/${imgKey}`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
imgUrl = "";
|
||||
}
|
||||
return imgUrl;
|
||||
};
|
||||
var getImageKey = (imageKey, preFix) => {
|
||||
const splitIndex = preFix || "v1_";
|
||||
if (imageKey.startsWith(splitIndex)) {
|
||||
return window.atob(imageKey.split(splitIndex)[1]).replace("_", "/");
|
||||
} else {
|
||||
return imageKey;
|
||||
}
|
||||
};
|
||||
var getFileByRect = async (img, odRect) => {
|
||||
var _a;
|
||||
let image;
|
||||
if ((0, import_lodash_es.isString)(img)) {
|
||||
const url = generateImg(img);
|
||||
image = await urlToImg(url);
|
||||
} else {
|
||||
image = img;
|
||||
}
|
||||
const commonCanvas = document.createElement("canvas");
|
||||
commonCanvas.width = odRect.w * image.width;
|
||||
commonCanvas.height = odRect.h * image.height;
|
||||
commonCanvas.style.display = "none";
|
||||
document.body.appendChild(commonCanvas);
|
||||
const commonCtx = commonCanvas.getContext("2d");
|
||||
commonCtx == null ? void 0 : commonCtx.translate(-odRect.x * image.width, -odRect.y * image.height);
|
||||
commonCtx == null ? void 0 : commonCtx.drawImage(image, 0, 0);
|
||||
const base64 = commonCanvas.toDataURL("image/jpeg");
|
||||
const blobData = dataURLToBlob(base64);
|
||||
(_a = commonCanvas.parentNode) == null ? void 0 : _a.removeChild(commonCanvas);
|
||||
const file = new window.File([blobData], `${(/* @__PURE__ */ new Date()).getTime()}`, {
|
||||
type: "image/jpeg"
|
||||
});
|
||||
return file;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
base64DecodeImageKey,
|
||||
base64toBlob,
|
||||
dataURLToBlob,
|
||||
downloadPackageImages,
|
||||
fileToBase64,
|
||||
generateImg,
|
||||
getBase64ByImage,
|
||||
getBase64ByUrl,
|
||||
getBase64Image,
|
||||
getFileByRect,
|
||||
getFileSize,
|
||||
getImageKey,
|
||||
urlToBase64V2,
|
||||
urlToImg
|
||||
});
|
11
packages/func/lib/index.d.ts
vendored
11
packages/func/lib/index.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
export * from 'lodash-es';
|
||||
export * from './file';
|
||||
export * from './map';
|
||||
export * from './performance';
|
||||
export * from './string';
|
||||
export * from './number';
|
||||
export * from './time';
|
||||
export * from './utils';
|
||||
export * from './camera';
|
||||
export * from './math';
|
||||
export * from './upload';
|
@ -1,43 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
__reExport(src_exports, require("lodash-es"), module.exports);
|
||||
__reExport(src_exports, require("./file"), module.exports);
|
||||
__reExport(src_exports, require("./map"), module.exports);
|
||||
__reExport(src_exports, require("./performance"), module.exports);
|
||||
__reExport(src_exports, require("./string"), module.exports);
|
||||
__reExport(src_exports, require("./number"), module.exports);
|
||||
__reExport(src_exports, require("./time"), module.exports);
|
||||
__reExport(src_exports, require("./utils"), module.exports);
|
||||
__reExport(src_exports, require("./camera"), module.exports);
|
||||
__reExport(src_exports, require("./math"), module.exports);
|
||||
__reExport(src_exports, require("./upload"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
...require("lodash-es"),
|
||||
...require("./file"),
|
||||
...require("./map"),
|
||||
...require("./performance"),
|
||||
...require("./string"),
|
||||
...require("./number"),
|
||||
...require("./time"),
|
||||
...require("./utils"),
|
||||
...require("./camera"),
|
||||
...require("./math"),
|
||||
...require("./upload")
|
||||
});
|
10
packages/func/lib/map/index.d.ts
vendored
10
packages/func/lib/map/index.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
/**
|
||||
* 获取经纬信息
|
||||
* @param lngLat 位置信息
|
||||
* @returns @object { long, lat }
|
||||
*/
|
||||
export declare const fixedLngLat: (lngLat?: string) => string;
|
||||
export declare const transformLngLat: (lngLat?: string) => {
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
} | null;
|
@ -1,54 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/map/index.ts
|
||||
var map_exports = {};
|
||||
__export(map_exports, {
|
||||
fixedLngLat: () => fixedLngLat,
|
||||
transformLngLat: () => transformLngLat
|
||||
});
|
||||
module.exports = __toCommonJS(map_exports);
|
||||
var fixedLngLat = (lngLat) => {
|
||||
if (!lngLat) {
|
||||
return "";
|
||||
}
|
||||
const lngLatArr = lngLat.split(",");
|
||||
const longitude = Number(lngLatArr[0]).toFixed(6);
|
||||
const latitude = Number(lngLatArr[1]).toFixed(6);
|
||||
if (lngLatArr.length < 2) {
|
||||
return "";
|
||||
}
|
||||
return `${longitude},${latitude}`;
|
||||
};
|
||||
var transformLngLat = (lngLat) => {
|
||||
if (lngLat) {
|
||||
const lngLatArr = lngLat ? lngLat.split(",") : [];
|
||||
const longitude = Number(lngLatArr[0]);
|
||||
const latitude = Number(lngLatArr[1]);
|
||||
if (lngLatArr.length < 2) {
|
||||
return null;
|
||||
}
|
||||
return { longitude, latitude };
|
||||
}
|
||||
return null;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
fixedLngLat,
|
||||
transformLngLat
|
||||
});
|
70
packages/func/lib/math/index.d.ts
vendored
70
packages/func/lib/math/index.d.ts
vendored
@ -1,70 +0,0 @@
|
||||
import { IOdRectOrigin, Rect } from '@zhst/types';
|
||||
export declare const ALGORITHM_VERSION: {
|
||||
7: string;
|
||||
4: string;
|
||||
6: string;
|
||||
};
|
||||
export declare const algorithmVersions: string[];
|
||||
export declare const getBikeExtendRect: (rect: Rect, maxW: number) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getOtherExtendRect: (srcRect: Rect, maxW: number, maxH: number, type: string) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getNormalization: (srcRect: Rect, maxW: number, maxH: number) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getExtendRect: (normalizationRect: Rect, imgW: number, imgH: number, type: string) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getTransformRect: (image: {
|
||||
height: number;
|
||||
width: number;
|
||||
}, transform: {
|
||||
translateX: any;
|
||||
translateY: any;
|
||||
scale: any;
|
||||
rotate: any;
|
||||
}, rect: Rect) => {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare const getRotateImg: (image: HTMLImageElement, rotate: number) => File;
|
||||
/**
|
||||
* 格式化工具
|
||||
* @param originData
|
||||
* @returns
|
||||
*/
|
||||
export declare const getOdRect: (originData: IOdRectOrigin) => {
|
||||
x: any;
|
||||
y: any;
|
||||
w: any;
|
||||
h: any;
|
||||
id: any;
|
||||
qualityScore: any;
|
||||
algorithmVersion: string;
|
||||
featureData: any;
|
||||
objectRectIndex: number;
|
||||
objectType: any;
|
||||
objectId: any;
|
||||
frameTimestamp: any;
|
||||
sourceObjectId: any;
|
||||
extendBox: any;
|
||||
}[];
|
||||
export declare const getOdRectV2: (originData: {
|
||||
odv2Result: any[];
|
||||
}) => any;
|
@ -1,358 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/math/index.ts
|
||||
var math_exports = {};
|
||||
__export(math_exports, {
|
||||
ALGORITHM_VERSION: () => ALGORITHM_VERSION,
|
||||
algorithmVersions: () => algorithmVersions,
|
||||
getBikeExtendRect: () => getBikeExtendRect,
|
||||
getExtendRect: () => getExtendRect,
|
||||
getNormalization: () => getNormalization,
|
||||
getOdRect: () => getOdRect,
|
||||
getOdRectV2: () => getOdRectV2,
|
||||
getOtherExtendRect: () => getOtherExtendRect,
|
||||
getRotateImg: () => getRotateImg,
|
||||
getTransformRect: () => getTransformRect
|
||||
});
|
||||
module.exports = __toCommonJS(math_exports);
|
||||
var import_lodash_es = require("lodash-es");
|
||||
var import_file = require("../file");
|
||||
var proto = {
|
||||
Common: {
|
||||
AlgorithmVersion: {
|
||||
VERSION_REID_HEAD_ATTR: "形体",
|
||||
VERSION_FACE: "人脸",
|
||||
VERSION_NON_MOTOR_VEHICLE: "非机动车"
|
||||
}
|
||||
}
|
||||
};
|
||||
var ALGORITHM_VERSION = {
|
||||
["7"]: "形体",
|
||||
["4"]: "人脸",
|
||||
["6"]: "非机动车"
|
||||
};
|
||||
var algorithmVersions = [...Object.keys(ALGORITHM_VERSION)];
|
||||
var getBikeExtendRect = (rect, maxW) => {
|
||||
const newRect = { ...rect };
|
||||
const oldY = (0, import_lodash_es.cloneDeep)(rect.y);
|
||||
newRect.y = newRect.y - newRect.h < 0 ? 0 : newRect.y - newRect.h;
|
||||
newRect.h += oldY - newRect.y;
|
||||
let newX = Math.round(newRect.x - newRect.w * 0.15);
|
||||
if (newX < 0) {
|
||||
newX = 0;
|
||||
}
|
||||
let newW = newRect.x - newX + newRect.w + Math.round(newRect.w * 0.15);
|
||||
if (newX + newW > maxW) {
|
||||
newW = maxW - newX;
|
||||
}
|
||||
newRect.x = newX;
|
||||
newRect.w = newW;
|
||||
return newRect;
|
||||
};
|
||||
var getOtherExtendRect = (srcRect, maxW, maxH, type) => {
|
||||
const wExtendRadio = 0.25;
|
||||
const upExtendRadio = 0.25;
|
||||
const downExtendRadio = 0.25;
|
||||
const fixPersonExtend = true;
|
||||
let nx = 0;
|
||||
let nw = 0;
|
||||
nx = srcRect.x - Math.round(srcRect.w * wExtendRadio);
|
||||
if (nx < 0) {
|
||||
nx = 0;
|
||||
}
|
||||
nw = srcRect.x - nx + srcRect.w + Math.round(srcRect.w * wExtendRadio);
|
||||
if (nx + nw > maxW) {
|
||||
nw = maxW - nx;
|
||||
}
|
||||
let ny = 0;
|
||||
let nh = 0;
|
||||
ny = srcRect.y - Math.round(upExtendRadio * srcRect.h);
|
||||
if (ny < 0) {
|
||||
ny = 0;
|
||||
}
|
||||
nh = srcRect.y - ny + srcRect.h + Math.round(srcRect.h * downExtendRadio);
|
||||
if (ny + nh > maxH) {
|
||||
nh = maxH - ny;
|
||||
}
|
||||
let newRect = {
|
||||
x: nx,
|
||||
y: ny,
|
||||
w: nw,
|
||||
h: nh
|
||||
};
|
||||
if ((type === proto.Common.AlgorithmVersion.VERSION_REID_HEAD_ATTR || type === proto.Common.AlgorithmVersion.VERSION_FACE) && fixPersonExtend) {
|
||||
const fixW = Math.round(nh * 0.75);
|
||||
if (nw < fixW) {
|
||||
let newX = nx + Math.round(nw / 2 - 0.5 * fixW);
|
||||
if (newX < 0) {
|
||||
newX = 0;
|
||||
}
|
||||
let newW = fixW;
|
||||
if (newW + newX > maxW) {
|
||||
newW = maxW - newX;
|
||||
}
|
||||
newRect = {
|
||||
x: newX,
|
||||
y: ny,
|
||||
w: newW,
|
||||
h: nh
|
||||
};
|
||||
} else if (nw > fixW) {
|
||||
const fixH = Math.round(nw * 1.333);
|
||||
let newY = ny + Math.round(nh / 2 - 0.5 * fixH);
|
||||
if (newY < 0) {
|
||||
newY = 0;
|
||||
}
|
||||
let newH = fixH;
|
||||
if (newY + newH > maxH) {
|
||||
newH = maxH - newY;
|
||||
}
|
||||
newRect = {
|
||||
x: nx,
|
||||
y: newY,
|
||||
w: nw,
|
||||
h: newH
|
||||
};
|
||||
}
|
||||
}
|
||||
return newRect;
|
||||
};
|
||||
var getNormalization = (srcRect, maxW, maxH) => {
|
||||
const newRect = {
|
||||
...srcRect
|
||||
};
|
||||
newRect.x = srcRect.x / maxW;
|
||||
newRect.y = srcRect.y / maxH;
|
||||
newRect.w = srcRect.w / maxW;
|
||||
newRect.h = srcRect.h / maxH;
|
||||
if (newRect.x + newRect.w > 1) {
|
||||
newRect.w = 1 - newRect.x;
|
||||
}
|
||||
if (newRect.y + newRect.h > 1) {
|
||||
newRect.h = 1 - newRect.y;
|
||||
}
|
||||
return newRect;
|
||||
};
|
||||
var getExtendRect = (normalizationRect, imgW, imgH, type) => {
|
||||
const rect = {
|
||||
x: normalizationRect.x * imgW,
|
||||
y: normalizationRect.y * imgH,
|
||||
w: normalizationRect.w * imgW,
|
||||
h: normalizationRect.h * imgH
|
||||
};
|
||||
let newRect;
|
||||
if (type === proto.Common.AlgorithmVersion.VERSION_NON_MOTOR_VEHICLE) {
|
||||
newRect = getBikeExtendRect(rect, imgW);
|
||||
} else {
|
||||
newRect = getOtherExtendRect(rect, imgW, imgH, type);
|
||||
}
|
||||
newRect = getNormalization(newRect, imgW, imgH);
|
||||
return newRect;
|
||||
};
|
||||
var getTransformRect = (image, transform, rect) => {
|
||||
const canvasRect = {
|
||||
x: rect.x,
|
||||
y: rect.y,
|
||||
x2: rect.x + rect.w,
|
||||
y2: rect.h + rect.y
|
||||
};
|
||||
const { translateX, translateY, scale, rotate } = transform;
|
||||
const originAxisRect = {
|
||||
x: (canvasRect.x - translateX) / scale,
|
||||
y: (canvasRect.y - translateY) / scale,
|
||||
x2: (canvasRect.x2 - translateX) / scale,
|
||||
y2: (canvasRect.y2 - translateY) / scale
|
||||
};
|
||||
let imgAxisRect = originAxisRect;
|
||||
if (rotate % 180 !== 0) {
|
||||
const offsetX = -(image.height - image.width) / 2;
|
||||
const offsetY = -(image.width - image.height) / 2;
|
||||
imgAxisRect = {
|
||||
x: originAxisRect.x - offsetX,
|
||||
y: originAxisRect.y - offsetY,
|
||||
x2: originAxisRect.x2 - offsetX,
|
||||
y2: originAxisRect.y2 - offsetY
|
||||
};
|
||||
}
|
||||
let imgW = image.width;
|
||||
let imgH = image.height;
|
||||
if (rotate % 180 !== 0) {
|
||||
[imgW, imgH] = [imgH, imgW];
|
||||
}
|
||||
imgAxisRect.x = Math.min(imgW, Math.max(imgAxisRect.x, 0));
|
||||
imgAxisRect.y = Math.min(imgH, Math.max(imgAxisRect.y, 0));
|
||||
imgAxisRect.x2 = Math.min(imgW, Math.max(imgAxisRect.x2, 0));
|
||||
imgAxisRect.y2 = Math.min(imgH, Math.max(imgAxisRect.y2, 0));
|
||||
const endRect = {
|
||||
x: imgAxisRect.x2 > imgAxisRect.x ? imgAxisRect.x : imgAxisRect.x2,
|
||||
y: imgAxisRect.y2 > imgAxisRect.y ? imgAxisRect.y : imgAxisRect.y2,
|
||||
w: Math.abs(imgAxisRect.x2 - imgAxisRect.x),
|
||||
h: Math.abs(imgAxisRect.y2 - imgAxisRect.y)
|
||||
};
|
||||
return getNormalization(endRect, imgW, imgH);
|
||||
};
|
||||
var getRotateImg = (image, rotate) => {
|
||||
var _a;
|
||||
let imgW = image.width;
|
||||
let imgH = image.height;
|
||||
if (rotate % 180 !== 0) {
|
||||
[imgW, imgH] = [imgH, imgW];
|
||||
}
|
||||
const commonCanvas = document.createElement("canvas");
|
||||
commonCanvas.width = imgW;
|
||||
commonCanvas.height = imgH;
|
||||
commonCanvas.style.display = "none";
|
||||
document.body.appendChild(commonCanvas);
|
||||
const commonCtx = commonCanvas.getContext("2d");
|
||||
commonCtx == null ? void 0 : commonCtx.save();
|
||||
if (rotate % 180 !== 0) {
|
||||
commonCtx == null ? void 0 : commonCtx.translate((image.height - image.width) / 2, (image.width - image.height) / 2);
|
||||
}
|
||||
commonCtx == null ? void 0 : commonCtx.translate(image.width / 2, image.height / 2);
|
||||
commonCtx == null ? void 0 : commonCtx.rotate(rotate / 180 * Math.PI);
|
||||
commonCtx == null ? void 0 : commonCtx.translate(-image.width / 2, -image.height / 2);
|
||||
commonCtx == null ? void 0 : commonCtx.drawImage(image, 0, 0);
|
||||
commonCtx == null ? void 0 : commonCtx.restore();
|
||||
const dataUrl = commonCanvas.toDataURL("image/jpeg");
|
||||
const blobData = (0, import_file.dataURLToBlob)(dataUrl);
|
||||
const file = new window.File([blobData], `${(/* @__PURE__ */ new Date()).getTime()}`, {
|
||||
type: "image/jpeg"
|
||||
});
|
||||
(_a = commonCanvas.parentNode) == null ? void 0 : _a.removeChild(commonCanvas);
|
||||
return file;
|
||||
};
|
||||
var getOdRect = (originData) => {
|
||||
let data = (0, import_lodash_es.get)(originData, "objects", []).filter((v) => !(0, import_lodash_es.isNull)((0, import_lodash_es.get)(v, "infoOnSource.bboxInFrame.bboxRatio"))).map((v, index) => {
|
||||
const rect = (0, import_lodash_es.get)(v, "infoOnSource.bboxInFrame.bboxRatio");
|
||||
const extendBox = (0, import_lodash_es.get)(v, "infoOnSource.bboxInFrame.extendBoxRatio");
|
||||
const frameTimestamp = (0, import_lodash_es.get)(v, "timestamp");
|
||||
const qualityScore = (0, import_lodash_es.get)(v, "qualityScore");
|
||||
const algorithmVersion = (0, import_lodash_es.get)(v, "objectType") === "OBJECT_TYPE_PEDESTRAIN" ? "VERSION_REID_HEAD_ATTR" : (0, import_lodash_es.get)(v, "objectType") === "OBJECT_TYPE_FACE" ? "VERSION_FACE" : "VERSION_REID_HEAD_ATTR";
|
||||
const featureData = (0, import_lodash_es.get)(v, "feature", []).filter(
|
||||
(v2) => v2.type === "FEATURE_TYPE_BYTE"
|
||||
);
|
||||
const objectRectIndex = algorithmVersion === "VERSION_FACE" ? 0 : 1;
|
||||
const objectType = (0, import_lodash_es.get)(v, "objectType");
|
||||
const objectId = (0, import_lodash_es.get)(v, "objectIndex.objectId");
|
||||
const sourceObjectId = (0, import_lodash_es.get)(v, "sourceObjectId");
|
||||
return {
|
||||
x: rect.x,
|
||||
y: rect.y,
|
||||
w: rect.w,
|
||||
h: rect.h,
|
||||
// faceCorrectImage: faceCorrectImage,
|
||||
id: index,
|
||||
qualityScore,
|
||||
algorithmVersion,
|
||||
featureData: (0, import_lodash_es.get)(featureData, "0.featureByte"),
|
||||
objectRectIndex,
|
||||
objectType,
|
||||
objectId,
|
||||
frameTimestamp,
|
||||
sourceObjectId,
|
||||
extendBox
|
||||
};
|
||||
});
|
||||
if (data.length > 0) {
|
||||
data = data.filter((v) => v.objectId !== "0");
|
||||
} else {
|
||||
throw new Error("empty");
|
||||
}
|
||||
return data;
|
||||
};
|
||||
var getOdRectV2 = (originData) => {
|
||||
const resp = originData.odv2Result[0];
|
||||
const subObjects = [];
|
||||
const data = (0, import_lodash_es.get)(resp, "objects", []).filter((v) => !(0, import_lodash_es.isNull)((0, import_lodash_es.get)(v, "subObjects[0].infoOnSource.bboxInFrame.bboxRatio"))).map((v, index) => {
|
||||
const rect = (0, import_lodash_es.get)(v, "infoOnSource.bboxInFrame.bboxRatio");
|
||||
const qualityScore = (0, import_lodash_es.get)(v, "qualityScore");
|
||||
const algorithmVersion = (0, import_lodash_es.get)(v, "objectType");
|
||||
const featrueData = (0, import_lodash_es.get)(v, "feature", []).filter(
|
||||
(v2) => v2.name === "feature-body" || v2.name === "feature-face"
|
||||
);
|
||||
const objectRectIndex = algorithmVersion === "OBJECT_TYPE_FACE" ? 0 : 1;
|
||||
const objectType = (0, import_lodash_es.get)(v, "objectType");
|
||||
const objectId = (0, import_lodash_es.get)(v, "objectIndex.objectId");
|
||||
if ((0, import_lodash_es.get)(v, "subObjects", []).length) {
|
||||
(0, import_lodash_es.get)(v, "subObjects", []).forEach((e) => {
|
||||
const rect2 = (0, import_lodash_es.get)(e, "infoOnSource.bboxInFrame.bboxRatio");
|
||||
const qualityScore2 = (0, import_lodash_es.get)(e, "qualityScore");
|
||||
const algorithmVersion2 = (0, import_lodash_es.get)(e, "objectType");
|
||||
const featrueData2 = (0, import_lodash_es.get)(e, "feature", []).filter(
|
||||
(v2) => v2.name === "feature-body" || v2.name === "feature-face"
|
||||
);
|
||||
const objectRectIndex2 = algorithmVersion2 === "OBJECT_TYPE_FACE" ? 0 : 1;
|
||||
const objectType2 = (0, import_lodash_es.get)(e, "objectType");
|
||||
const objectId2 = (0, import_lodash_es.get)(e, "objectIndex.objectId");
|
||||
subObjects.push({
|
||||
x: rect2.x,
|
||||
y: rect2.y,
|
||||
w: rect2.w,
|
||||
h: rect2.h,
|
||||
id: index,
|
||||
qualityScore: qualityScore2,
|
||||
algorithmVersion: algorithmVersion2,
|
||||
featrueData: featrueData2.length ? featrueData2[0].featureByte : "",
|
||||
objectRectIndex: objectRectIndex2,
|
||||
objectType: objectType2,
|
||||
objectId: objectId2
|
||||
});
|
||||
});
|
||||
}
|
||||
return {
|
||||
x: rect.x,
|
||||
y: rect.y,
|
||||
w: rect.w,
|
||||
h: rect.h,
|
||||
id: index,
|
||||
qualityScore,
|
||||
algorithmVersion,
|
||||
featrueData: featrueData[0].featureByte,
|
||||
objectRectIndex,
|
||||
objectType,
|
||||
objectId
|
||||
};
|
||||
});
|
||||
const brr = data.concat(subObjects).map((v, vs) => {
|
||||
if (String(v.id)) {
|
||||
v.id = vs;
|
||||
}
|
||||
return v;
|
||||
});
|
||||
if (brr.length > 0) {
|
||||
console.log(brr, "data111");
|
||||
} else {
|
||||
throw new Error("empty");
|
||||
}
|
||||
console.log(brr);
|
||||
return brr;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ALGORITHM_VERSION,
|
||||
algorithmVersions,
|
||||
getBikeExtendRect,
|
||||
getExtendRect,
|
||||
getNormalization,
|
||||
getOdRect,
|
||||
getOdRectV2,
|
||||
getOtherExtendRect,
|
||||
getRotateImg,
|
||||
getTransformRect
|
||||
});
|
14
packages/func/lib/number/index.d.ts
vendored
14
packages/func/lib/number/index.d.ts
vendored
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* 设置数据的精度
|
||||
* @param originNumber
|
||||
* @param accuracy 精度 以原点为中心向左为正,向右为负,
|
||||
* @param isCeil 是否为向上取整
|
||||
* @returns number
|
||||
*/
|
||||
export declare const setNumberAccuracy: (originNumber: number, accuracy?: number, isCeil?: boolean) => number;
|
||||
/**
|
||||
* 获取数字
|
||||
* @param number 需要校验的数值
|
||||
* @returns @number
|
||||
*/
|
||||
export declare const toRealNumber: (number: any) => any;
|
@ -1,53 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/number/index.ts
|
||||
var number_exports = {};
|
||||
__export(number_exports, {
|
||||
setNumberAccuracy: () => setNumberAccuracy,
|
||||
toRealNumber: () => toRealNumber
|
||||
});
|
||||
module.exports = __toCommonJS(number_exports);
|
||||
var setNumberAccuracy = (originNumber, accuracy = 0, isCeil = true) => {
|
||||
if (originNumber === 0) {
|
||||
return 0;
|
||||
}
|
||||
let returnData = 0;
|
||||
if (isCeil) {
|
||||
returnData = Math.ceil(originNumber / Math.pow(10, accuracy)) * Math.pow(10, accuracy);
|
||||
} else {
|
||||
returnData = Math.floor(originNumber / Math.pow(10, accuracy)) * Math.pow(10, accuracy);
|
||||
}
|
||||
if (accuracy < 0) {
|
||||
returnData = Number(returnData.toFixed(-accuracy));
|
||||
} else {
|
||||
returnData = Number(returnData.toFixed(0));
|
||||
}
|
||||
return returnData;
|
||||
};
|
||||
var toRealNumber = (number) => {
|
||||
if (isNaN(number) || number === Infinity) {
|
||||
return 0;
|
||||
} else
|
||||
return number;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
setNumberAccuracy,
|
||||
toRealNumber
|
||||
});
|
1
packages/func/lib/performance/index.d.ts
vendored
1
packages/func/lib/performance/index.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare const speedConvert: (bps: number, contertUnit?: number) => string;
|
@ -1,41 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/performance/index.ts
|
||||
var performance_exports = {};
|
||||
__export(performance_exports, {
|
||||
speedConvert: () => speedConvert
|
||||
});
|
||||
module.exports = __toCommonJS(performance_exports);
|
||||
var speedConvert = (bps, contertUnit = 8) => {
|
||||
if (bps === void 0)
|
||||
return `0KB/s`;
|
||||
const byte = bps / contertUnit;
|
||||
if (bps > 1024 * 1024 * 1024) {
|
||||
return `${(byte / 1024 / 1024 / 1024).toFixed(2)}GB/s`;
|
||||
} else if (byte > 1024 * 1024) {
|
||||
return `${(byte / 1024 / 1024).toFixed(2)}MB/s`;
|
||||
} else if (byte > 1024) {
|
||||
return `${(byte / 1024).toFixed(2)}KB/s`;
|
||||
}
|
||||
return `${byte}KB/s`;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
speedConvert
|
||||
});
|
7
packages/func/lib/string/index.d.ts
vendored
7
packages/func/lib/string/index.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
export declare const getStrLength: (str: string) => number;
|
||||
/**
|
||||
* js截取字符串,中英文都能用
|
||||
* @param str:需要截取的字符串
|
||||
* @param len: 需要截取的长度
|
||||
*/
|
||||
export declare const cutStr: (str: string, len: number) => string | String | undefined;
|
@ -1,62 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/string/index.ts
|
||||
var string_exports = {};
|
||||
__export(string_exports, {
|
||||
cutStr: () => cutStr,
|
||||
getStrLength: () => getStrLength
|
||||
});
|
||||
module.exports = __toCommonJS(string_exports);
|
||||
var getStrLength = function(str) {
|
||||
var realLength = 0, len = str.length, charCode = -1;
|
||||
for (var i = 0; i < len; i++) {
|
||||
charCode = str.charCodeAt(i);
|
||||
if (charCode >= 0 && charCode <= 128)
|
||||
realLength += 1;
|
||||
else
|
||||
realLength += 2;
|
||||
}
|
||||
return realLength;
|
||||
};
|
||||
var cutStr = function cutstr(str, len) {
|
||||
var str_length = 0;
|
||||
var str_len = 0;
|
||||
let str_cut = new String();
|
||||
str_len = str.length;
|
||||
for (var i = 0; i < str_len; i++) {
|
||||
let a = str.charAt(i);
|
||||
str_length++;
|
||||
if (escape(a).length > 4) {
|
||||
str_length++;
|
||||
}
|
||||
str_cut = str_cut.concat(a);
|
||||
if (str_length >= len) {
|
||||
str_cut = str_cut.concat("...");
|
||||
return str_cut;
|
||||
}
|
||||
}
|
||||
if (str_length < len) {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
cutStr,
|
||||
getStrLength
|
||||
});
|
11
packages/func/lib/time/index.d.ts
vendored
11
packages/func/lib/time/index.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
export declare const formateDuration: (diff: number) => string;
|
||||
export declare function generateTime(): {
|
||||
startDateTime: number;
|
||||
endDateTime: number;
|
||||
};
|
||||
/**
|
||||
* 格式化时间为 00:00
|
||||
* @param seconds 时间,单位秒
|
||||
* @returns
|
||||
*/
|
||||
export declare function formatDurationTime(seconds: number): string;
|
@ -1,73 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/time/index.ts
|
||||
var time_exports = {};
|
||||
__export(time_exports, {
|
||||
formatDurationTime: () => formatDurationTime,
|
||||
formateDuration: () => formateDuration,
|
||||
generateTime: () => generateTime
|
||||
});
|
||||
module.exports = __toCommonJS(time_exports);
|
||||
var import_dayjs = __toESM(require("dayjs"));
|
||||
var formateDuration = (diff) => {
|
||||
var days = Math.floor(diff / (24 * 3600 * 1e3));
|
||||
var leave1 = diff % (24 * 3600 * 1e3);
|
||||
var hours = Math.floor(leave1 / (3600 * 1e3));
|
||||
var leave2 = leave1 % (3600 * 1e3);
|
||||
var minutes = Math.floor(leave2 / (60 * 1e3));
|
||||
var leave3 = leave2 % (60 * 1e3);
|
||||
var seconds = Math.round(leave3 / 1e3);
|
||||
var returnStr = seconds + "秒";
|
||||
if (minutes > 0) {
|
||||
returnStr = minutes + "分";
|
||||
}
|
||||
if (hours > 0) {
|
||||
returnStr = hours + "小时";
|
||||
}
|
||||
if (days > 0) {
|
||||
returnStr = days + "天";
|
||||
}
|
||||
return returnStr;
|
||||
};
|
||||
function generateTime() {
|
||||
let endDateTime = (0, import_dayjs.default)().endOf("day").unix();
|
||||
let startDateTime = (0, import_dayjs.default)().startOf("day").unix();
|
||||
return { startDateTime, endDateTime };
|
||||
}
|
||||
function formatDurationTime(seconds) {
|
||||
var minutes = Math.floor(seconds / 60) || 0;
|
||||
var remainingSeconds = Math.floor(seconds % 60);
|
||||
return (minutes < 10 ? `0${minutes}` : minutes) + ":" + (remainingSeconds < 10 ? "0" : "") + remainingSeconds;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
formatDurationTime,
|
||||
formateDuration,
|
||||
generateTime
|
||||
});
|
8
packages/func/lib/upload/index.d.ts
vendored
8
packages/func/lib/upload/index.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
type uploadOption = {
|
||||
bucket?: string;
|
||||
dir?: string;
|
||||
withSuFuffix?: boolean;
|
||||
};
|
||||
export declare const commonUpload: (file: File, option: uploadOption | undefined, type: string) => Promise<unknown>;
|
||||
export declare const upload: (file: File, option?: uploadOption) => Promise<unknown>;
|
||||
export {};
|
@ -1,90 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/upload/index.ts
|
||||
var upload_exports = {};
|
||||
__export(upload_exports, {
|
||||
commonUpload: () => commonUpload,
|
||||
upload: () => upload
|
||||
});
|
||||
module.exports = __toCommonJS(upload_exports);
|
||||
var import_dayjs = __toESM(require("dayjs"));
|
||||
var import_utils = require("../utils");
|
||||
var import_base_64 = __toESM(require("base-64"));
|
||||
var import_uuid = require("uuid");
|
||||
var import_lodash_es = require("lodash-es");
|
||||
var import_request = __toESM(require("@zhst/request"));
|
||||
var defaultBucket = "public";
|
||||
var commonUpload = async (file, option = {}, type) => {
|
||||
const { bucket = defaultBucket, dir = "file", withSuFuffix = false } = option;
|
||||
const prefix = `${(0, import_dayjs.default)().format("YYYYMMDD")}`;
|
||||
const fileSuffix = withSuFuffix ? (0, import_utils.getFileSuffix)((0, import_lodash_es.get)(file, "name")) : "";
|
||||
const fileType = file["type"].split("/", 2);
|
||||
let imageSuffix = "";
|
||||
if (fileType["0"] === "image") {
|
||||
imageSuffix = (0, import_utils.getImageSuffixByFileType)(fileType["1"]);
|
||||
}
|
||||
const key = `${prefix}/${dir ? `${dir}/` : ""}${(0, import_uuid.v4)()}${!fileSuffix ? "" : `.${fileSuffix}`}`;
|
||||
let imgKey = `${bucket}_${bucket}_${key}${imageSuffix}`;
|
||||
if (type === "upload") {
|
||||
imgKey = `v1_${import_base_64.default.encode(imgKey)}`;
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = async () => {
|
||||
var _a;
|
||||
if (reader.result) {
|
||||
await (0, import_request.default)({
|
||||
method: "PUT",
|
||||
url: "/singer.FileServerService/PutObject",
|
||||
data: {
|
||||
version: 1,
|
||||
bucket: defaultBucket,
|
||||
objectName: `${bucket}_${key}${imageSuffix}`,
|
||||
// fileData: reader.result,
|
||||
putObjectOption: {
|
||||
contentType: file.type
|
||||
},
|
||||
// @ts-ignore
|
||||
fileDataBase64: (_a = reader.result) == null ? void 0 : _a.split(";base64,")[1]
|
||||
}
|
||||
});
|
||||
resolve(imgKey);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
var upload = async (file, option = {}) => {
|
||||
return await commonUpload(file, option, "upload");
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
commonUpload,
|
||||
upload
|
||||
});
|
36
packages/func/lib/utils/index.d.ts
vendored
36
packages/func/lib/utils/index.d.ts
vendored
@ -1,36 +0,0 @@
|
||||
export { default as isChrome } from './isChrome';
|
||||
export declare const matchS3Prefix: (str: string) => boolean;
|
||||
/**
|
||||
* 通过文件名获取文件类型
|
||||
* @param fileName 文件名称
|
||||
* @returns 文件类型
|
||||
*/
|
||||
export declare const getFileSuffix: (fileName: string) => string;
|
||||
/**
|
||||
* 通过类型获取文件名
|
||||
* @param type 类型
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageSuffixByFileType: (type: string) => string;
|
||||
export declare function getChromeVersion(): number | false;
|
||||
export declare const nextTick: (func: (value: void) => void | PromiseLike<void>) => void;
|
||||
export declare const loop: (items: string | any[], callback: (arg0: any) => any) => void;
|
||||
export declare const addEventListenerWrapper: (target: any, eventType: string, cb: any, option?: any) => {
|
||||
remove: () => void;
|
||||
};
|
||||
/**
|
||||
* Get transforms base on the given object.
|
||||
* @param {Object} obj - The target object.
|
||||
* @returns {string} A string contains transform values.
|
||||
*/
|
||||
export declare function getTransforms({ rotate, scaleX, scaleY, translateX, translateY, }: {
|
||||
rotate?: number;
|
||||
scaleX?: number;
|
||||
scaleY?: number;
|
||||
translateX?: number;
|
||||
translateY?: number;
|
||||
}): {
|
||||
WebkitTransform: string;
|
||||
msTransform: string;
|
||||
transform: string;
|
||||
};
|
@ -1,171 +0,0 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/utils/index.ts
|
||||
var utils_exports = {};
|
||||
__export(utils_exports, {
|
||||
addEventListenerWrapper: () => addEventListenerWrapper,
|
||||
getChromeVersion: () => getChromeVersion,
|
||||
getFileSuffix: () => getFileSuffix,
|
||||
getImageSuffixByFileType: () => getImageSuffixByFileType,
|
||||
getTransforms: () => getTransforms,
|
||||
isChrome: () => import_isChrome.default,
|
||||
loop: () => loop,
|
||||
matchS3Prefix: () => matchS3Prefix,
|
||||
nextTick: () => nextTick
|
||||
});
|
||||
module.exports = __toCommonJS(utils_exports);
|
||||
var import_lodash_es = require("lodash-es");
|
||||
var import_react_dom = __toESM(require("react-dom"));
|
||||
var import_isChrome = __toESM(require("./isChrome"));
|
||||
var matchS3Prefix = (str) => {
|
||||
return /^v[0-9]_/.test(str);
|
||||
};
|
||||
var getFileSuffix = (fileName) => {
|
||||
const splitArr = fileName.split(".");
|
||||
return splitArr.length < 2 ? "" : splitArr[splitArr.length - 1];
|
||||
};
|
||||
var getImageSuffixByFileType = (type) => {
|
||||
let imageSuffix = "";
|
||||
switch (type) {
|
||||
case "jpeg": {
|
||||
imageSuffix = ".jpg";
|
||||
break;
|
||||
}
|
||||
case "gif": {
|
||||
imageSuffix = ".gif";
|
||||
break;
|
||||
}
|
||||
case "png": {
|
||||
imageSuffix = ".png";
|
||||
break;
|
||||
}
|
||||
case "vnd.wap.wbmp": {
|
||||
imageSuffix = ".wbmp";
|
||||
break;
|
||||
}
|
||||
case "x-up-wpng": {
|
||||
imageSuffix = ".wpng";
|
||||
break;
|
||||
}
|
||||
case "nbmp": {
|
||||
imageSuffix = ".nbmp";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return imageSuffix;
|
||||
};
|
||||
function getChromeVersion() {
|
||||
const arr = navigator.userAgent.split(" ");
|
||||
let chromeVersion = "";
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (/chrome/i.test(arr[i]))
|
||||
chromeVersion = arr[i];
|
||||
}
|
||||
if (chromeVersion) {
|
||||
return Number(chromeVersion.split("/")[1].split(".")[0]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var nextTick = (func) => {
|
||||
if (queueMicrotask) {
|
||||
queueMicrotask(func);
|
||||
return;
|
||||
}
|
||||
Promise.resolve().then(func);
|
||||
};
|
||||
var loop = (items, callback) => {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const element = items[i];
|
||||
let isBreak = callback(element);
|
||||
if (isBreak) {
|
||||
return;
|
||||
}
|
||||
if (element["children"]) {
|
||||
loop(element["children"], callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
var addEventListenerWrapper = (target, eventType, cb, option) => {
|
||||
const callback = import_react_dom.default.unstable_batchedUpdates ? function run(e) {
|
||||
import_react_dom.default.unstable_batchedUpdates(cb, e);
|
||||
} : cb;
|
||||
if (target.addEventListener) {
|
||||
target.addEventListener(eventType, callback, option);
|
||||
}
|
||||
return {
|
||||
remove: () => {
|
||||
if (target.removeEventListener) {
|
||||
target.removeEventListener(eventType, callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
function getTransforms({
|
||||
rotate,
|
||||
scaleX,
|
||||
scaleY,
|
||||
translateX,
|
||||
translateY
|
||||
}) {
|
||||
const values = [];
|
||||
if ((0, import_lodash_es.isNumber)(translateX) && translateX !== 0) {
|
||||
values.push(`translateX(${translateX}px)`);
|
||||
}
|
||||
if ((0, import_lodash_es.isNumber)(translateY) && translateY !== 0) {
|
||||
values.push(`translateY(${translateY}px)`);
|
||||
}
|
||||
if ((0, import_lodash_es.isNumber)(rotate) && rotate !== 0) {
|
||||
values.push(`rotate(${rotate}deg)`);
|
||||
}
|
||||
if ((0, import_lodash_es.isNumber)(scaleX) && scaleX !== 1) {
|
||||
values.push(`scaleX(${scaleX})`);
|
||||
}
|
||||
if ((0, import_lodash_es.isNumber)(scaleY) && scaleY !== 1) {
|
||||
values.push(`scaleY(${scaleY})`);
|
||||
}
|
||||
const transform = values.length ? values.join(" ") : "none";
|
||||
return {
|
||||
WebkitTransform: transform,
|
||||
msTransform: transform,
|
||||
transform
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
addEventListenerWrapper,
|
||||
getChromeVersion,
|
||||
getFileSuffix,
|
||||
getImageSuffixByFileType,
|
||||
getTransforms,
|
||||
isChrome,
|
||||
loop,
|
||||
matchS3Prefix,
|
||||
nextTick
|
||||
});
|
3
packages/func/lib/utils/isChrome.d.ts
vendored
3
packages/func/lib/utils/isChrome.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export declare const isBrowser: boolean;
|
||||
declare const isChrome: () => boolean;
|
||||
export default isChrome;
|
@ -1,42 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/utils/isChrome.ts
|
||||
var isChrome_exports = {};
|
||||
__export(isChrome_exports, {
|
||||
default: () => isChrome_default,
|
||||
isBrowser: () => isBrowser
|
||||
});
|
||||
module.exports = __toCommonJS(isChrome_exports);
|
||||
var isBrowser = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
||||
var isChrome = () => {
|
||||
const winNav = isBrowser && window.navigator;
|
||||
const vendorName = winNav && (winNav == null ? void 0 : winNav.vendor);
|
||||
const userAgent = winNav && winNav.userAgent;
|
||||
const isChromium = isBrowser && typeof chrome !== "undefined";
|
||||
const isOpera = isBrowser && typeof opr !== "undefined";
|
||||
const isIEedge = userAgent && userAgent.indexOf("Edge") > -1;
|
||||
const isIOSChrome = !!(userAgent && userAgent.match("CriOS"));
|
||||
const isDesktopChrome = isChromium && vendorName === "Google Inc." && !isOpera && !isIEedge;
|
||||
return isIOSChrome || isDesktopChrome;
|
||||
};
|
||||
var isChrome_default = isChrome;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
isBrowser
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
import { cloneDeep, get, isNull, isNumber, isString } from 'lodash-es';
|
||||
import { dataURLToBlob, generateImg, urlToImg } from '../file';
|
||||
import { cloneDeep, get, isNull } from 'lodash-es';
|
||||
import { dataURLToBlob } from '../file';
|
||||
import { IOdRectOrigin, Rect } from '@zhst/types';
|
||||
|
||||
const proto = {
|
||||
|
@ -36,17 +36,14 @@ import { defaultAlignOption, CROP_TYPE } from '../utils/constants'
|
||||
const componentName = `zhst-image__img-view`;
|
||||
|
||||
export interface ImgViewProps extends React.HTMLAttributes<HTMLElement> {
|
||||
dataSource: Array<{
|
||||
data: {
|
||||
url?: string
|
||||
imageKey: string
|
||||
attachImg?: Array<{ label: string; url: string }>; // 缩略图列表
|
||||
odRect?: Rect
|
||||
score?: number
|
||||
showScore?: boolean
|
||||
cameraPosition?: string
|
||||
time?: string | number
|
||||
objects: any[]
|
||||
}>
|
||||
objects?: IOdRectOrigin[] // 图片人物框选
|
||||
}
|
||||
showAttachImgLabel?: boolean; // 是否显示缩略图
|
||||
showOpt?: boolean; // 是否显示操作面板
|
||||
width?: string | number; // 画布宽度
|
||||
@ -57,7 +54,6 @@ export interface ImgViewProps extends React.HTMLAttributes<HTMLElement> {
|
||||
hideLeftTopBtn?: boolean;
|
||||
showScore?: boolean // 是否显示相似度
|
||||
viewOption?: ViewOption;
|
||||
objects?: IOdRectOrigin[] // 图片人物框选
|
||||
}
|
||||
export interface ImgViewRef {
|
||||
/* 图片实例 */
|
||||
@ -104,11 +100,10 @@ const operateBtnDataSource = [
|
||||
|
||||
export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props, ref) => {
|
||||
const {
|
||||
dataSource = [],
|
||||
width,
|
||||
height,
|
||||
showScore = true,
|
||||
objects = [],
|
||||
data,
|
||||
showOpt = false,
|
||||
showAttachImgLabel = true,
|
||||
screenshotButtonAlign = defaultAlignOption,
|
||||
@ -119,11 +114,15 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
hideLeftTopBtn = true,
|
||||
viewOption = {}
|
||||
} = props;
|
||||
const {
|
||||
imageKey,
|
||||
attachImg,
|
||||
odRect,
|
||||
score,
|
||||
objects = [],
|
||||
} = data
|
||||
const imgContainerRef = React.useRef(null);
|
||||
const [isReady, setIsReady] = useState(false);
|
||||
const [currentIndex, setCurrentIndex] = useState(0)
|
||||
|
||||
console.log('props', props)
|
||||
|
||||
const init = useCallback(($container: null) => {
|
||||
imgContainerRef.current = $container;
|
||||
@ -134,7 +133,6 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
const [isImgReady, setIsImgReady] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('123', 123)
|
||||
if (!isReady || !imgContainerRef?.current) return;
|
||||
const handleReady = addEventListenerWrapper(imgContainerRef.current, EVENT_VIEWER_READY, () => {
|
||||
setIsImgReady(true);
|
||||
@ -148,7 +146,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
imgInsRef.current = new Viewer(imgContainerRef.current, {
|
||||
...viewOption,
|
||||
fitScaleAsMinScale: true,
|
||||
image: generateImg(dataSource[currentIndex]?.imageKey),
|
||||
image: generateImg(imageKey),
|
||||
});
|
||||
return () => {
|
||||
handleReady?.remove();
|
||||
@ -156,7 +154,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
imgInsRef?.current?.destroy?.();
|
||||
imgInsRef.current = null;
|
||||
};
|
||||
}, [isReady, currentIndex]);
|
||||
}, [isReady, imageKey]);
|
||||
|
||||
// ============================= viewer操作按钮 =========================
|
||||
const handleOptClick = (v: string) => {
|
||||
@ -196,7 +194,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
const handleShapeSelectRef: any = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
initData(dataSource[currentIndex].objects || objects)
|
||||
initData(objects)
|
||||
return () => {
|
||||
imgInsRef.current?.clearShape?.();
|
||||
handlerCropStartRef.current?.remove();
|
||||
@ -205,11 +203,11 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
cropInsRef?.current?.destroy?.();
|
||||
cropInsRef.current = null;
|
||||
};
|
||||
}, [isImgReady, showCrop, cropType, currentIndex]);
|
||||
}, [isImgReady, showCrop, cropType, imageKey]);
|
||||
|
||||
const initData = (_objects: IOdRectOrigin[]) => {
|
||||
const imgIns = imgInsRef.current;
|
||||
const _odRect = dataSource[currentIndex].odRect
|
||||
const _odRect = odRect
|
||||
//清理crop
|
||||
setCropRect(null);
|
||||
if (!isImgReady) return;
|
||||
@ -298,14 +296,13 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
|
||||
// 获取框选的截图框信息
|
||||
const latestCropType = useLatest(cropType);
|
||||
const latestImgKey = useLatest(dataSource[currentIndex].imageKey);
|
||||
const latestCropRect = useLatest(cropRect);
|
||||
const getCropInfo = async () => {
|
||||
const getCropInfo = async (cb: (data: any) => void) => {
|
||||
const cropType = latestCropType.current;
|
||||
const cropRect = latestCropRect.current;
|
||||
const imgIns = imgInsRef.current;
|
||||
const transform = imgIns.targetTransform;
|
||||
let newImgKey = latestImgKey.current;
|
||||
let newImgKey = imageKey;
|
||||
let rectList: any = [];
|
||||
let extendRectList = [];
|
||||
let selectIndex = 0;
|
||||
@ -346,7 +343,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
if (get(transform, 'rotate', 0) % 360 != 0) {
|
||||
const data = getRotateImg(imgIns.image, get(transform, 'rotate', 0)) as any;
|
||||
//在画布上画旋转后的图片
|
||||
newImgKey = await upload(data) as any;
|
||||
newImgKey = data as any;
|
||||
}
|
||||
rectList.push(newRect);
|
||||
extendRectList.push(newRect);
|
||||
@ -356,7 +353,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
await Promise.all(
|
||||
extendRectList.map(async (rect, index) => {
|
||||
const file = await getFileByRect(imgIns.image, rect);
|
||||
const imgKey = await upload(file);
|
||||
const imgKey = file;
|
||||
extendRectList[index] = { ...rect, imgKey };
|
||||
})
|
||||
);
|
||||
@ -369,7 +366,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
const base64 = `data:image/jpg;base64,${faceCorrectImage}`;
|
||||
const blobData = dataURLToBlob(base64);
|
||||
const file = new window.File([blobData], `${new Date().getTime()}`);
|
||||
faceCorrectImageKey = await upload(file);
|
||||
faceCorrectImageKey = file
|
||||
}
|
||||
const newRect: any = {
|
||||
...rect,
|
||||
@ -379,6 +376,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
rectList[index] = newRect;
|
||||
})
|
||||
);
|
||||
cb?.({ rectList, extendRectList, selectIndex, imgKey: newImgKey })
|
||||
return { rectList, extendRectList, selectIndex, imgKey: newImgKey };
|
||||
};
|
||||
|
||||
@ -405,11 +403,9 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
* 修改当前图片预览下标
|
||||
* @param diff 跳转强度 正向后翻、负值向前翻
|
||||
*/
|
||||
const handleChangeIndex = (diff: number) => {
|
||||
const _index = currentIndex + diff
|
||||
|
||||
if (!dataSource?.[_index]?.imageKey) return
|
||||
setCurrentIndex(_index)
|
||||
const handleChangeIndex = (cb?: () => void) => {
|
||||
if (!imageKey) return
|
||||
cb?.()
|
||||
}
|
||||
|
||||
// ============================== Ref ===============================
|
||||
@ -424,7 +420,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
return (
|
||||
<div className={classNames(`${componentName}`)} style={{ height, width }}>
|
||||
{/*场景图大图 */}
|
||||
{dataSource.length ?
|
||||
{imageKey ?
|
||||
<>
|
||||
<div
|
||||
className={classNames(
|
||||
@ -486,7 +482,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
</>
|
||||
)}
|
||||
{/* 场景图小图 */}
|
||||
{dataSource[currentIndex].attachImg?.length && !showCrop && (
|
||||
{attachImg?.length && !showCrop && (
|
||||
<div
|
||||
className={classNames(
|
||||
`${componentName}-attach`,
|
||||
@ -497,7 +493,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
>
|
||||
<div className={classNames(`${componentName}-attach__tab`)}>
|
||||
{showAttachImgLabel
|
||||
? dataSource[currentIndex].attachImg?.map(({ label }, index) => (
|
||||
? attachImg?.map(({ label }, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className={classNames(
|
||||
@ -539,7 +535,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
`${componentName}-attach__img`,
|
||||
`${componentName}-attach__img--fixed`
|
||||
)}
|
||||
src={get(dataSource[currentIndex].attachImg, `${selectAttachImgIndex}.url`, '')}
|
||||
src={get(attachImg, `${selectAttachImgIndex}.url`, '')}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@ -547,7 +543,7 @@ export const BigImagePreview = React.forwardRef<ImgViewRef, ImgViewProps>((props
|
||||
style={{ bottom: 20 }}
|
||||
className={classNames(`${componentName}__face-score`)}
|
||||
>
|
||||
{`人脸质量分:${(Number(dataSource[currentIndex].score) as number).toFixed(2)}`}
|
||||
{`人脸质量分:${(Number(score) as number).toFixed(2)}`}
|
||||
</div>}
|
||||
</>
|
||||
:
|
||||
|
@ -79,10 +79,10 @@ const getScreenshotButtonRender = (arg: {
|
||||
e.stopPropagation();
|
||||
let image: any = getCropInfo();
|
||||
setShowCrop(false);
|
||||
if (!image.rectList[0].algorithmVersion) {
|
||||
image.rectList[0].algorithmVersion = 0;
|
||||
image.extendRectList[0].algorithmVersion = 0;
|
||||
}
|
||||
// if (!image.rectList?.[0].algorithmVersion) {
|
||||
// image.rectList[0].algorithmVersion = 0;
|
||||
// image.extendRectList[0].algorithmVersion = 0;
|
||||
// }
|
||||
onBigImageActionClick(IBigImageOpt['ADD_HISTORY_WITH_CROP_ARCHIVE'], image);
|
||||
}}
|
||||
>
|
||||
|
@ -17,10 +17,12 @@ export interface CompareImageProps {
|
||||
*/
|
||||
label?: string;
|
||||
openRoll?: boolean; //开启翻页
|
||||
dataSource?: Array<{
|
||||
url: string;
|
||||
score: number | string;
|
||||
}>;
|
||||
url: string;
|
||||
score?: number;
|
||||
onPre?: () => void;
|
||||
onNext?: () => void;
|
||||
preDisable?: boolean; // 向前翻页禁用
|
||||
nextDisable?: boolean; // 向后翻页禁用
|
||||
showScore?: boolean; // 是否展示相似度
|
||||
current?: number; // 当前图片下标
|
||||
}
|
||||
@ -31,16 +33,24 @@ export interface CompareImageRefProps {
|
||||
|
||||
// 对比图组件
|
||||
const CompareImage = forwardRef<CompareImageRefProps, CompareImageProps>((props, ref) => {
|
||||
const { label = '标题', openRoll = true, dataSource = [], showScore = true, current = 0 } = props;
|
||||
const {
|
||||
label = '标题',
|
||||
openRoll = true,
|
||||
url = '',
|
||||
score = 0,
|
||||
preDisable,
|
||||
nextDisable,
|
||||
showScore = true,
|
||||
onNext,
|
||||
onPre
|
||||
} = props;
|
||||
const imgContainerRef = useRef(null);
|
||||
const imgInsRef = useRef<any>(null);
|
||||
const [scale, setScale] = useState(0);
|
||||
//图片翻页机制
|
||||
const [currentIndex, setCurrentIndex] = useState(current)
|
||||
|
||||
// 初始化页面
|
||||
useEffect(() => {
|
||||
if (!dataSource?.length) return
|
||||
if (!url) return
|
||||
|
||||
const handleTransformChange = addEventListenerWrapper(
|
||||
imgContainerRef.current,
|
||||
@ -51,9 +61,9 @@ const CompareImage = forwardRef<CompareImageRefProps, CompareImageProps>((props,
|
||||
}
|
||||
);
|
||||
|
||||
if (generateImg(dataSource[currentIndex].url)) {
|
||||
if (generateImg(url)) {
|
||||
imgInsRef.current = new Viewer(imgContainerRef.current, {
|
||||
image: generateImg(dataSource[currentIndex].url),
|
||||
image: generateImg(url),
|
||||
});
|
||||
}
|
||||
|
||||
@ -68,51 +78,39 @@ const CompareImage = forwardRef<CompareImageRefProps, CompareImageProps>((props,
|
||||
useUpdateEffect(() => {
|
||||
if (imgInsRef.current) {
|
||||
imgInsRef.current?.refleshImage({
|
||||
image: generateImg(dataSource[currentIndex].url),
|
||||
image: generateImg(url),
|
||||
});
|
||||
}
|
||||
}, [currentIndex]);
|
||||
|
||||
// 翻页实践
|
||||
const handleIndexChange = (changeVal: number) => {
|
||||
const _index = currentIndex + changeVal
|
||||
|
||||
if (!dataSource?.[_index]?.url) return
|
||||
imgInsRef.current?.refleshImage({
|
||||
image: generateImg(dataSource[_index].url),
|
||||
});
|
||||
setCurrentIndex(_index)
|
||||
}
|
||||
}, [url]);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
imgInsRef,
|
||||
handleIndexChange
|
||||
}));
|
||||
|
||||
if (!dataSource) return null
|
||||
|
||||
return (
|
||||
<div className={classNames(`${componentName}__container`)}>
|
||||
<div className={classNames(`${componentName}__label`)}>{label}</div>
|
||||
<div ref={imgContainerRef} className={classNames(`${componentName}__view`)} />
|
||||
{!dataSource.length && (
|
||||
|
||||
{!url ? (
|
||||
<div className={classNames(`${componentName}__empty`)}>
|
||||
<img
|
||||
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==" title="暂无数据"
|
||||
></img>
|
||||
<span className={classNames(`${componentName}__empty--text`)}>暂无匹配数据</span>
|
||||
</div>
|
||||
) : (
|
||||
<div ref={imgContainerRef} className={classNames(`${componentName}__view`)} />
|
||||
)}
|
||||
{/* 翻页组件 */}
|
||||
{!!dataSource.length && openRoll && (
|
||||
{!!url && openRoll && (
|
||||
<div className={classNames(`${componentName}__scoll-module`)}>
|
||||
{/* <div> </div> */}
|
||||
<Button
|
||||
type={'default'}
|
||||
className={classNames(`${componentName}__scoll-module__btn`)}
|
||||
disabled={currentIndex <= 0}
|
||||
disabled={preDisable}
|
||||
onClick={() => {
|
||||
handleIndexChange(-1);
|
||||
onPre?.();
|
||||
}}
|
||||
>
|
||||
<Icon icon="icon-qiehuanzuo" size={40} />
|
||||
@ -120,16 +118,16 @@ const CompareImage = forwardRef<CompareImageRefProps, CompareImageProps>((props,
|
||||
<Button
|
||||
type={'default'}
|
||||
className={classNames(`${componentName}__scoll-module__btn`)}
|
||||
disabled={currentIndex >= dataSource.length - 1}
|
||||
disabled={nextDisable}
|
||||
onClick={() => {
|
||||
handleIndexChange(1);
|
||||
onNext?.();
|
||||
}}
|
||||
>
|
||||
<Icon icon="icon-qiehuanyou" size={40} />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{showScore && <CornerScore scoreTxt={dataSource[currentIndex]?.score || 0} />}
|
||||
{showScore && <CornerScore scoreTxt={score || 0} />}
|
||||
<div className={classNames(`${componentName}__tool`)}>
|
||||
<Button
|
||||
type="text"
|
||||
|
@ -13,14 +13,15 @@
|
||||
}
|
||||
|
||||
&__container {
|
||||
font-size: 0;
|
||||
position: relative;
|
||||
box-sizing: content-box;
|
||||
border: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
&__view {
|
||||
width: 345px;
|
||||
height: 460px;
|
||||
min-width: 345px;
|
||||
min-height: 450px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
@ -29,6 +30,7 @@
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
font-size: 16px;
|
||||
height: 34px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@ -41,7 +43,7 @@
|
||||
|
||||
&__tool {
|
||||
display: flex;
|
||||
width: 345px;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@ -124,6 +126,7 @@
|
||||
display: flex;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
bottom: 45px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 6px;
|
||||
|
32
packages/request/es/index.d.ts
vendored
32
packages/request/es/index.d.ts
vendored
@ -1,32 +0,0 @@
|
||||
import type { RequestOptionsInit } from 'umi-request';
|
||||
export declare class ResponseError<D> extends Error {
|
||||
name: string;
|
||||
data: D;
|
||||
response: Response;
|
||||
request: {
|
||||
url: string;
|
||||
options: RequestOptionsInit;
|
||||
};
|
||||
type: string;
|
||||
constructor(response: Response, text: string, data: D, request: {
|
||||
url: string;
|
||||
options: RequestOptionsInit;
|
||||
}, type?: string);
|
||||
}
|
||||
export declare const req: import("umi-request").RequestMethod<true>;
|
||||
export interface OPTION extends RequestOptionsInit {
|
||||
toast?: boolean;
|
||||
}
|
||||
interface CGI {
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
||||
url: string;
|
||||
baseUrl?: string;
|
||||
data?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
useBaseUrl?: boolean;
|
||||
originUrl?: boolean;
|
||||
refererSuffix?: string;
|
||||
}
|
||||
export declare const doRequest: <T>(cgi: CGI, option?: OPTION) => Promise<T>;
|
||||
export default doRequest;
|
@ -142,7 +142,6 @@ export var doRequest = function doRequest(cgi, option) {
|
||||
_cgi$refererSuffix = cgi.refererSuffix,
|
||||
refererSuffix = _cgi$refererSuffix === void 0 ? '' : _cgi$refererSuffix;
|
||||
var token = localStorage.getItem(User.TOKEN_KEY);
|
||||
var userInfo = localStorage.getItem(User.USER_KEY) ? JSON.parse(localStorage.getItem(User.USER_KEY)) : null;
|
||||
var newUrl = '';
|
||||
if (useBaseUrl) {
|
||||
newUrl = "".concat(baseUrl).concat(url);
|
||||
|
32
packages/request/lib/index.d.ts
vendored
32
packages/request/lib/index.d.ts
vendored
@ -1,32 +0,0 @@
|
||||
import type { RequestOptionsInit } from 'umi-request';
|
||||
export declare class ResponseError<D> extends Error {
|
||||
name: string;
|
||||
data: D;
|
||||
response: Response;
|
||||
request: {
|
||||
url: string;
|
||||
options: RequestOptionsInit;
|
||||
};
|
||||
type: string;
|
||||
constructor(response: Response, text: string, data: D, request: {
|
||||
url: string;
|
||||
options: RequestOptionsInit;
|
||||
}, type?: string);
|
||||
}
|
||||
export declare const req: import("umi-request").RequestMethod<true>;
|
||||
export interface OPTION extends RequestOptionsInit {
|
||||
toast?: boolean;
|
||||
}
|
||||
interface CGI {
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
||||
url: string;
|
||||
baseUrl?: string;
|
||||
data?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
useBaseUrl?: boolean;
|
||||
originUrl?: boolean;
|
||||
refererSuffix?: string;
|
||||
}
|
||||
export declare const doRequest: <T>(cgi: CGI, option?: OPTION) => Promise<T>;
|
||||
export default doRequest;
|
@ -104,7 +104,6 @@ var doRequest = (cgi, option) => {
|
||||
refererSuffix = ""
|
||||
} = cgi;
|
||||
const token = localStorage.getItem(import_user.User.TOKEN_KEY);
|
||||
const userInfo = localStorage.getItem(import_user.User.USER_KEY) ? JSON.parse(localStorage.getItem(import_user.User.USER_KEY)) : null;
|
||||
let newUrl = "";
|
||||
if (useBaseUrl) {
|
||||
newUrl = `${baseUrl}${url}`;
|
||||
|
@ -102,9 +102,6 @@ export const doRequest = <T>(cgi: CGI, option?: OPTION): Promise<T> => {
|
||||
refererSuffix = '',
|
||||
} = cgi;
|
||||
const token = localStorage.getItem(User.TOKEN_KEY);
|
||||
const userInfo = localStorage.getItem(User.USER_KEY)
|
||||
? JSON.parse(localStorage.getItem(User.USER_KEY)!)
|
||||
: null;
|
||||
let newUrl = '';
|
||||
if (useBaseUrl) {
|
||||
newUrl = `${baseUrl}${url}`;
|
||||
|
2
packages/types/BigImageModal.d.ts
vendored
2
packages/types/BigImageModal.d.ts
vendored
@ -27,5 +27,5 @@ export enum IBigImageOpt {
|
||||
ADD_CURRENT_SRARCH, //添加到当前检索(目标检索)
|
||||
}
|
||||
|
||||
export type TAB_TYPE = 'COMPATER' | 'NORMAL' | 'TRACK';
|
||||
export type TAB_TYPE = 'COMPATER' | 'NORMAL' | 'VIDEO';
|
||||
export type MODEL_TYPE = 'VIDEO' | 'IMAGE';
|
||||
|
Loading…
Reference in New Issue
Block a user