提交 6737d2b7 authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 5ff64b0f
...@@ -7,7 +7,7 @@ import EditorSimple from '@/common/editor-simple' ...@@ -7,7 +7,7 @@ import EditorSimple from '@/common/editor-simple'
import './index.less' import './index.less'
import { addExpandRead, expandReadInfo } from '../utils/request' import { addExpandRead, expandReadInfo } from '../utils/request'
const ExpandModal = forwardRef((props, ref) => { const ExpandModal = (props, ref) => {
const { const {
editor, editor,
ossClient, ossClient,
...@@ -361,6 +361,6 @@ const ExpandModal = forwardRef((props, ref) => { ...@@ -361,6 +361,6 @@ const ExpandModal = forwardRef((props, ref) => {
</div> </div>
</div> </div>
) )
}) }
export default ExpandModal export default forwardRef(ExpandModal)
import React, { useState, forwardRef, useImperativeHandle, useRef } from 'react'; import React, { useState, forwardRef, useImperativeHandle, useRef } from 'react'
import { Input, InputNumber } from 'antd'; import { Input, InputNumber } from 'antd'
import '../index.less'; import '../index.less'
const PaddingSpace = forwardRef((props, ref) => { const PaddingSpace = (props, ref) => {
const { editorNodes, editor } = props; const { editorNodes, editor } = props
const [inputValue1, setInputValue1] = useState(''); const [inputValue1, setInputValue1] = useState('')
const [inputValue2, setInputValue2] = useState(''); const [inputValue2, setInputValue2] = useState('')
const [inputValue3, setInputValue3] = useState(''); const [inputValue3, setInputValue3] = useState('')
const timeDebonceRef = useRef(); const timeDebonceRef = useRef()
const InpoutValueChange1 = (value) => { const InpoutValueChange1 = value => {
setInputValue1(value); setInputValue1(value)
changeIt(); changeIt()
}; }
const InpoutValueChange2 = (value) => { const InpoutValueChange2 = value => {
setInputValue2(value); setInputValue2(value)
}; }
const InpoutValueChange3 = (value) => { const InpoutValueChange3 = value => {
setInputValue3(value); setInputValue3(value)
}; }
const changeIt = () => { const changeIt = () => {
clearTimeout(timeDebonceRef.current); clearTimeout(timeDebonceRef.current)
timeDebonceRef.current = setTimeout(() => { timeDebonceRef.current = setTimeout(() => {}, 500)
}, 500);
if (editorNodes) { if (editorNodes) {
} else { } else {
} }
} }
...@@ -37,49 +33,34 @@ const PaddingSpace = forwardRef((props, ref) => { ...@@ -37,49 +33,34 @@ const PaddingSpace = forwardRef((props, ref) => {
return { return {
inputValue1, inputValue1,
inputValue2, inputValue2,
inputValue3, inputValue3
}; }
}); })
return ( return (
<div className='custom-bar-box-input'> <div className="custom-bar-box-input">
<div className='box'> <div className="box">
<div className='customer-box-input-item'> <div className="customer-box-input-item">
<p> <p>
<InputNumber <InputNumber controls={false} id="padding_1" value={inputValue1} onChange={InpoutValueChange1} />
controls={false}
id='padding_1'
value={inputValue1}
onChange={InpoutValueChange1}
/>
</p> </p>
<p className='text'>段前间距</p> <p className="text">段前间距</p>
</div> </div>
<div className='customer-box-input-item'> <div className="customer-box-input-item">
<p> <p>
<InputNumber <InputNumber controls={false} id="padding_2" value={inputValue2} onChange={InpoutValueChange2} />
controls={false}
id='padding_2'
value={inputValue2}
onChange={InpoutValueChange2}
/>
</p> </p>
<p className='text'>段后间距</p> <p className="text">段后间距</p>
</div> </div>
<div className='customer-box-input-item'> <div className="customer-box-input-item">
<p> <p>
<InputNumber <InputNumber controls={false} id="padding_3" value={inputValue3} onChange={InpoutValueChange3} />
controls={false}
id='padding_3'
value={inputValue3}
onChange={InpoutValueChange3}
/>
</p> </p>
<p className='text'>行距</p> <p className="text">行距</p>
</div> </div>
</div> </div>
</div> </div>
); )
}); }
export default PaddingSpace; export default forwardRef(PaddingSpace)
import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react'; import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react'
import { Input } from 'antd'; import { Input } from 'antd'
const inCorrect = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; const inCorrect = [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z'
]
const TopicItem = forwardRef((props, ref) => { const TopicItem = (props, ref) => {
const { topic, index, preview = false } = props; const { topic, index, preview = false } = props
const [recordInfo, setRecordInfo] = useState({}); const [recordInfo, setRecordInfo] = useState({})
const [choose, setChoose] = useState(false); const [choose, setChoose] = useState(false)
const [chooseAnswer, setChooseAnswer] = useState([]); const [chooseAnswer, setChooseAnswer] = useState([])
const [isMap, setIsMap] = useState(false); const [isMap, setIsMap] = useState(false)
useEffect(() => { useEffect(() => {
if (Object.entries(topic).length) { if (Object.entries(topic).length) {
let temp = {}; let temp = {}
for (const key in topic) { for (const key in topic) {
if (key === 'question_list') { if (key === 'question_list') {
try { try {
temp[key] = JSON.parse(topic[key]); temp[key] = JSON.parse(topic[key])
} catch (e) { } catch (e) {
temp[key] = topic[key]; temp[key] = topic[key]
} }
} else { } else {
temp[key] = topic[key]; temp[key] = topic[key]
} }
} }
if (temp.question_style === 1 || temp.question_style === 2 || temp.question_style === 3) { if (temp.question_style === 1 || temp.question_style === 2 || temp.question_style === 3) {
setChoose(true); setChoose(true)
} }
if (temp.question_list instanceof Array && temp.question_list.length > 0) { if (temp.question_list instanceof Array && temp.question_list.length > 0) {
setIsMap(true); setIsMap(true)
let an = []; let an = []
temp.question_list.forEach((item, index) => { temp.question_list.forEach((item, index) => {
if (item.correct && (item.correct === 'true' || item.correct === true)) { if (item.correct && (item.correct === 'true' || item.correct === true)) {
an.push(inCorrect[index]); an.push(inCorrect[index])
} }
}); })
setChooseAnswer(an); setChooseAnswer(an)
} }
setRecordInfo(temp); setRecordInfo(temp)
} }
}, [topic]); }, [topic])
useImperativeHandle(ref, () => { useImperativeHandle(ref, () => {
return {}; return {}
}); })
return ( return (
<div className='topic-item-info'> <div className="topic-item-info">
{Object.entries(recordInfo).length && ( {Object.entries(recordInfo).length && (
<> <>
<div className='index'>{index}.</div> <div className="index">{index}.</div>
<div className='topic'> <div className="topic">
{/* <div>{recordInfo.titles}</div> */} {/* <div>{recordInfo.titles}</div> */}
<div <div className="topic-choose-title" dangerouslySetInnerHTML={{ __html: recordInfo.titles }}></div>
className='topic-choose-title'
dangerouslySetInnerHTML={{ __html: recordInfo.titles }}
></div>
{[1, 2, 3].includes(parseInt(recordInfo.question_style)) && ( {[1, 2, 3].includes(parseInt(recordInfo.question_style)) && (
<div className='topic-choose'> <div className="topic-choose">
{choose && {choose &&
isMap && isMap &&
recordInfo && recordInfo &&
...@@ -67,28 +91,27 @@ const TopicItem = forwardRef((props, ref) => { ...@@ -67,28 +91,27 @@ const TopicItem = forwardRef((props, ref) => {
recordInfo.question_list.map((item, cindex) => { recordInfo.question_list.map((item, cindex) => {
return ( return (
<div <div
className='topic-choose-item' className="topic-choose-item"
key={cindex} key={cindex}
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: `${inCorrect[cindex]}. ` + item.option, __html: `${inCorrect[cindex]}. ` + item.option
}} }}></div>
></div> )
);
})} })}
</div> </div>
)} )}
{preview && ( {preview && (
<div className='notes-preivew'> <div className="notes-preivew">
{recordInfo.question_style === 5 && ( {recordInfo.question_style === 5 && (
<div className='textarea'> <div className="textarea">
<Input.TextArea autoSize={{ minRows: 3, maxRows: 4 }} /> <Input.TextArea autoSize={{ minRows: 3, maxRows: 4 }} />
</div> </div>
)} )}
</div> </div>
)} )}
<div className='answer'> <div className="answer">
<strong>答案: </strong> <strong>答案: </strong>
{[1, 2, 3].includes(recordInfo.question_style) ? ( {[1, 2, 3].includes(recordInfo.question_style) ? (
<span>{chooseAnswer.join(' ')}</span> <span>{chooseAnswer.join(' ')}</span>
...@@ -100,7 +123,7 @@ const TopicItem = forwardRef((props, ref) => { ...@@ -100,7 +123,7 @@ const TopicItem = forwardRef((props, ref) => {
</> </>
)} )}
</div> </div>
); )
}); }
export default TopicItem; export default forwardRef(TopicItem)
...@@ -16,7 +16,7 @@ import { bookNameList } from './request' ...@@ -16,7 +16,7 @@ import { bookNameList } from './request'
import '../utils/iconfont' import '../utils/iconfont'
import './index.less' import './index.less'
const PracticeSettingModal = forwardRef((props, ref) => { const PracticeSettingModal = (props, ref) => {
const { editor, chapterId, bookId, closePanel } = props const { editor, chapterId, bookId, closePanel } = props
const dispatch = useDispatch() const dispatch = useDispatch()
const { practiceRandom, practiceTitle, practiceTheme } = useSelector(state => state.editor) const { practiceRandom, practiceTitle, practiceTheme } = useSelector(state => state.editor)
...@@ -248,6 +248,6 @@ const PracticeSettingModal = forwardRef((props, ref) => { ...@@ -248,6 +248,6 @@ const PracticeSettingModal = forwardRef((props, ref) => {
</Row> </Row>
</div> </div>
) )
}) }
export default PracticeSettingModal export default forwardRef(PracticeSettingModal)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论