@ -28,7 +28,7 @@ const uuid = uuidv4();
const handleAdd = async ( fields : TableListItem ) = > {
const hide = message . loading ( '正在添加' ) ;
try {
await saveCourse ( { . . . fields , attachment_filesize : 0 , } ) ;
await saveCourse ( { . . . fields } ) ;
hide ( ) ;
message . success ( '添加成功' ) ;
return true ;
@ -45,7 +45,7 @@ const handleAdd = async (fields: TableListItem) => {
* @param fields
* /
const handleUpdate = async ( fields : FormValueType , currentRow? : TableListItem ) = > {
const hide = message . loading ( '正在 配置 ') ;
const hide = message . loading ( '正在 更新 ') ;
console . log ( 'fields' , fields )
try {
await saveCourse ( {
@ -53,11 +53,11 @@ console.log('fields',fields)
. . . fields ,
} ) ;
hide ( ) ;
message . success ( ' 配置 成功') ;
message . success ( ' 操作 成功') ;
return true ;
} catch ( error ) {
hide ( ) ;
message . error ( ' 配置 失败请重试!') ;
message . error ( ' 操作 失败请重试!') ;
return false ;
}
} ;
@ -176,7 +176,12 @@ const CourseList: React.FC = () => {
hideInTable : true ,
hideInForm : false ,
hideInSearch : true ,
renderText : ( val : string ) = > ` ${ val } 分钟 ` ,
render : ( text : React.ReactNode , _ : any , index : number ) = > {
return (
< div > { text } 分 钟 < / div >
)
} ,
// renderText: (val: string) => `${val} 分钟`,
formItemProps : {
// 参照 https://ant.design/components/form-cn/#Rule
rules : [
@ -255,7 +260,8 @@ const CourseList: React.FC = () => {
beforeUpload = { async ( file ) = > {
/** 获取视频文件信息 */
const { media : { track : [ General , Video , Audio ] } } = await getInfo ( file )
if ( Video . format !== 'AVC' || Audio . format !== 'AAC' ) {
console . log ( 'media' , General , Video , Audio )
if ( Video . Format !== 'AVC' || Audio . Format !== 'AAC' ) {
message . error ( '视频编码格式不正确( 视频采用AVC, 音频采用AAC) ' )
return false ;
}
@ -276,7 +282,7 @@ const CourseList: React.FC = () => {
maxCount = { 1 }
multiple = { false }
file = { ( ) = > {
// location.pathname
// location.pathname
} }
>
< Button icon = { < UploadOutlined / > } > 上 传 视 频 < / Button >
@ -300,7 +306,7 @@ const CourseList: React.FC = () => {
hideInForm : true ,
hideInSearch : true ,
width : 100 ,
renderText : ( val : string) = > ` ${ val } 字节 ` ,
renderText : ( val : number) = > ` ${ ( val / 1024 ) . toFixed ( 2 ) } KB ` ,
formItemProps : {
// 参照 https://ant.design/components/form-cn/#Rule
rules : [
@ -489,7 +495,7 @@ const CourseList: React.FC = () => {
fluid : true , // 当true时, Video.js player将拥有流体大小。换句话说, 它将按比例缩放以适应其容器。
sources : [
{
src : ( currentRow ? . attachment_json ? . url ) || '/dsideal_yy/html/down/Syzx/3b/3b225da8-87a5-4619-82a4-664ae2b37e23.mp4' , // 测试地址后续请删除
src : '/dsideal_yy/html/' + currentRow ? . attachment_json ? . url , // 测试地址后续请删除
type : 'application/x-mpegURL'
}
] ,
@ -578,11 +584,12 @@ const CourseList: React.FC = () => {
//return false;
// values.attachment_json.response.file.response.url
//console.log('currentRow', currentRow)
console . log ( 'values00000000000ss' , values )
console . log ( 'values00000000000ss' , values )
await handleAdd ( {
. . . values ,
//course_id: currentRow?.course_id,
attachment_json : ` {"img":"", "name": " ${ values . attachment_json . file . name } ", "url": "down/Syzx/ ${ uuid ? . substr ( 0 , 2 ) } / ${ uuid } .mp4"} `
attachment_json : ` {"img":"", "name": " ${ values ? . attachment_json ? . file ? . name } ", "url": "down/Syzx/ ${ uuid ? . substr ( 0 , 2 ) } / ${ uuid } .mp4"} ` ,
attachment_filesize : values?.attachment_json?.file?.size , // 字节
} ) ;
handleCreateModalVisible ( false ) ; // 隐藏创建窗口
actionRef . current ? . reloadAndRest ? . ( ) ;
@ -624,13 +631,14 @@ const CourseList: React.FC = () => {
//const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url;
//console.log('url', url)
console . log ( 'values编辑' , values )
await handleUpdate ( {
. . . values ,
attachment_filesize : attachment_json?.size || 0 , // Bit 字节
course_id : currentRow?.course_id ,
attachment_json : ` {"img":"", "name":" ${ values . attachment_json . file . name } ", "url": " ${ values . attachment_json ? . url } ", "size": " ${ values . attachment_json ? . size } "} `
} ) ;
await handleUpdate ( {
. . . values ,
attachment_json : ` {"img":"", "name": " ${ values . attachment_json . file . name } ", "url": "down/Syzx/ ${ uuid ? . substr ( 0 , 2 ) } / ${ uuid } .mp4"} ` ,
attachment_filesize : values.attachment_json?.size || 0 , // Bit 字节
course_id : currentRow?.course_id ,
// attachment_json:JSON.stringify(values.attachment_json)
// attachment_json: `{"img":"", "name":"${values.attachment_json.file.name}", "url": "${values.attachment_json?.url}", "size": "${values.attachment_json?.size}"}`
} ) ;
handleUpdateModalVisible ( false ) ; // 隐藏编辑窗口
actionRef . current ? . reloadAndRest ? . ( ) ;
console . log ( values ) ;