|
@@ -1,7 +1,8 @@
|
|
import { SceneType } from "constant"
|
|
import { SceneType } from "constant"
|
|
-import { memo } from 'react'
|
|
|
|
-import { Button, Upload, message, Input, Popover } from 'antd'
|
|
|
|
|
|
+import {memo, useState} from 'react'
|
|
|
|
+import {Button, Upload, message, Input, Popover, Progress, Modal} from 'antd'
|
|
import { useDispatch, uploadModelScene } from 'store'
|
|
import { useDispatch, uploadModelScene } from 'store'
|
|
|
|
+import styles from './style.module.scss'
|
|
|
|
|
|
import type { GetSceneByTypeParams, PagingRequest } from 'api'
|
|
import type { GetSceneByTypeParams, PagingRequest } from 'api'
|
|
import type { UploadProps } from 'antd'
|
|
import type { UploadProps } from 'antd'
|
|
@@ -16,6 +17,11 @@ type ListHeaderProps = {
|
|
|
|
|
|
export const SceneHeader = memo(({ readonly, type, onSearch, onDataChange }: ListHeaderProps) => {
|
|
export const SceneHeader = memo(({ readonly, type, onSearch, onDataChange }: ListHeaderProps) => {
|
|
const dispatch = useDispatch()
|
|
const dispatch = useDispatch()
|
|
|
|
+ const [progress, setProgress] = useState<number | null>(null);
|
|
|
|
+ const progressCallback = (num: number) => {
|
|
|
|
+ console.log(num)
|
|
|
|
+ setProgress(num === 100 ? null : num);
|
|
|
|
+ }
|
|
const onUpload: UploadProps['beforeUpload'] = file => {
|
|
const onUpload: UploadProps['beforeUpload'] = file => {
|
|
const filename = file.name
|
|
const filename = file.name
|
|
|
|
|
|
@@ -24,11 +30,11 @@ export const SceneHeader = memo(({ readonly, type, onSearch, onDataChange }: Lis
|
|
if (!isZip) {
|
|
if (!isZip) {
|
|
message.error('只能上传zip文件')
|
|
message.error('只能上传zip文件')
|
|
return Upload.LIST_IGNORE
|
|
return Upload.LIST_IGNORE
|
|
- } else if (file.size > 1 * 1024 * 1024 * 1024) {
|
|
|
|
|
|
+ } else if (file.size > 1024 * 1024 * 1024) {
|
|
message.error('大小在1GB以内')
|
|
message.error('大小在1GB以内')
|
|
return Upload.LIST_IGNORE
|
|
return Upload.LIST_IGNORE
|
|
}
|
|
}
|
|
- dispatch(uploadModelScene({ file }))
|
|
|
|
|
|
+ dispatch(uploadModelScene({ file, progressCallback }))
|
|
.unwrap()
|
|
.unwrap()
|
|
.finally(onDataChange)
|
|
.finally(onDataChange)
|
|
return Upload.LIST_IGNORE
|
|
return Upload.LIST_IGNORE
|
|
@@ -41,10 +47,28 @@ export const SceneHeader = memo(({ readonly, type, onSearch, onDataChange }: Lis
|
|
</Popover>
|
|
</Popover>
|
|
</Upload>
|
|
</Upload>
|
|
))
|
|
))
|
|
|
|
+ const renderProgress = progress
|
|
|
|
+ ? (
|
|
|
|
+ <Modal
|
|
|
|
+ title="文件上传中"
|
|
|
|
+ className={styles['upload-modal']}
|
|
|
|
+ centered
|
|
|
|
+ open={true}
|
|
|
|
+ width={1000}
|
|
|
|
+ footer={false}
|
|
|
|
+ closable={false}
|
|
|
|
+ >
|
|
|
|
+ <div style={{height: '100px'}}>
|
|
|
|
+ <Progress percent={progress} />
|
|
|
|
+ </div>
|
|
|
|
+ </Modal>
|
|
|
|
+ )
|
|
|
|
+ : null;
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className='content-header'>
|
|
<div className='content-header'>
|
|
{ renderUpload }
|
|
{ renderUpload }
|
|
|
|
+ { renderProgress }
|
|
<Input.Search
|
|
<Input.Search
|
|
allowClear
|
|
allowClear
|
|
className='content-header-search'
|
|
className='content-header-search'
|