feat: 本次提交更新内容如下

改造下视频上传组件
This commit is contained in:
笔记本里的永平
2025-07-15 15:21:53 +08:00
parent 6a89573558
commit 0e8bb566b5
2 changed files with 101 additions and 14 deletions

View File

@@ -14,6 +14,7 @@ import { Upload } from 'tdesign-mobile-react';
import type { UploadFile as TDesignUploadFile } from 'tdesign-mobile-react/es/upload/type';
import { uploadImage } from '@/api/upload';
import UploadImage from '@/components/UploadImage';
import UploadVideo from '@/components/UploadVideo';
export default function NewMaterial() {
const navigate = useNavigate();
@@ -161,7 +162,7 @@ export default function NewMaterial() {
<select
value={contentType}
onChange={e => setContentType(Number(e.target.value))}
className="w-full h-12 rounded-2xl border border-gray-300 focus:border-blue-500 focus:ring-2 focus:ring-blue-100 px-4 text-base bg-white appearance-none"
className="w-full h-12 border border-gray-300 focus:border-blue-500 focus:ring-2 focus:ring-blue-100 px-4 text-base bg-white appearance-none"
>
<option value="" disabled></option>
<option value={1}></option>
@@ -217,20 +218,12 @@ export default function NewMaterial() {
{contentType === 3 && (
<>
<Label className="font-bold mb-2"></Label>
<div className="flex items-center gap-4">
{!videoUrl ? (
<Button type="button" variant="outline" className="rounded-2xl border-dashed border-2 border-blue-300 bg-white hover:bg-blue-50 h-28 w-44 flex flex-col items-center justify-center p-0" onClick={() => setVideoUrl('https://www.w3schools.com/html/mov_bbb.mp4')}>
<UploadCloud className="h-8 w-8 mb-2 text-gray-400 mx-auto" />
<span className="text-sm text-gray-500"></span>
</Button>
) : (
<div className="relative">
<video src={videoUrl} controls className="object-contain rounded-xl h-24 w-40 mx-auto my-auto" />
<Button type="button" variant="base" size="small" className="absolute top-1 right-1 h-8 px-2 rounded-lg" onClick={() => setVideoUrl('')}></Button>
</div>
)}
<div className="pt-4">
<UploadVideo
value={videoUrl}
onChange={setVideoUrl}
/>
</div>
<div className="text-xs text-gray-400 mt-1">MP420MB</div>
</>
)}
</div>