|
|
@@ -2,21 +2,22 @@ import React, { useRef, useState, useCallback, useEffect } from 'react';
|
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
import { StockChart, MemoToggle, TradePanel, useTradeRecords, useStockQueries, useProfitCalculator, ProfitDisplay, useStockDataFilter, DrawingToolbar } from './components/stock-chart/mod.ts';
|
|
|
import type { StockChartRef } from './components/stock-chart/mod.ts';
|
|
|
-import { useSocketRoom, useQuestionManagement } from './hooks/useSocketClient.ts';
|
|
|
+// import { useSocketRoom, useQuestionManagement } from './hooks/useSocketClient.ts';
|
|
|
import { useSearchParams } from 'react-router';
|
|
|
-import { message } from 'antd';
|
|
|
+// import { message } from 'antd';
|
|
|
+import { ActiveType } from "./components/stock-chart/src/types/index.ts";
|
|
|
|
|
|
const queryClient = new QueryClient();
|
|
|
|
|
|
function StockApp() {
|
|
|
const chartRef = useRef<StockChartRef>(null);
|
|
|
- const lastSentDateRef = useRef('');
|
|
|
+// const lastSentDateRef = useRef('');
|
|
|
const [searchParams] = useSearchParams();
|
|
|
const codeFromUrl = searchParams.get('code');
|
|
|
- const [stockCode, setStockCode] = useState(codeFromUrl);// || '001339'
|
|
|
- const classroom = searchParams.get('classroom');
|
|
|
- const { connected } = useSocketRoom(classroom);
|
|
|
- const { sendNextQuestion } = useQuestionManagement(classroom);
|
|
|
+ const [stockCode, setStockCode] = useState(codeFromUrl || undefined);// || '001339'
|
|
|
+// const classroom = searchParams.get('classroom');
|
|
|
+// const { connected } = useSocketRoom(classroom);
|
|
|
+// const { sendNextQuestion } = useQuestionManagement(classroom);
|
|
|
|
|
|
const {
|
|
|
stockData: fullStockData,
|
|
|
@@ -48,36 +49,36 @@ function StockApp() {
|
|
|
}
|
|
|
}, [moveToNextDay, updateCurrentDate]);
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- const currentDate = profitSummary.dailyStats.date;
|
|
|
- if (classroom && connected && currentDate && lastSentDateRef.current !== currentDate) {
|
|
|
- lastSentDateRef.current = currentDate;
|
|
|
- sendNextQuestion({
|
|
|
- date: currentDate,
|
|
|
- price: profitSummary.dailyStats.close
|
|
|
- }).catch(() => {
|
|
|
- message.error('发送题目失败');
|
|
|
- });
|
|
|
- }
|
|
|
- }, [classroom, connected, profitSummary.dailyStats, sendNextQuestion]);
|
|
|
+// useEffect(() => {
|
|
|
+// const currentDate = profitSummary.dailyStats.date;
|
|
|
+// if (classroom && connected && currentDate && lastSentDateRef.current !== currentDate) {
|
|
|
+// lastSentDateRef.current = currentDate;
|
|
|
+// sendNextQuestion({
|
|
|
+// date: currentDate,
|
|
|
+// price: profitSummary.dailyStats.close
|
|
|
+// }).catch(() => {
|
|
|
+// message.error('发送题目失败');
|
|
|
+// });
|
|
|
+// }
|
|
|
+// }, [classroom, connected, profitSummary.dailyStats, sendNextQuestion]);
|
|
|
|
|
|
const handleDayNumChange = useCallback((days: number) => {
|
|
|
if (!isInitialized) {
|
|
|
- initializeView(days);
|
|
|
+ initializeView();
|
|
|
} else {
|
|
|
- setDayNum(days, days);
|
|
|
+ setDayNum(days);
|
|
|
}
|
|
|
}, [isInitialized, initializeView, setDayNum]);
|
|
|
|
|
|
const handleQuery = useCallback(() => {
|
|
|
- if (stockCode.trim()) {
|
|
|
+ if (stockCode && stockCode.trim()) {
|
|
|
fetchData().then(() => {
|
|
|
- initializeView(120);
|
|
|
+ initializeView();
|
|
|
});
|
|
|
}
|
|
|
}, [stockCode, fetchData, initializeView]);
|
|
|
|
|
|
- const handleStartDrawing = useCallback((type: 'horizontal' | 'trend') => {
|
|
|
+ const handleStartDrawing = useCallback((type: ActiveType) => {
|
|
|
chartRef.current?.startDrawing(type);
|
|
|
}, []);
|
|
|
|
|
|
@@ -112,7 +113,7 @@ function StockApp() {
|
|
|
if (codeFromUrl && codeFromUrl !== stockCode) {
|
|
|
setStockCode(codeFromUrl);
|
|
|
fetchData().then(() => {
|
|
|
- initializeView(120);
|
|
|
+ initializeView();
|
|
|
});
|
|
|
}
|
|
|
}, [codeFromUrl, stockCode, fetchData, initializeView]);
|