- stockSlice: 新增 loadAllStocks action(带缓存检查)
- stockSlice: watchlist 结构升级为 { stock_code, stock_name }[]
- store/hooks.ts: 新增 useAppDispatch, useAppSelector 类型化 hooks
- stockService: 移除 getAllStocks(已迁移到 Redux)
- mock: 股票搜索支持模糊匹配 + 相关性排序
16 lines
530 B
TypeScript
16 lines
530 B
TypeScript
/**
|
|
* Redux Typed Hooks
|
|
* 提供类型安全的 useDispatch 和 useSelector hooks
|
|
*/
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
import type { TypedUseSelectorHook } from 'react-redux';
|
|
import { store } from './index';
|
|
|
|
// 从 store 推断类型
|
|
export type RootState = ReturnType<typeof store.getState>;
|
|
export type AppDispatch = typeof store.dispatch;
|
|
|
|
// 类型化的 hooks
|
|
export const useAppDispatch: () => AppDispatch = useDispatch;
|
|
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|