Merge branch 'main' of http://113.45.157.195:3003/insiinc/re-mooc
This commit is contained in:
commit
165cb9f295
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useState } from "react";
|
import { ReactNode, useCallback, useState } from "react";
|
||||||
import {
|
import {
|
||||||
UploadOutlined,
|
UploadOutlined,
|
||||||
CheckCircleOutlined,
|
CheckCircleOutlined,
|
||||||
|
@ -12,6 +12,9 @@ export interface TusUploaderProps {
|
||||||
onChange?: (value: string[]) => void;
|
onChange?: (value: string[]) => void;
|
||||||
multiple?: boolean;
|
multiple?: boolean;
|
||||||
allowTypes?: string[];
|
allowTypes?: string[];
|
||||||
|
style?:string
|
||||||
|
icon?:ReactNode,
|
||||||
|
description?:string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UploadingFile {
|
interface UploadingFile {
|
||||||
|
@ -27,6 +30,9 @@ export const TusUploader = ({
|
||||||
onChange,
|
onChange,
|
||||||
multiple = true,
|
multiple = true,
|
||||||
allowTypes = undefined,
|
allowTypes = undefined,
|
||||||
|
style="",
|
||||||
|
icon = <UploadOutlined />,
|
||||||
|
description = "点击或拖拽文件到此区域进行上传",
|
||||||
}: TusUploaderProps) => {
|
}: TusUploaderProps) => {
|
||||||
const { handleFileUpload, uploadProgress } = useTusUpload();
|
const { handleFileUpload, uploadProgress } = useTusUpload();
|
||||||
const [uploadingFiles, setUploadingFiles] = useState<UploadingFile[]>([]);
|
const [uploadingFiles, setUploadingFiles] = useState<UploadingFile[]>([]);
|
||||||
|
@ -137,7 +143,7 @@ export const TusUploader = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-1">
|
<div className={`space-y-1 ${style}`}>
|
||||||
<Upload.Dragger
|
<Upload.Dragger
|
||||||
accept={allowTypes?.join(",")}
|
accept={allowTypes?.join(",")}
|
||||||
name="files"
|
name="files"
|
||||||
|
@ -145,18 +151,18 @@ export const TusUploader = ({
|
||||||
showUploadList={false}
|
showUploadList={false}
|
||||||
beforeUpload={handleBeforeUpload}>
|
beforeUpload={handleBeforeUpload}>
|
||||||
<p className="ant-upload-drag-icon">
|
<p className="ant-upload-drag-icon">
|
||||||
<UploadOutlined />
|
{icon}
|
||||||
</p>
|
</p>
|
||||||
<p className="ant-upload-text">
|
<p className="ant-upload-text">
|
||||||
点击或拖拽文件到此区域进行上传
|
{description}
|
||||||
</p>
|
</p>
|
||||||
<p className="ant-upload-hint">
|
<p className="ant-upload-hint">
|
||||||
{multiple ? "支持单个或批量上传文件" : "仅支持上传单个文件"}
|
{multiple ? "支持单个或批量上传文件" : "仅支持上传单个文件"}
|
||||||
{allowTypes && (
|
{/* {allowTypes && (
|
||||||
<span className="block text-xs text-gray-500">
|
<span className="block text-xs text-gray-500">
|
||||||
允许类型: {allowTypes.join(", ")}
|
允许类型: {allowTypes.join(", ")}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)} */}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="px-2 py-0 rounded mt-1">
|
<div className="px-2 py-0 rounded mt-1">
|
||||||
|
|
|
@ -3,6 +3,8 @@ import {
|
||||||
CaretRightOutlined,
|
CaretRightOutlined,
|
||||||
SaveOutlined,
|
SaveOutlined,
|
||||||
CaretDownOutlined,
|
CaretDownOutlined,
|
||||||
|
PaperClipOutlined,
|
||||||
|
PlaySquareOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import { Form, Button, Input, Select, Space } from "antd";
|
import { Form, Button, Input, Select, Space } from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
@ -175,12 +177,13 @@ export const SortableLecture: React.FC<SortableLectureProps> = ({
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 flex flex-2 flex-col gap-y-5 ">
|
<div className="mt-4 flex flex-2 flex-row gap-x-5 ">
|
||||||
{lectureType === LectureType.VIDEO ? (
|
{lectureType === LectureType.VIDEO ? (
|
||||||
<>
|
<>
|
||||||
|
<div className="mb-0 flex-1">
|
||||||
|
{/* <span className="inline-block w-full h-7 my-1 rounded-lg bg-slate-100 text-center leading-7">添加视频</span> */}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={["meta", "videoIds"]}
|
name={["meta", "videoIds"]}
|
||||||
className="mb-0 flex-1"
|
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -190,13 +193,24 @@ export const SortableLecture: React.FC<SortableLectureProps> = ({
|
||||||
<TusUploader
|
<TusUploader
|
||||||
allowTypes={videoMimeTypes}
|
allowTypes={videoMimeTypes}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
|
style={"h-64"}
|
||||||
|
icon={<PlaySquareOutlined />}
|
||||||
|
description="点击或拖拽视频到此区域进行上传"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
</div>
|
||||||
|
<div className="mb-0 flex-1">
|
||||||
|
{/* <span className="inline-block w-full h-7 my-1 rounded-lg bg-slate-100 text-center leading-7">添加附件</span> */}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={["meta", "fileIds"]}
|
name={["meta", "fileIds"]}>
|
||||||
className="mb-0 flex-1">
|
<TusUploader
|
||||||
<TusUploader multiple={true} />
|
style={"h-64"}
|
||||||
|
multiple={true}
|
||||||
|
icon={<PaperClipOutlined />}
|
||||||
|
description="点击或拖拽附件到此区域进行上传"
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
) : (
|
) : (
|
||||||
|
|
Loading…
Reference in New Issue