feat: StockListItem.js - 分时/K线点击切换效果修复
This commit is contained in:
@@ -14,11 +14,12 @@ const StockChartModal = ({
|
|||||||
stock,
|
stock,
|
||||||
eventTime,
|
eventTime,
|
||||||
isChakraUI = true, // 是否使用Chakra UI,默认true;如果false则使用Antd
|
isChakraUI = true, // 是否使用Chakra UI,默认true;如果false则使用Antd
|
||||||
size = "6xl"
|
size = "6xl",
|
||||||
|
initialChartType = 'timeline' // 初始图表类型(timeline/daily)
|
||||||
}) => {
|
}) => {
|
||||||
const chartRef = useRef(null);
|
const chartRef = useRef(null);
|
||||||
const chartInstanceRef = useRef(null);
|
const chartInstanceRef = useRef(null);
|
||||||
const [chartType, setChartType] = useState('timeline');
|
const [chartType, setChartType] = useState(initialChartType);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [chartData, setChartData] = useState(null);
|
const [chartData, setChartData] = useState(null);
|
||||||
const [preloadedData, setPreloadedData] = useState({});
|
const [preloadedData, setPreloadedData] = useState({});
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ const StockListItem = ({
|
|||||||
|
|
||||||
const [isDescExpanded, setIsDescExpanded] = useState(false);
|
const [isDescExpanded, setIsDescExpanded] = useState(false);
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
|
const [modalChartType, setModalChartType] = useState('timeline'); // 跟踪用户点击的图表类型
|
||||||
|
|
||||||
const handleViewDetail = () => {
|
const handleViewDetail = () => {
|
||||||
const stockCode = stock.stock_code.split('.')[0];
|
const stockCode = stock.stock_code.split('.')[0];
|
||||||
@@ -203,6 +204,7 @@ const StockListItem = ({
|
|||||||
bg="rgba(59, 130, 246, 0.1)"
|
bg="rgba(59, 130, 246, 0.1)"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
setModalChartType('timeline'); // 设置为分时图
|
||||||
setIsModalOpen(true);
|
setIsModalOpen(true);
|
||||||
}}
|
}}
|
||||||
cursor="pointer"
|
cursor="pointer"
|
||||||
@@ -245,6 +247,7 @@ const StockListItem = ({
|
|||||||
bg="rgba(168, 85, 247, 0.1)"
|
bg="rgba(168, 85, 247, 0.1)"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
setModalChartType('daily'); // 设置为日K线
|
||||||
setIsModalOpen(true);
|
setIsModalOpen(true);
|
||||||
}}
|
}}
|
||||||
cursor="pointer"
|
cursor="pointer"
|
||||||
@@ -385,6 +388,7 @@ const StockListItem = ({
|
|||||||
stock={stock}
|
stock={stock}
|
||||||
eventTime={eventTime}
|
eventTime={eventTime}
|
||||||
size="6xl"
|
size="6xl"
|
||||||
|
initialChartType={modalChartType} // 传递用户点击的图表类型
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user