feat: 修改部分文案及删除多余内容

This commit is contained in:
秋水浮尘
2023-11-14 00:52:40 +08:00
parent 13f794caea
commit 3218fccf7c
15 changed files with 702 additions and 773 deletions

View File

@@ -1,17 +1,18 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" /> <link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<title>Vite App</title> <title>鸡翅CLUB</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.tsx"></script> <script type="module" src="/src/main.tsx"></script>
</body> </body>
</html> </html>

View File

@@ -1,20 +1,30 @@
import { useEffect, memo } from 'react';
import './App.less';
import { useLocation, useNavigate, Outlet } from 'react-router-dom';
import Header from '@views/header' import Header from '@views/header'
import { memo, useEffect } from 'react'
import { Outlet, useLocation, useNavigate } from 'react-router-dom'
import './App.less'
const App = () => { const App = () => {
const location = useLocation(); const location = useLocation()
const navigate = useNavigate() const navigate = useNavigate()
useEffect(() => { useEffect(() => {
if (location.pathname === '/') { if (location.pathname === '/') {
const userInfoStorage = localStorage.getItem('userInfo')
if (!userInfoStorage) {
return window.location.replace('/login')
}
navigate('/question-bank') navigate('/question-bank')
} }
}, [location]) }, [location])
return ( return (
<div className="app-main" style={{ padding: location.pathname === '/login' ? '66px 0 0' : '66px 16px 32px' }}> <div
className='app-main'
style={{ padding: location.pathname === '/login' ? '66px 0 0' : '66px 16px 32px' }}
>
<Header /> <Header />
<div className='content-box' style={{ width: location.pathname === '/login' ? '100%' : '1439px' }}> <div
className='content-box'
style={{ width: location.pathname === '/login' ? '100%' : '1439px' }}
>
<Outlet /> <Outlet />
</div> </div>
</div> </div>

View File

@@ -1,4 +1,4 @@
@import "normalize.less"; @import 'normalize.less';
* { * {
box-sizing: border-box; box-sizing: border-box;
@@ -8,7 +8,8 @@
body, body,
html { html {
font-family: -apple-system, "宋体","微软雅黑"; font-family: -apple-system, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB',
'微软雅黑', Arial, sans-serif;
width: 100%; width: 100%;
height: 100%; height: 100%;
color: #666666; color: #666666;
@@ -26,7 +27,7 @@ a {
display: block; display: block;
clear: both; clear: both;
height: 0; height: 0;
content: ""; content: '';
} }
.arrow-right { .arrow-right {
@@ -51,11 +52,11 @@ a {
box-shadow: none; box-shadow: none;
} }
.ant-input:focus, .ant-input:hover { .ant-input:focus,
.ant-input:hover {
border-color: #d9d9d9; border-color: #d9d9d9;
} }
.ant-input-affix-wrapper:hover .ant-input:not(.ant-input-disabled) { .ant-input-affix-wrapper:hover .ant-input:not(.ant-input-disabled) {
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
} }

View File

@@ -305,6 +305,7 @@ const CategoryList = ({ primaryCategoryId, categoryList, ...props }) => {
dashed dashed
style={{ style={{
marginTop: 10, marginTop: 10,
marginBottom: 10,
fontSize: 13, fontSize: 13,
cursor: 'pointer' cursor: 'pointer'
}} }}
@@ -326,11 +327,6 @@ const CategoryList = ({ primaryCategoryId, categoryList, ...props }) => {
<div className='category-box'> <div className='category-box'>
<Fragment>{categoryList?.length && renderFirstContainer()}</Fragment> <Fragment>{categoryList?.length && renderFirstContainer()}</Fragment>
<Fragment>{secondCategoryList?.length > 0 && renderSecondContainer()}</Fragment> <Fragment>{secondCategoryList?.length > 0 && renderSecondContainer()}</Fragment>
{/* {!this.props.isHideSec && (
<Fragment>
{secondCategoryList?.length > 0 && this.renderSecondContainer()}
</Fragment>
)} */}
<Modal <Modal
open={openMoreFlag} open={openMoreFlag}
footer={null} footer={null}

View File

@@ -65,7 +65,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 16px; margin-right: 16px;
min-width: 60px; min-width: 70px;
height: 40px; height: 40px;
font-size: 14px; font-size: 14px;
color: rgba(0, 0, 0, 0.85); color: rgba(0, 0, 0, 0.85);
@@ -90,32 +90,18 @@
margin: 8px 15px 8px 0; margin: 8px 15px 8px 0;
cursor: pointer; cursor: pointer;
font-size: 14px; font-size: 14px;
border: 1px solid rgba(0, 0, 0, 0.04); border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px; border-radius: 4px;
// @mixin box-backgroundColor($alpha: 1) {
// background-color: rgba(60, 110, 238, $alpha) !important;
// }
// @mixin box-border($width: 1px, $style: solid, $alpha: 1) {
// border: $width $style rgba(60, 110, 238, $alpha) !important;
// }
// @mixin font-color($alpha: 1) {
// color: rgba(60, 110, 238, $alpha) !important;
// }
&:hover { &:hover {
background-color: rgba(60, 110, 238, 0.1); background-color: rgba(60, 110, 238, 0.1);
border: 1px solid rgba(60, 110, 238, 1); border: 1px solid rgba(60, 110, 238, 1);
color: rgba(60, 110, 238, 1) color: rgba(60, 110, 238, 1);
} }
} }
.third-category-item-active { .third-category-item-active {
// @include box-backgroundColor(0.1);
// @include box-border();
// @include font-color();
background-color: rgba(60, 110, 238, 0.1); background-color: rgba(60, 110, 238, 0.1);
border: 1px solid rgba(60, 110, 238, 1); border: 1px solid rgba(60, 110, 238, 1);
color: rgba(60, 110, 238, 1) color: rgba(60, 110, 238, 1);
} }
} }
.second-category-item-status { .second-category-item-status {

View File

@@ -1,8 +1,7 @@
import React, { Component } from 'react' import { HeartTwoTone, InfoCircleTwoTone, LikeTwoTone } from '@ant-design/icons'
import { Modal, Input, Radio, message } from 'antd'
import { HeartTwoTone, LikeTwoTone, InfoCircleTwoTone } from '@ant-design/icons'
import { collection, good } from './constant'
import req from '@utils/request' import req from '@utils/request'
import { Input, Modal, Radio, message } from 'antd'
import React, { Component } from 'react'
import './index.less' import './index.less'
const { TextArea } = Input const { TextArea } = Input
@@ -19,19 +18,19 @@ export default class GoodCollectionError extends Component {
isModal: false, //是否显示纠错弹框 isModal: false, //是否显示纠错弹框
value: 1, //纠错类型对应值 value: 1, //纠错类型对应值
inputValue: '', //纠错详情内容 inputValue: '', //纠错详情内容
questionId: '', //题目id questionId: '' //题目id
} }
} }
/**纠错类型 */ /**纠错类型 */
errorType = [ errorType = [
{ {
value: 1, value: 1,
content: '答案错误', content: '答案错误'
}, },
{ {
value: 2, value: 2,
content: '题目与答案不符', content: '题目与答案不符'
}, }
] ]
componentDidMount() { componentDidMount() {
// this.getDetail() // this.getDetail()
@@ -39,32 +38,33 @@ export default class GoodCollectionError extends Component {
getDetail() { getDetail() {
let params = { let params = {
subjectId: this.props.questionId, subjectId: this.props.questionId
} }
req({ req({
method: 'post', method: 'post',
data: params, data: params,
url: 'admin/question/collect/getDetail', url: 'admin/question/collect/getDetail'
}) })
.then((res) => { .then(res => {
if (res.data) { if (res.data) {
this.setState({ this.setState({
isGood: res.data.isThump, isGood: res.data.isThump,
goodAmount: res.data.thumpCount, goodAmount: res.data.thumpCount,
isCollection: res.data.isCollect, isCollection: res.data.isCollect,
collectionAmount: res.data.collectCount, collectionAmount: res.data.collectCount
}) })
} }
}) })
.catch((err) => console.log(err)) .catch(err => console.log(err))
} }
/** /**
* 点击纠错按钮 * 点击纠错按钮
*/ */
handleModal = () => { handleModal = () => {
return message.info('敬请期待')
this.setState({ this.setState({
isModal: true, isModal: true
}) })
} }
/** /**
@@ -77,20 +77,20 @@ export default class GoodCollectionError extends Component {
let params = { let params = {
subjectId: questionId, subjectId: questionId,
errorType: value, errorType: value,
errorMsg: inputValue, errorMsg: inputValue
} }
if (inputValue.length === 0) { if (inputValue.length === 0) {
message.warning('请填写纠错详情!') message.warning('请填写纠错详情!')
} else { } else {
this.setState({ this.setState({
isModal: false, isModal: false,
inputValue: '', inputValue: ''
}) })
message.success('感谢纠错,立即更改!') message.success('感谢纠错,立即更改!')
JDreq({ req({
method: 'post', method: 'post',
data: params, data: params,
url: '/admin/question/subjectError/add', url: '/admin/question/subjectError/add'
}) })
} }
} }
@@ -100,25 +100,25 @@ export default class GoodCollectionError extends Component {
handleCancel = () => { handleCancel = () => {
this.setState({ this.setState({
isModal: false, isModal: false,
inputValue: '', inputValue: ''
}) })
} }
/** /**
* *
* @param {选择纠错类型} e * @param {选择纠错类型} e
*/ */
handleChangeRadio = (e) => { handleChangeRadio = e => {
this.setState({ this.setState({
value: e.target.value, value: e.target.value
}) })
} }
/** /**
* *
* @param {纠错详情中填写内容} e * @param {纠错详情中填写内容} e
*/ */
handleChangeInput = (e) => { handleChangeInput = e => {
this.setState({ this.setState({
inputValue: e.target.value, inputValue: e.target.value
}) })
} }
/** /**
@@ -130,19 +130,19 @@ export default class GoodCollectionError extends Component {
const { isGood, goodAmount } = this.state const { isGood, goodAmount } = this.state
const { questionId } = this.props const { questionId } = this.props
let params = { let params = {
subjectId: questionId, subjectId: questionId
} }
this.setState( this.setState(
{ {
isGood: isGood === true ? false : true, isGood: isGood === true ? false : true,
goodAmount: isGood === true ? goodAmount - 1 : goodAmount + 1, goodAmount: isGood === true ? goodAmount - 1 : goodAmount + 1
}, },
() => { () => {
JDreq({ req({
method: 'post', method: 'post',
data: params, data: params,
url: 'admin/question/thump/addOrCancel', url: 'admin/question/thump/addOrCancel'
}).catch((err) => console.log(err)) }).catch(err => console.log(err))
} }
) )
} }
@@ -154,62 +154,68 @@ export default class GoodCollectionError extends Component {
const { isCollection, collectionAmount } = this.state const { isCollection, collectionAmount } = this.state
const { questionId } = this.props const { questionId } = this.props
let params = { let params = {
subjectId: questionId, subjectId: questionId
} }
this.setState( this.setState(
{ {
isCollection: isCollection === true ? false : true, isCollection: isCollection === true ? false : true,
collectionAmount: isCollection === true ? collectionAmount - 1 : collectionAmount + 1, collectionAmount: isCollection === true ? collectionAmount - 1 : collectionAmount + 1
}, },
() => { () => {
req({ req({
method: 'post', method: 'post',
data: params, data: params,
url: 'admin/question/collect/addOrCancel', url: 'admin/question/collect/addOrCancel'
}).catch((err) => console.log(err)) }).catch(err => console.log(err))
} }
) )
} }
render() { render() {
const { isCollection, isGood, isModal, value, collectionAmount, goodAmount } = this.state const { isCollection, isGood, isModal, value, collectionAmount, goodAmount } = this.state
return ( return (
<div className="left"> <div className='left'>
<div <div
className="good" className='good'
size="middle" size='middle'
onClick={() => { onClick={() => {
this.handleChangeGood() this.handleChangeGood()
}} }}
> >
<LikeTwoTone twoToneColor={isGood == false ? 'grey' : 'blue'} style={{ marginRight: 4 }} />({goodAmount}) <LikeTwoTone
twoToneColor={isGood == false ? 'grey' : 'blue'}
style={{ marginRight: 4 }}
/>
({goodAmount})
</div> </div>
<div <div
className="collection" className='collection'
onClick={() => { onClick={() => {
this.handleChangeCollection() this.handleChangeCollection()
}} }}
> >
<HeartTwoTone twoToneColor={isCollection == false ? 'grey' : 'blue'} style={{ marginRight: 4 }} />( <HeartTwoTone
{collectionAmount}) twoToneColor={isCollection == false ? 'grey' : 'blue'}
style={{ marginRight: 4 }}
/>
({collectionAmount})
</div> </div>
{/* <div className="comment"> {/* <div className="comment">
<MessageTwoTone twoToneColor="blue" style={{ marginRight: 4 }} /> <MessageTwoTone twoToneColor="blue" style={{ marginRight: 4 }} />
评论 评论
</div> */} </div> */}
<div <div
className="error-collection" className='error-collection'
onClick={() => { onClick={() => {
console.log('111')
this.handleModal() this.handleModal()
}} }}
> >
<InfoCircleTwoTone twoToneColor="red" style={{ marginRight: 4 }} /> <InfoCircleTwoTone twoToneColor='red' style={{ marginRight: 4 }} />
纠错 纠错
</div> </div>
<Modal <Modal
className="error-modal" className='error-modal'
title="题目纠错" title='题目纠错'
visible={isModal} open={isModal}
destroyOnClose={true} destroyOnClose={true}
onOk={() => { onOk={() => {
this.handleOk() this.handleOk()
@@ -217,25 +223,25 @@ export default class GoodCollectionError extends Component {
onCancel={() => { onCancel={() => {
this.handleCancel() this.handleCancel()
}} }}
okText="确认" okText='确认'
cancelText="取消" cancelText='取消'
style={{ fontWeight: 500 }} style={{ fontWeight: 500 }}
> >
<div> <div>
<div className="error-collection-title">纠错类型</div> <div className='error-collection-title'>纠错类型</div>
<div className="error-collection-type"> <div className='error-collection-type'>
{this.errorType.map((item, index) => { {this.errorType.map((item, index) => {
return ( return (
<div key={index} className="error-collection-type-detail"> <div key={index} className='error-collection-type-detail'>
<Radio.Group <Radio.Group
onChange={(e) => { onChange={e => {
this.handleChangeRadio(e) this.handleChangeRadio(e)
}} }}
defaultValue={1} defaultValue={1}
buttonStyle="solid" buttonStyle='solid'
value={value} value={value}
> >
<Radio.Button value={item.value} className="ll"> <Radio.Button value={item.value} className='ll'>
{item.content} {item.content}
</Radio.Button> </Radio.Button>
</Radio.Group> </Radio.Group>
@@ -243,14 +249,14 @@ export default class GoodCollectionError extends Component {
) )
})} })}
</div> </div>
<div className="error-collection-title">纠错详情</div> <div className='error-collection-title'>纠错详情</div>
<TextArea <TextArea
className="error-input" className='error-input'
placeholder="请输入..." placeholder='请输入...'
maxLength={256} maxLength={256}
rows={4} rows={4}
showCount={true} showCount={true}
onChange={(e) => { onChange={e => {
this.handleChangeInput(e) this.handleChangeInput(e)
}} }}
/> />

View File

@@ -69,8 +69,6 @@
padding: 0px 6px; padding: 0px 6px;
font-size: 10px !important; font-size: 10px !important;
border-radius: 4px; border-radius: 4px;
// @include font-color();
// border: 1px solid rgba(60, 110, 238, 0.6);
} }
} }
} }

View File

@@ -54,9 +54,3 @@ export const gradeObject = {
title: '专家' title: '专家'
} }
} }
export const imgObject = {
clickImg:
host +
'/jichi/icon/%E7%83%AD%E9%97%A8.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minioadmin%2F20231102%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231102T153146Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=e6b8cdb3231b1c3d7114212cb9278ecc17cf6d4ec0f759ea0200e04156d4c8b7'
}

View File

@@ -15,7 +15,6 @@ export const baseHttp = () => {
} }
export default function request(config, url) { export default function request(config, url) {
console.log(config, url, 'config url')
// const navigate = useNavigate() // const navigate = useNavigate()
const userInfoStorage = localStorage.getItem('userInfo') const userInfoStorage = localStorage.getItem('userInfo')
const userInfo = userInfoStorage ? JSON.parse(userInfoStorage) : {} const userInfo = userInfoStorage ? JSON.parse(userInfoStorage) : {}

View File

@@ -1,9 +1,9 @@
export const good = { export const good = {
0: '未点赞', 0: '未点赞',
1:'已点赞', 1: '已点赞'
} }
export const collection = { export const collection = {
0: '未收藏', 0: '未收藏',
1:'已收藏', 1: '已收藏'
} }

View File

@@ -1,8 +1,6 @@
.brush-questions-box { .brush-questions-box {
width: 1439px; width: 1439px;
margin: 0 auto; margin: 0 auto;
// display: flex;
background-color: #fff; background-color: #fff;
padding: 20px 50px; padding: 20px 50px;
border-radius: 5px; border-radius: 5px;
@@ -10,17 +8,13 @@
overflow: auto; overflow: auto;
.brush-questions-box, .brush-questions-box,
.question-box { .question-box {
// display: flex;
// flex: 1;
flex-direction: column; flex-direction: column;
overflow-y: auto; overflow-y: auto;
background-color: #fff; background-color: #fff;
border-radius: 8px; border-radius: 8px;
// position: relative;
.question, .question,
.question-content { .question-content {
display: flex; display: flex;
// flex: 1;
.question-type, .question-type,
.question-number { .question-number {
display: flex; display: flex;
@@ -30,9 +24,6 @@
} }
} }
} }
// .answer-box{
// }
.question-box { .question-box {
margin-bottom: 10px; margin-bottom: 10px;
} }
@@ -40,24 +31,19 @@
margin-bottom: 20px; margin-bottom: 20px;
} }
.question-type { .question-type {
// padding-left: 50px;
color: rgba(60, 110, 238, 1) !important; color: rgba(60, 110, 238, 1) !important;
font-size: 16px; font-size: 16px;
} }
.question-number { .question-number {
justify-content: right; justify-content: right;
// padding-right: 50px;
color: rgba(60, 110, 238, 1) !important; color: rgba(60, 110, 238, 1) !important;
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
// padding:2px 10px;
} }
.question-content { .question-content {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 16px; font-size: 16px;
// padding: 20px 0 20px 30px;
// border-bottom:1px dashed #000
line-height: 35px; line-height: 35px;
margin-top: 50px; margin-top: 50px;
margin-bottom: 10px; margin-bottom: 10px;
@@ -98,27 +84,10 @@
margin: 10px 0 10px 700px; margin: 10px 0 10px 700px;
} }
// .question-number-box{
// position:absolute;right:0px;
// }
// .right{
// position:absolute;right:0px;
// }
.jump-question { .jump-question {
margin: 0 auto; margin: 0 auto;
text-align: center; text-align: center;
} }
// .answer-box,.question-box{
// display: flex;
// flex: 1;
// overflow-y: auto;
// border-radius: 8px;
// // position: relative;
// background-color: rgb(84, 169, 248);
// font-size: 20px;
// height: auto;
// min-height:200px;
// }
.last, .last,
.next { .next {
// background-color: rgba(60, 110, 238,1) !important; // background-color: rgba(60, 110, 238,1) !important;
@@ -127,20 +96,7 @@
cursor: pointer; cursor: pointer;
width: 110px; width: 110px;
height: 46px; height: 46px;
// color: white
} }
// .question-type-box,.question-number-box {
// height: 200px;
// line-height: 200px;
// font-size: 30px;
// font-weight: bold;
// color: rgb(84, 169, 248);
// }
// .word{
// font-size: 20px;
// font-weight: bold;
// color: rgb(84, 169, 248);
// }
.last:active, .last:active,
.next:active { .next:active {
background-color: rgba(60, 110, 238, 1) !important; background-color: rgba(60, 110, 238, 1) !important;

View File

@@ -38,13 +38,9 @@
&:last-child { &:last-child {
margin-right: 0px; margin-right: 0px;
} }
&:hover {
// @include font-color();
}
} }
.ranking-list-btn-active { .ranking-list-btn-active {
font-weight: 600; font-weight: 600;
// @include font-color();
border-bottom: 1px solid rgba(60, 110, 238, 1); border-bottom: 1px solid rgba(60, 110, 238, 1);
} }
} }
@@ -101,7 +97,6 @@
color: #c3c3c6; color: #c3c3c6;
} }
&:hover { &:hover {
// @include box-backgroundColor(0.05);
background-color: rgba(60, 110, 238, 0.05); background-color: rgba(60, 110, 238, 0.05);
} }
} }
@@ -119,7 +114,6 @@
border-radius: 30px; border-radius: 30px;
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
background-color: rgba(60, 110, 238, 0.9); background-color: rgba(60, 110, 238, 0.9);
// @include box-backgroundColor(0.9);
.ranking-btn-go-icon { .ranking-btn-go-icon {
width: 22px; width: 22px;
height: 22px; height: 22px;

View File

@@ -1,28 +1,26 @@
import { useState, useEffect, memo } from 'react' import CategoryList from '@components/category-list'
import QuestionList from '@components/question-list'; import QuestionList from '@components/question-list'
import CategoryList from '@components/category-list'; import req from '@utils/request'
import ContributionList from './components/contribution-list'; import { memo, useEffect, useState } from 'react'
import ContributionList from './components/contribution-list'
import RankingList from './components/practice-list' import RankingList from './components/practice-list'
import { apiName } from './constant'; import { apiName } from './constant'
import req from '@utils/request'; import './index.less'
import './index.less';
const QuestionBank = () => { const QuestionBank = () => {
const [firstCategoryList, setFirstCategoryList] = useState<Record<string, any>[]>([]) const [firstCategoryList, setFirstCategoryList] = useState<Record<string, any>[]>([])
const [questionList, setQuestionList] = useState([]) const [questionList, setQuestionList] = useState([])
const [labelList, setLabelList] = useState<string | number>(); // 选中的标签列表 const [labelList, setLabelList] = useState<string | number>() // 选中的标签列表
const [difficulty, setDiffculty] = useState(''); //困难度(全部) const [difficulty, setDiffculty] = useState('') //困难度(全部)
const [total, setTotal] = useState(0); // 总条数 const [total, setTotal] = useState(0) // 总条数
const [pageIndex, setPageIndex] = useState(0); const [pageIndex, setPageIndex] = useState(0)
const [primaryCategoryId, setPromaryCategoryId] = useState(''); //第一个大类id const [primaryCategoryId, setPromaryCategoryId] = useState('') //第一个大类id
const [secondCategoryId, setSecondCategoryId] = useState('') const [secondCategoryId, setSecondCategoryId] = useState('')
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [finished, setFinished] = useState(false) const [finished, setFinished] = useState(false)
const [switchFlag, setSwitchFlag] = useState(false) const [switchFlag, setSwitchFlag] = useState(false)
/** /**
* 获取大类分类 * 获取大类分类
*/ */
@@ -34,7 +32,7 @@ const QuestionBank = () => {
}) })
.then((res: Record<string, any>) => { .then((res: Record<string, any>) => {
if (res.data && res.data.length > 0) { if (res.data && res.data.length > 0) {
setPromaryCategoryId(res.data[0].id); setPromaryCategoryId(res.data[0].id)
setFirstCategoryList(res.data) setFirstCategoryList(res.data)
} }
}) })
@@ -53,8 +51,7 @@ const QuestionBank = () => {
setQuestionList([]) setQuestionList([])
setTotal(0) setTotal(0)
setPageIndex(1) setPageIndex(1)
}; }
/** /**
* 选择标签时,请求列表数据 * 选择标签时,请求列表数据
@@ -67,7 +64,7 @@ const QuestionBank = () => {
setQuestionList([]) setQuestionList([])
setTotal(0) setTotal(0)
setPageIndex(1) setPageIndex(1)
}; }
const queryQuestionList = () => { const queryQuestionList = () => {
setLoading(true) setLoading(true)
@@ -82,14 +79,15 @@ const QuestionBank = () => {
method: 'post', method: 'post',
url: apiName.getSubjectPage, url: apiName.getSubjectPage,
data: params data: params
}).then(res => { })
.then(res => {
setLoading(false) setLoading(false)
let lastList = [...questionList] let lastList = [...questionList]
const { total, result } = res.data const { total = 0, result } = res.data
setTotal(total)
if (result.length) { if (result.length) {
lastList = lastList.concat(result) lastList = lastList.concat(result)
setQuestionList(lastList) setQuestionList(lastList)
setTotal(total)
if (result.length < 20 || lastList.length >= total) { if (result.length < 20 || lastList.length >= total) {
setFinished(true) setFinished(true)
} else { } else {
@@ -97,9 +95,11 @@ const QuestionBank = () => {
setSwitchFlag(false) setSwitchFlag(false)
} }
} }
}).catch(err => { })
.catch(err => {
console.log(err) console.log(err)
}).finally(() => { })
.finally(() => {
setLoading(false) setLoading(false)
}) })
} }
@@ -130,11 +130,11 @@ const QuestionBank = () => {
} }
const scrollHandler = e => { const scrollHandler = e => {
let scrollTop = e.target.scrollTop; // listBox 滚动条向上卷曲出去的长度,随滚动变化 let scrollTop = e.target.scrollTop // listBox 滚动条向上卷曲出去的长度,随滚动变化
let clientHeight = e.target.clientHeight; // listBox 的视口可见高度,固定不变 let clientHeight = e.target.clientHeight // listBox 的视口可见高度,固定不变
let scrollHeight = e.target.scrollHeight; // listBox 的整体高度,随数据加载变化 let scrollHeight = e.target.scrollHeight // listBox 的整体高度,随数据加载变化
let saveHeight = 30; // 安全距离距离底部XX时触发加载 let saveHeight = 30 // 安全距离距离底部XX时触发加载
let tempVal = scrollTop + clientHeight + saveHeight; let tempVal = scrollTop + clientHeight + saveHeight
// 如果不加入 saveHeight 安全距离,在 scrollTop + clientHeight == scrollHeight 时,触发加载 // 如果不加入 saveHeight 安全距离,在 scrollTop + clientHeight == scrollHeight 时,触发加载
// 加入安全距离,相当于在 scrollTop + clientHeight >= scrollHeight - 30 时,触发加载,比前者更早触发 // 加入安全距离,相当于在 scrollTop + clientHeight >= scrollHeight - 30 时,触发加载,比前者更早触发
if (tempVal >= scrollHeight) { if (tempVal >= scrollHeight) {
@@ -154,10 +154,10 @@ const QuestionBank = () => {
} }
return ( return (
<div className="question-bank-box"> <div className='question-bank-box'>
<div className='mask-box' onScroll={scrollHandler}> <div className='mask-box' onScroll={scrollHandler}>
<div className="question-box" > <div className='question-box'>
<div className="category-list-box"> <div className='category-list-box'>
{firstCategoryList?.length > 0 && ( {firstCategoryList?.length > 0 && (
<CategoryList <CategoryList
onChangeCategory={onChangeCategory} onChangeCategory={onChangeCategory}
@@ -169,7 +169,7 @@ const QuestionBank = () => {
/> />
)} )}
</div> </div>
<div className="question-list-box"> <div className='question-list-box'>
<QuestionList <QuestionList
pageIndex={pageIndex} pageIndex={pageIndex}
total={total} total={total}
@@ -179,21 +179,21 @@ const QuestionBank = () => {
/> />
</div> </div>
<div className='loading-more'>{ <div className='loading-more'>
questionList.length == 0 {questionList.length == 0
? "暂无数据" ? '暂无数据'
: loading && !finished : loading && !finished
? "努力加载中..." ? '努力加载中...'
: "我是有底线的(:" : '我是有底线的(:'}
}</div>
</div> </div>
</div> </div>
<div className="ranking-box"> </div>
<div className='ranking-box'>
<RankingList /> <RankingList />
<ContributionList /> <ContributionList />
</div> </div>
</div> </div>
); )
} }
export default memo(QuestionBank) export default memo(QuestionBank)

View File

@@ -27,16 +27,6 @@
background: #fff; background: #fff;
border: 1px solid #d4d4d4; border: 1px solid #d4d4d4;
border-radius: 4px; border-radius: 4px;
// .repeat-subject-label {
// margin-right: 4px;
// width: 20px;
// height: 20px;
// line-height: 20px;
// text-align: center;
// color: rgba(51, 51, 51, 0.8);
// border-radius: 50%;
// @include box-backgroundColor(0.3);
// }
.repeat-subject-text { .repeat-subject-text {
line-height: 22px; line-height: 22px;
font-size: 14px; font-size: 14px;

View File

@@ -19,8 +19,6 @@
border: 1px solid rgba(208, 212, 222, 1); border: 1px solid rgba(208, 212, 222, 1);
border-radius: 12px; border-radius: 12px;
&:hover { &:hover {
@include font-color(0.9);
@include box-backgroundColor(0.3);
} }
} }
.upload-left-layout-item-active { .upload-left-layout-item-active {