|
|
@@ -23,6 +23,7 @@ export default function ExamCard() {
|
|
|
} = useSocketClient(classroom as string);
|
|
|
const [currentDate, setCurrentDate] = useState('');
|
|
|
const [currentPrice, setCurrentPrice] = useState('0');
|
|
|
+ const [dailyGain, setDailyGain] = useState(0);
|
|
|
const [holdingStock, setHoldingStock] = useState('0');
|
|
|
const [holdingCash, setHoldingCash] = useState('0');
|
|
|
const [isStarted, setIsStarted] = useState(false);
|
|
|
@@ -67,6 +68,7 @@ export default function ExamCard() {
|
|
|
if (question) {
|
|
|
setCurrentDate(question.date);
|
|
|
setCurrentPrice(String(question.price));
|
|
|
+ setDailyGain(question.gain || 0);
|
|
|
setIsStarted(true);
|
|
|
}
|
|
|
|
|
|
@@ -225,6 +227,7 @@ export default function ExamCard() {
|
|
|
const handleQuestionUpdate = (question:QuizState ) => {
|
|
|
setCurrentDate(question.date);
|
|
|
setCurrentPrice(String(question.price));
|
|
|
+ setDailyGain(question.gain || 0);
|
|
|
setIsStarted(true);
|
|
|
};
|
|
|
|
|
|
@@ -241,6 +244,7 @@ export default function ExamCard() {
|
|
|
const handleCleaned = () => {
|
|
|
setCurrentDate('');
|
|
|
setCurrentPrice('0');
|
|
|
+ setDailyGain(0);
|
|
|
setHoldingStock('0');
|
|
|
setHoldingCash('0');
|
|
|
setIsStarted(false);
|
|
|
@@ -287,6 +291,9 @@ export default function ExamCard() {
|
|
|
{isStarted ? (
|
|
|
<>
|
|
|
<span>价格: {currentPrice}</span>
|
|
|
+ <span className={dailyGain >= 0 ? 'text-red-500' : 'text-green-500'}>
|
|
|
+ 涨幅: {dailyGain > 0 ? '+' : ''}{dailyGain.toFixed(2)}%
|
|
|
+ </span>
|
|
|
</>
|
|
|
) : (
|
|
|
<div className="text-blue-600">
|