my-kaiqiuwang/src/page/Logto/Callback.tsx
kyuuseiryuu 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

34 lines
954 B
TypeScript

import { useHandleSignInCallback } from '@logto/react';
import { Spin } from 'antd';
import { useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router';
export const CallbackPage = () => {
const { isLoading, isAuthenticated, error } = useHandleSignInCallback(() => {
// Navigate to root path when finished
});
const navigate = useNavigate();
const location = useLocation();
useEffect(() => {
if (isAuthenticated) {
console.debug({ isLoading, isAuthenticated, error });
const redirect = sessionStorage.getItem('redirect');
if (redirect) {
navigate(redirect);
sessionStorage.removeItem('redirect');
} else {
navigate('/user-center');
}
}
}, [isAuthenticated]);
// When it's working in progress
if (isLoading) {
return (
<Spin spinning>
<div style={{ height: '100vh', width: '100vw' }} />
</Spin>
);
}
return null;
};