From 26f51df7233917f526c6021948248c134b781686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4=E6=B5=AE=E5=B0=98?= <18510549872@163.comm> Date: Mon, 23 Oct 2023 00:16:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/question-list/index.jsx | 5 +- src/router/index.tsx | 2 +- src/views/brush-questions/index.tsx | 80 ++++++++++++++++++++++++-- src/views/question-bank/index.tsx | 3 +- 4 files changed, 81 insertions(+), 9 deletions(-) diff --git a/src/components/question-list/index.jsx b/src/components/question-list/index.jsx index 23b2551..4e784f4 100644 --- a/src/components/question-list/index.jsx +++ b/src/components/question-list/index.jsx @@ -123,7 +123,7 @@ const QuestionList = (props) => { const onChangeAction = (item, index) => () => { let { isNotToDetail, difficulty, primaryCategoryId, labelList, pageIndex } = props; - !isNotToDetail && navigate("/brush-question") + !isNotToDetail && navigate("/brush-question/" + item.id) // this.props.history.push( // splicingQuery("/brush-questions", { // id: item?.id, @@ -191,9 +191,10 @@ const QuestionList = (props) => { }} columns={questionColumns} dataSource={questionList} - rowKey={(record) => record.id} + rowKey="id" pagination={false} rowClassName="question-table-row" + /> {/* {total > 10 && ( , }, { - path: "brush-question", + path: "brush-question/:id", element: , }, { diff --git a/src/views/brush-questions/index.tsx b/src/views/brush-questions/index.tsx index 0944fbb..1e16a0d 100644 --- a/src/views/brush-questions/index.tsx +++ b/src/views/brush-questions/index.tsx @@ -1,11 +1,83 @@ import { Pagination, Button, Modal, Input, Radio, message } from 'antd' -import React, { Component, Fragment } from 'react' -import { queryParse } from '@utils' +import React, { Component, Fragment, useState, useEffect } from 'react' +import { useParams } from 'react-router-dom' import GoodCollectionError from '@components/good-collection-error' import './index.less' import req from '@utils/request' -export default class BrushQuestions extends Component { +const grade: Record = { + 1: '初级', + 2: '中级', + 3: '高级', + 4: '资深', + 5: '专家', +} + +const BrushQuestions = () => { + + const { id } = useParams() + const [question, setQuestion] = useState>(null) + const [index, setIndex] = useState(1) + + useEffect(() => { + if (!id) return + req({ + method: 'post', + data: { + id + }, + url: '/querySubjectInfo', + }) + .then((res) => { + if (res.success && res.data) { + setQuestion(res.data) + } + }) + .catch((err) => console.log(err)) + }, [id]) + + return ( +
+
+
+
+
{index}
+
问答题
+
+
+
+ { + question ? +
+
+ {grade[question.subjectDifficult]}-{question?.labelName.join('、')} +
+
{question.subjectName}
+
+
+
参考答案
+
+
+
+
+ +
+
: null + } +
+ ) +} + +export default BrushQuestions + +class BrushQuestions1 extends Component { constructor(props) { super(props) this.state = { @@ -64,7 +136,7 @@ export default class BrushQuestions extends Component { return await req({ method: 'post', data: params, - url: '/admin/question/subject/getSubjectList', + url: '/querySubjectInfo', }) .then((res) => { if (res.data && res.data?.pageList?.length > 0) { diff --git a/src/views/question-bank/index.tsx b/src/views/question-bank/index.tsx index 9b1b70e..c621bcb 100644 --- a/src/views/question-bank/index.tsx +++ b/src/views/question-bank/index.tsx @@ -7,7 +7,6 @@ import RankingList from './components/ranking-list' import { apiName } from './constant'; import req from '@utils/request'; import { Spin } from 'antd'; -import { mockDataList } from './mock'; import './index.less'; const QuestionBank = () => { @@ -132,8 +131,8 @@ const QuestionBank = () => {
- +
);