-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
261 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getFileSrc } from '@/knife' | ||
import { DeleteOutlined } from '@ant-design/icons' | ||
|
||
import type { IPropsCustomRender } from '../types' | ||
|
||
const Index = (props: IPropsCustomRender) => { | ||
const { file, remove } = props | ||
|
||
return ( | ||
<div className='upload_custom_wrap flex relative'> | ||
<div className='icon_delete absolute justify_center align_center transition_normal' onClick={remove}> | ||
<DeleteOutlined className='icon'></DeleteOutlined> | ||
</div> | ||
<video className='video' src={getFileSrc(file.response!)} controls></video> | ||
</div> | ||
) | ||
} | ||
|
||
export default window.$app.memo(Index) |
28 changes: 9 additions & 19 deletions
28
packages/xgen/components/edit/Upload/components/UploadBtn.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,82 @@ | ||
import Video from './components/Video' | ||
import Audio from './components/Audio' | ||
import Image from './components/Image' | ||
|
||
import type { FileType } from './types' | ||
import type { FileType, PreviewProps } from './types' | ||
import { UploadFile } from 'antd' | ||
|
||
export default { | ||
image: { | ||
listType: 'picture-card', | ||
className: 'image', | ||
desc: { | ||
placeholder: { | ||
'zh-CN': '上传图片', | ||
'en-US': 'Upload Image' | ||
}, | ||
placeholderIcon: 'icon-upload', | ||
preview: (props: PreviewProps, file: UploadFile<string>, remove: () => void) => { | ||
return <Image file={file} imageSize={getSize(props.size)} remove={remove} /> | ||
} | ||
}, | ||
|
||
audio: { | ||
listType: 'picture-card', | ||
className: 'image', | ||
placeholder: { | ||
'zh-CN': '上传音频', | ||
'en-US': 'Upload Audio' | ||
}, | ||
placeholderIcon: 'icon-upload', | ||
preview: (props: PreviewProps, file: UploadFile<string>, remove: () => void) => { | ||
return <div>Image</div> | ||
} | ||
}, | ||
|
||
file: { | ||
listType: 'text', | ||
className: 'file', | ||
desc: { | ||
listType: 'picture-card', | ||
className: 'image', | ||
placeholder: { | ||
'zh-CN': '上传文件', | ||
'en-US': 'Upload File' | ||
}, | ||
placeholderIcon: 'icon-upload', | ||
preview: (props: PreviewProps, file: UploadFile<string>, remove: () => void) => { | ||
return <div>File</div> | ||
} | ||
}, | ||
|
||
video: { | ||
listType: 'picture-card', | ||
className: 'video', | ||
desc: { | ||
className: 'image', | ||
placeholder: { | ||
'zh-CN': '上传视频', | ||
'en-US': 'Upload Video' | ||
}, | ||
render: (_, file, fileList, { remove }) => <Video file={file} remove={remove}></Video> | ||
placeholderIcon: 'icon-upload', | ||
preview: (props: PreviewProps, file: UploadFile<string>, remove: () => void) => { | ||
return <div>Video</div> | ||
} | ||
} | ||
} as FileType | ||
|
||
function getSize(size: PreviewProps['size']): PreviewProps['size'] { | ||
const defaultSize: PreviewProps['size'] = { | ||
width: size?.width || '90px', | ||
height: size?.height || '90px', | ||
ratio: size?.ratio || 1 | ||
} | ||
|
||
if (defaultSize.ratio && defaultSize.ratio != 1) { | ||
const width = parseInt(defaultSize.width as string) | ||
const height = parseInt(defaultSize.height as string) | ||
if (!width && !height) { | ||
defaultSize.width = '100%' | ||
defaultSize.height = `${100 * defaultSize.ratio}%` | ||
} | ||
if (width) { | ||
defaultSize.width = `${width * defaultSize.ratio}px` | ||
} else if (height) defaultSize.height = `${width * defaultSize.ratio}px` | ||
} | ||
|
||
return defaultSize | ||
} |
Oops, something went wrong.