feat: 修改更新依赖
This commit is contained in:
@@ -63,11 +63,11 @@ function StockDetailPanel({ visible, event, onClose }) {
|
|||||||
refreshQuotes
|
refreshQuotes
|
||||||
} = useEventStocks(event?.id, event?.start_time);
|
} = useEventStocks(event?.id, event?.start_time);
|
||||||
|
|
||||||
// 自选股管理
|
// 自选股管理(只在 Drawer 可见时加载)
|
||||||
const {
|
const {
|
||||||
watchlistSet,
|
watchlistSet,
|
||||||
toggleWatchlist
|
toggleWatchlist
|
||||||
} = useWatchlist();
|
} = useWatchlist(visible);
|
||||||
|
|
||||||
// 实时监控管理
|
// 实时监控管理
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ import { logger } from '../../../../../utils/logger';
|
|||||||
* 自选股管理 Hook
|
* 自选股管理 Hook
|
||||||
* 封装自选股的加载、添加、移除逻辑
|
* 封装自选股的加载、添加、移除逻辑
|
||||||
*
|
*
|
||||||
|
* @param {boolean} shouldLoad - 是否立即加载自选股列表(默认 true)
|
||||||
* @returns {Object} 自选股数据和操作方法
|
* @returns {Object} 自选股数据和操作方法
|
||||||
*/
|
*/
|
||||||
export const useWatchlist = () => {
|
export const useWatchlist = (shouldLoad = true) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
// 从 Redux 获取自选股列表
|
// 从 Redux 获取自选股列表
|
||||||
@@ -23,10 +24,13 @@ export const useWatchlist = () => {
|
|||||||
return new Set(watchlistArray);
|
return new Set(watchlistArray);
|
||||||
}, [watchlistArray]);
|
}, [watchlistArray]);
|
||||||
|
|
||||||
// 初始化时加载自选股列表
|
// 初始化时加载自选股列表(只在 shouldLoad 为 true 时)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (shouldLoad) {
|
||||||
|
logger.debug('useWatchlist', '条件加载自选股列表', { shouldLoad });
|
||||||
dispatch(loadWatchlist());
|
dispatch(loadWatchlist());
|
||||||
}, [dispatch]);
|
}
|
||||||
|
}, [dispatch, shouldLoad]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查股票是否在自选股中
|
* 检查股票是否在自选股中
|
||||||
|
|||||||
Reference in New Issue
Block a user