From cb32d00818ef08f8db99e5deac2a4c2d1899693b Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Tue, 15 Mar 2022 12:44:13 +0800 Subject: [PATCH 1/4] fix --- web/package.json | 4 ++-- web/src/app.tsx | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/web/package.json b/web/package.json index df8b9ee..6f7c0fa 100644 --- a/web/package.json +++ b/web/package.json @@ -55,7 +55,7 @@ "@ant-design/pro-descriptions": "^1.6.8", "@ant-design/pro-form": "^1.18.3", "@ant-design/pro-layout": "^6.15.3", - "@ant-design/pro-table": "^2.30.8", + "@ant-design/pro-table": "^2.67.0", "@antv/data-set": "^0.11.0", "@antv/l7": "^2.3.7", "@antv/l7-maps": "^2.3.7", @@ -65,7 +65,7 @@ "@umijs/route-utils": "^1.0.36", "ahooks": "^3.0.5", "ahooks-v2": "^2.10.15", - "antd": "^4.14.0", + "antd": "^4.19.2", "base-64": "^1.0.0", "bizcharts": "^3.5.3-beta.0", "bizcharts-plugin-slider": "^2.1.1-beta.1", diff --git a/web/src/app.tsx b/web/src/app.tsx index 284f372..7bbc8ef 100644 --- a/web/src/app.tsx +++ b/web/src/app.tsx @@ -87,14 +87,30 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => { }; }; +/** 全局响应拦截 */ +const responseInterceptor = async (response: any, options: any) => { + const data = await response.clone().json(); + if (data && data?.status === '0') { + //location.href = location.pathname + '#/user/login'; // /#/user/login + history.push('/user/login') + } + console.log('返回了', response); + console.log('options', options); + return response; +}; + /** request 用于配置全局的网络请求,你可以在这里做拦截器,全局错误处理,鉴权的配置。*/ export const request: RequestConfig = { - errorHandler: (error: ResponseError) => { - /*notification.error({ + console.log('RequestConfig errorHandler', error) + /* + notification.error({ description: '您的网络发生异常,无法连接服务器', message: '网络异常', });*/ throw error; }, + //middlewares?: OnionMiddleware[], + //requestInterceptors: [requestInterceptor], // 请求前拦截器 + responseInterceptors: [responseInterceptor], // 响应拦截器 }; \ No newline at end of file From dca8b1f14ae6db23e0e1098f7f14caf9f45e426e Mon Sep 17 00:00:00 2001 From: wangxi <123456> Date: Tue, 15 Mar 2022 14:30:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B5=8B=E8=AF=95bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/course/detail/index.tsx | 22 ++++----- web/src/pages/dashboard/workplace/index.tsx | 53 +++++++++++++++------ 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/web/src/pages/course/detail/index.tsx b/web/src/pages/course/detail/index.tsx index c59d0a6..3f125ca 100644 --- a/web/src/pages/course/detail/index.tsx +++ b/web/src/pages/course/detail/index.tsx @@ -17,14 +17,13 @@ import VideoJS from '../components/VideoJS'; const { Paragraph } = Typography; const CardList = () => { + + const params = useParams(); + const ids = params.msg.split(',');//chapter_id,course_id,subject_id const [currentLearning, SetCurrentLearning] = useState(); - const [courseId, SetCourseId] = useState(); + const [courseId, SetCourseId] = useState(ids[1]); let time=0; const videoRef = useRef(null); - const params = useParams(); - const ids = params.msg.split(',');//chapter_id,course_id,subject_id - - console.log('courseIdcourseIdcourseIdcourseId',courseId) /** 获取课节 */ @@ -139,7 +138,8 @@ const CardList = () => { @@ -196,13 +196,13 @@ const CardList = () => { - { - const data = videoRef?.current?.currentTime(); + { + const data = videoRef?.current?.currentTime(); console.log('getData', data) - }}>videoRef get + }}>videoRef get - { - const data = videoRef?.current?.currentTime(300); + { + const data = videoRef?.current?.currentTime(300); console.log('setData', data) }}>videoRef set diff --git a/web/src/pages/dashboard/workplace/index.tsx b/web/src/pages/dashboard/workplace/index.tsx index 6bb09fe..4c9f021 100644 --- a/web/src/pages/dashboard/workplace/index.tsx +++ b/web/src/pages/dashboard/workplace/index.tsx @@ -260,26 +260,49 @@ const Workplace: FC = () => { position: 'top-center', }} point={{ size: 5 }} + tooltip={{ + customContent: (title: any, items: any): any => { + console.log('title',title); + console.log('items',items); + return( +
+
{title}
+
学习时长:{items[0]?items[0].data.learning_minutes:''}
+ +
+ + ) + } + }} /> - } - cover={} + { + JSON.stringify(lastLearningList)!=='{}'? + } + cover={} > - - {lastLearningList?.lecture_teacher} - {lastLearningList?.chapter_name} - {lastLearningList?.subject_name} - {lastLearningList?.total_course_minutes}分钟 - - + + {lastLearningList?.lecture_teacher} + {lastLearningList?.chapter_name} + {lastLearningList?.subject_name} + {lastLearningList?.total_course_minutes}分钟 + + + :
暂无数据
+ } Date: Tue, 15 Mar 2022 16:06:50 +0800 Subject: [PATCH 3/4] fix bug --- web/src/app.tsx | 6 +++++- web/src/pages/user/Login/index.tsx | 4 ++-- web/src/services/ant-design-pro/api.ts | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/web/src/app.tsx b/web/src/app.tsx index 7bbc8ef..61def5b 100644 --- a/web/src/app.tsx +++ b/web/src/app.tsx @@ -8,7 +8,7 @@ import { currentUser as queryCurrentUser, queryPersonTxByYw } from './services/a import { BookOutlined, LinkOutlined } from '@ant-design/icons'; import { RequestConfig } from 'umi'; import { ResponseError } from 'umi-request'; -import { notification } from 'antd'; +import { message, notification } from 'antd'; import cookie from 'react-cookies'; const isDev = process.env.NODE_ENV === 'development'; @@ -96,6 +96,10 @@ const responseInterceptor = async (response: any, options: any) => { } console.log('返回了', response); console.log('options', options); + console.log('data', data) + if(data?.success === false && options?.url === '/dsideal_yy/checkLoginStatus'){ + message.error(data?.info) + } return response; }; diff --git a/web/src/pages/user/Login/index.tsx b/web/src/pages/user/Login/index.tsx index 50cbb63..7fc3245 100644 --- a/web/src/pages/user/Login/index.tsx +++ b/web/src/pages/user/Login/index.tsx @@ -54,11 +54,11 @@ const Login: React.FC = () => { history.push(redirect || '/'); return; } - console.log(msg); + console.log('msg..', msg); // 如果失败去设置用户错误信息 setUserLoginState(msg); } catch (error) { - const defaultLoginFailureMessage = '登录失败,请重试!'; + const defaultLoginFailureMessage = msg?.info; message.error(defaultLoginFailureMessage); } }; diff --git a/web/src/services/ant-design-pro/api.ts b/web/src/services/ant-design-pro/api.ts index 72885c5..4cbb6fc 100644 --- a/web/src/services/ant-design-pro/api.ts +++ b/web/src/services/ant-design-pro/api.ts @@ -37,9 +37,9 @@ export async function outLogin(options?: { [key: string]: any }) { } /** 登录接口 POST /api/login/account */ -export async function login(body: API.LoginParams, options?: { [key: string]: any }) { - return request('/dsideal_yy/login/doLogin?login_type=1', { - method: 'POST', +export async function login(body: API.LoginParams, options?: { [key: string]: any }) { + return request('/dsideal_yy/checkLoginStatus', { // /dsideal_yy/login/doLogin?login_type=1 + method: 'POST', requestType: 'form', data: body, ...(options || {}), From ffc43e91ff704d12ea97fbc3d8a2ed370a7fe59d Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Tue, 15 Mar 2022 18:17:08 +0800 Subject: [PATCH 4/4] fix bug --- admin/src/pages/course/option/index.tsx | 11 ++++++++++- admin/src/pages/course/subject/step/index.tsx | 16 ++++++++++++++++ admin/src/pages/questionbank/index.tsx | 16 ++++++++++------ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/admin/src/pages/course/option/index.tsx b/admin/src/pages/course/option/index.tsx index 22f48a4..1a3242e 100644 --- a/admin/src/pages/course/option/index.tsx +++ b/admin/src/pages/course/option/index.tsx @@ -14,6 +14,8 @@ import type { TableListItem, TableListPagination } from './data'; import Tags from './components/Tags'; import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud'; import { VideoJS } from './components/VideoJS'; +import { getInfo } from 'react-mediainfo'; + import { v4 as uuidv4 } from 'uuid'; const uuid = uuidv4(); @@ -247,9 +249,16 @@ const CourseList: React.FC = () => { hideInDescriptions: true, renderFormItem: (item, { defaultRender, ...rest }, form) => ( { + beforeUpload={async (file) => { + /** 获取视频文件信息 */ + const {media: {track:[General, Video, Audio]}} = await getInfo(file) + if(Video.format !== 'AVC' || Audio.format !== 'AAC'){ + message.error('视频编码格式不正确(视频采用AVC,音频采用AAC)') + return false; + } // console.log('file', file) // 获取文件名 SetUploadFileName(file?.name); diff --git a/admin/src/pages/course/subject/step/index.tsx b/admin/src/pages/course/subject/step/index.tsx index e1ce51a..74996f6 100644 --- a/admin/src/pages/course/subject/step/index.tsx +++ b/admin/src/pages/course/subject/step/index.tsx @@ -439,10 +439,26 @@ export default () => { label="主题图片" max={2} fieldProps={{ + accept:'.jpg,.jpeg,.git,.png', name: 'file', listType: 'picture-card', maxCount: 1, beforeUpload: (file) => { + //限制图片 格式、size、分辨率 + const isJPG = file.type === 'image/jpeg'; + const isJPEG = file.type === 'image/jpeg'; + const isGIF = file.type === 'image/gif'; + const isPNG = file.type === 'image/png'; + if (!(isJPG || isJPEG || isGIF || isPNG)) { + message.error('只能上传JPG 、JPEG 、GIF、 PNG格式的图片~'); + return false; + } + const isLt2M = file.size / 1024 / 1024 < 2; + if (!isLt2M) { + message.error('超过2M限制,不允许上传~'); + return false; + } + // 获取文件名 SetUploadFileName(file?.name); // 获取最后一个.的位置 diff --git a/admin/src/pages/questionbank/index.tsx b/admin/src/pages/questionbank/index.tsx index 44f586a..fa278f2 100644 --- a/admin/src/pages/questionbank/index.tsx +++ b/admin/src/pages/questionbank/index.tsx @@ -376,13 +376,17 @@ const QuestionBank = () => { console.log('del selectedRowsState', selectedRowsState) const selectedRows = selectedRowsState?.map((item)=>({key:item?.id})) console.log('selectedRows', selectedRows) - const success = await handleRemove(selectedRows); - if (success) { - // handleModalVisible(false); - if (actionRef.current) { - setSelectedRows([]); - actionRef.current?.reload(); + if(selectedRows?.length > 0){ + const success = await handleRemove(selectedRows); + if (success) { + // handleModalVisible(false); + if (actionRef.current) { + setSelectedRows([]); + actionRef.current?.reload(); + } } + }else{ + message.warn('请选择删除项') } }}> 批量删除