Prevent my-traders API calls when user is not logged in

- Add authentication checks to SWR calls in App.tsx and AITradersPage.tsx
- Only call api.getTraders when user and token are available
- Modify loadConfigs to skip authenticated API calls when not logged in
- Load only public supported models/exchanges for unauthenticated users
- Update useEffect dependencies to include user and token
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
icy
2025-11-03 23:14:10 +08:00
parent 804bb4c302
commit 41b57ce834
2 changed files with 27 additions and 6 deletions
+8 -4
View File
@@ -88,10 +88,14 @@ function App() {
// window.location.hash = page === 'competition' ? '' : 'trader';
// };
// 获取trader列表
const { data: traders } = useSWR<TraderInfo[]>('traders', api.getTraders, {
refreshInterval: 10000,
});
// 获取trader列表(仅在用户登录时)
const { data: traders } = useSWR<TraderInfo[]>(
user && token ? 'traders' : null,
api.getTraders,
{
refreshInterval: 10000,
}
);
// 当获取到traders后,设置默认选中第一个
useEffect(() => {