Commit Graph

19 Commits

Author SHA1 Message Date
21ea49f7c7 refactor(global): import alias @ 2026-03-26 15:54:42 +09:00
f7b7216ef1 fix(fav-page): switch from static cacheKey to dynamic refreshDeps
- Replace the static `cacheKey` with `refreshDeps: [headers]` in the
  query configuration.
- This ensures the cached data is automatically refreshed when the
  headers dependency changes, rather than relying on a static cache
  identifier.
2026-03-25 12:02:51 +09:00
191906192b feat(cache): remove redis caching and add force refresh mechanism
- Remove Redis-based caching logic from uidScoreStore and xcxApi.
- Add force refresh support to uidScoreRequest in GroupingPrediction component.
- Update server API /api/user/nowScores to accept force parameter.
- Always show refresh button in GroupingPrediction regardless of data state.
- Change default sort type in FavPlayersPage to SCORE_DOWN.
- Clean up unused imports from server.ts.

This change ensures user scores are always up-to-date by bypassing cache
when needed, preventing issues with stale data during manual sync operations.
2026-03-25 11:19:59 +09:00
eef4656f87 fix(page): remove unused Antd imports and protect "log in to view cloud collection" button
- Removed unused imports from Ant Design (`message as AntdMessage`, `StarFilled`, `ShopTwoTone`, `DeleteOutlined`, `UploadOutlined`) and `@ant-design/icons`.
- Removed unused `type IdTokenClaims` import from `@logto/react`.
- Updated the logic in the empty list state: the "Log in to view cloud collection" button now only displays when the user is NOT authenticated (`!isAuthenticated`). Previously, it showed even when logged in, which was misleading.

This cleans up the codebase and improves the user experience on the Favorite Players page.
2026-03-17 11:02:35 +09:00
86c3b6651b feat(fav-players): optimize un-fav API response and refactor player list UI
- Modify the DELETE /api/fav endpoint to include the player uid in the response JSON.
- Refactor FavPlayersPage to remove explicit dependency on `aud` for API calls, relying solely on `useAuthHeaders`.
- Add a dedicated "un-fav" button to player cards to allow users to unfollow individual players.
- Implement logic to distinguish between local un-fav (for unauthenticated users) and server-side un-fav (for authenticated users).
- Improve UI layout using `styled-components` and updated Ant Design components (`Typography.Title`).
- Add a link to sign in and view cloud favorites when the local list is empty.
2026-03-16 19:33:44 +09:00
f188b4eac4 refactor: centralize Logto config and improve auth flow
- Centralized Logto domain and API base URLs in `common.ts` to avoid duplication.
- Replaced deprecated `Modal.useModal` with `App.useApp().modal` for consistent Ant Design usage.
- Refactored `useAutoLogin` hook to handle token expiration checks and trigger re-authentication.
- Updated `UserCenter` and `FavPlayersPage` to use the new `autoSignIn` flow.
- Removed the `useAuthHeaders` hook as logic was consolidated into `useAutoLogin`.
- Added `AUTH_CALLBACK_URL` and `USER_CENTER_URL` constants for cleaner routing.
2026-03-16 13:38:02 +09:00
9c9b3735cb feat: migrate user fav system from session aud to Logto sub
- Update database schema to rename `UserFav` to `LogtoUserFav` with clearer field names (`logto_uid`, `kaiqiu_uid`).
- Bump `jose` dependency to v6.2.1 for improved JWT verification.
- Configure `@logto/react` to request the correct resource token for API access.
- Implement token verification on the server side using `jose` and `jwtVerify`.
- Update API routes (`/api/fav`) to extract the user ID from the verified JWT `sub` claim instead of the URL `aud` parameter.
- Refactor frontend components (`FavButton`, `FavePlayersPage`) to use `useAuthHeaders` for fetching auth headers instead of manual token claims extraction.
- Clean up unused migration and DAO functions related to the old `aud`-based logic.
2026-03-16 12:45:12 +09:00
9044073afd feat: sync favorite player state with server and improve clear confirmation
- Add `isFav` selector to `useFavPlayerStore` to determine initial button state immediately.
- Initialize `FavButton` value based on the store's `isFav` result instead of a stale local state.
- In `FavePlayersPage`, integrate Ant Design message hooks for user feedback during server sync.
  - Show "syncing" loading indicator when starting the sync process.
  - Show "synced" success notification upon completion.
- Enhance the "Clear Local Favorites" confirmation dialog:
  - Update warning text to indicate the action is irreversible.
  - Add custom button labels ("清空", "取消").
  - Make the confirm button dangerous and add a delete icon for better UX.
2026-03-11 11:51:30 +09:00
54d275796e feat: add player profile cache & manual sync button
- Cache user profile data in Redis with 10-minute expiration in XcxAPI service to reduce API overhead.
- Added a refresh/sync button on FavPlayersPage to manually trigger fetching players from the account.
- Refactored authentication logic to properly set and use ID token claims for syncing.
- Improved UX by removing automatic view switching logic that caused layout shifts, relying on state-driven rendering instead.
- Unified login redirect flow using the new `useAutoLogin` hook.
2026-03-10 11:19:30 +09:00
06665f3371 feat(FavPlayersPage): cache 2026-03-09 17:52:40 +09:00
d0aee38df8 fix: display correct local player count in FavPlayersPage dropdown
Update the label for the LOCAL filter option to reference `localList.length` instead of `list.length`, ensuring the item count displayed in the dropdown matches the actual filtered list size.

File: src/page/FavPlayersPage.tsx
- { label: `${ShowType.LOCAL}(${list.length})`, ... }
+ { label: `${ShowType.LOCAL}(${localList.length})`, ... }
2026-03-09 17:49:11 +09:00
d171e496ff refactor(page): 合并本地与远程球员收藏列表逻辑并简化组件
- 将本地列表 (localList) 和请求数据 (favListRequest.data) 的映射逻辑统一至主 list useMemo 中。
- 移除冗余的 showList useMemo,直接基于 showType 动态生成 list。
- 修正 sortType 默认分支显式返回 localList,确保排序逻辑一致性。
- 更新依赖数组并清理未使用的 isAuthenticated 相关逻辑。
- 调整空状态判断条件以匹配新的 list 结构。
2026-03-09 17:16:21 +09:00
9499de0180 feat(likes): sync local favorites and add auto-login flow
- Add Prisma code generation in Dockerfile build step.
- Implement instant state updates for favoriting players via store hooks.
- Enhance 'FavPlayersPage' with:
  - New "Sync to cloud" and "Clear local favorites" actions.
  - Updated tabs showing counts for local vs. account favorites.
  - Auto-detection of view mode based on authentication status.
- Add auto-login support in 'UserCenter' triggered by query parameter `autoSignIn=true`.
2026-03-09 16:51:57 +09:00
80aebac57a feat: implement user favorite player system with Logto sync
- Add `FavPlayerDAO` for database operations (create, read, delete, check) against `user_fav` table.
- Integrate Prisma ORM with MariaDB adapter in `src/prisma/db.ts`.
- Implement backend API routes (`/api/fav`) to handle GET, PUT, and DELETE requests for managing favorites based on user audience (aud).
- Create `FavePlayersPage` with support for:
  - Viewing local stored favorites.
  - Syncing server-side favorites via Logto authentication.
  - Visual distinction between "Local" and "Account" favorite lists using Segmented control.
  - Loading states and empty state handling with Ant Design components.
- Enhance `Logto/Callback` to redirect users back to their intended destination (e.g., `FavePlayersPage`) after authentication if a `redirect` param was stored in session storage.
- Update `UserCenter` page to include "Backup Codes" management option under account settings.
- Add necessary dependencies: `@logto/react`, `ahooks`, and update UI imports accordingly.
2026-03-09 10:16:27 +09:00
c26bb93ffa refactor(profile): replace Descriptions with Flex layout and show rank
- remove unused antd imports (Space, Descriptions)
- refactor equipment section to Flex-based rows
- refactor profile meta fields to structured Flex rows
- add rank display next to name and score
2026-02-18 00:45:12 +09:00
60a8bf68d1 fix(User): replace Link with useHref for external profile navigation
- Updated avatar image styling on FavePlayersPage
- Changed default sort type to '注册时间'
- Improved title rendering and structure on EventPage
- Added favUser logic and effect in ProfilePage
2026-02-12 01:12:50 +09:00
59cf101c26 fix(FavPlayersPage): img height 2026-02-11 16:08:26 +09:00
f5f68496c1 fix(FavePlayersPage): add objectFit: 'cover' to avatar image
Added `objectFit: 'cover'` to ensure avatars are displayed consistently.
2026-02-11 16:05:32 +09:00
3b87230173 feat: add favorite player functionality and improve navigation
- components: add FavButton for player favoriting
- store: create useFavPlayerStore for managing favorites
- pages: add FavePlayersPage for displaying favorites
- components: add MenuButtons for navigation controls
- ui: update App and ProfilePage for new features
- meta: update index.html title to "我的开球网"
2026-02-11 16:00:01 +09:00