|
@@ -1,14 +1,19 @@
|
|
|
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
|
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
|
|
|
|
+import { createRoot } from 'react-dom/client';
|
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
|
|
+// import { useSocketRoom, useQuestionManagement } from './hooks/useSocketClient.ts';
|
|
|
|
|
+import { RouterProvider, createBrowserRouter, useSearchParams } from 'react-router';
|
|
|
|
|
+import { ToastContainer , toast} from 'react-toastify';
|
|
|
import { StockChart, MemoToggle, TradePanel, useTradeRecords, useStockQueries, useProfitCalculator, ProfitDisplay, useStockDataFilter, DrawingToolbar } from './components/stock-chart/mod.ts';
|
|
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 type { StockChartRef } from './components/stock-chart/mod.ts';
|
|
|
-// import { useSocketRoom, useQuestionManagement } from './hooks/useSocketClient.ts';
|
|
|
|
|
-import { useSearchParams } from 'react-router';
|
|
|
|
|
-// import { message } from 'antd';
|
|
|
|
|
import { ActiveType } from "./components/stock-chart/src/types/index.ts";
|
|
import { ActiveType } from "./components/stock-chart/src/types/index.ts";
|
|
|
|
|
|
|
|
const queryClient = new QueryClient();
|
|
const queryClient = new QueryClient();
|
|
|
|
|
|
|
|
|
|
+const showToast = (type: 'info' | 'success' | 'error', message: string): void => {
|
|
|
|
|
+ toast[type](message);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
function StockApp() {
|
|
function StockApp() {
|
|
|
const chartRef = useRef<StockChartRef>(null);
|
|
const chartRef = useRef<StockChartRef>(null);
|
|
|
// const lastSentDateRef = useRef('');
|
|
// const lastSentDateRef = useRef('');
|
|
@@ -71,6 +76,10 @@ function StockApp() {
|
|
|
}, [isInitialized, initializeView, setDayNum]);
|
|
}, [isInitialized, initializeView, setDayNum]);
|
|
|
|
|
|
|
|
const handleQuery = useCallback(() => {
|
|
const handleQuery = useCallback(() => {
|
|
|
|
|
+ if(!stockCode){
|
|
|
|
|
+ showToast('error', '请先输入股票代码');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (stockCode && stockCode.trim()) {
|
|
if (stockCode && stockCode.trim()) {
|
|
|
fetchData().then(() => {
|
|
fetchData().then(() => {
|
|
|
initializeView();
|
|
initializeView();
|
|
@@ -234,10 +243,29 @@ function StockApp() {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export default function App() {
|
|
|
|
|
- return (
|
|
|
|
|
- <QueryClientProvider client={queryClient}>
|
|
|
|
|
- <StockApp />
|
|
|
|
|
- </QueryClientProvider>
|
|
|
|
|
- );
|
|
|
|
|
-}
|
|
|
|
|
|
|
+
|
|
|
|
|
+const router = createBrowserRouter([
|
|
|
|
|
+ {
|
|
|
|
|
+ path: '*',
|
|
|
|
|
+ element: <StockApp />,
|
|
|
|
|
+ },
|
|
|
|
|
+]);
|
|
|
|
|
+
|
|
|
|
|
+// 渲染应用
|
|
|
|
|
+const root = createRoot(document.getElementById('root') as HTMLElement);
|
|
|
|
|
+root.render(
|
|
|
|
|
+ <QueryClientProvider client={queryClient}>
|
|
|
|
|
+ <RouterProvider router={router} />
|
|
|
|
|
+ <ToastContainer
|
|
|
|
|
+ position="top-right"
|
|
|
|
|
+ autoClose={500}
|
|
|
|
|
+ hideProgressBar={false}
|
|
|
|
|
+ newestOnTop={false}
|
|
|
|
|
+ closeOnClick
|
|
|
|
|
+ rtl={false}
|
|
|
|
|
+ pauseOnFocusLoss
|
|
|
|
|
+ draggable
|
|
|
|
|
+ pauseOnHover
|
|
|
|
|
+ />
|
|
|
|
|
+ </QueryClientProvider>
|
|
|
|
|
+);
|