切换板块 tab 时强制 refetch,绕过前端/反代缓存确保数据正确
This commit is contained in:
@@ -40,6 +40,12 @@ function SectorsPage() {
|
||||
const { data = [], isLoading, isFetching, refetch } =
|
||||
tab === "industry" ? industryQ : conceptQ;
|
||||
|
||||
// 切换 tab 时强制重新请求,绕过 React Query 缓存和上游反代缓存,确保拿到对应类型的数据
|
||||
const handleTab = (t: SectorType) => {
|
||||
setTab(t);
|
||||
(t === "industry" ? industryQ : conceptQ).refetch();
|
||||
};
|
||||
|
||||
const sorted = useMemo(() => {
|
||||
const dir = asc ? 1 : -1;
|
||||
return [...data].sort((a, b) => {
|
||||
@@ -83,7 +89,7 @@ function SectorsPage() {
|
||||
{TABS.map((t) => (
|
||||
<button
|
||||
key={t.key}
|
||||
onClick={() => setTab(t.key)}
|
||||
onClick={() => handleTab(t.key)}
|
||||
className={`flex-1 py-1.5 text-sm font-medium rounded-md transition-colors ${
|
||||
tab === t.key
|
||||
? "bg-background text-foreground shadow-sm"
|
||||
|
||||
Reference in New Issue
Block a user