From 41e5f27d4de05ef4c02429c989842e86a35ce8a0 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Tue, 24 Jun 2025 11:44:03 +0800 Subject: [PATCH] layout: view menu now has a maximum width, closes #1459 (#1463) * refactor: auth callback page * layout: view menu now has a maximum width, closes #1459 --- .../src/app/auth/callback/page.tsx | 50 +++++++++---------- .../src/app/reader/components/ViewMenu.tsx | 9 +++- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/apps/readest-app/src/app/auth/callback/page.tsx b/apps/readest-app/src/app/auth/callback/page.tsx index f980ee52..2ae161da 100644 --- a/apps/readest-app/src/app/auth/callback/page.tsx +++ b/apps/readest-app/src/app/auth/callback/page.tsx @@ -1,42 +1,42 @@ 'use client'; +import { useEffect } from 'react'; import { useRouter } from 'next/navigation'; -import { handleAuthCallback } from '@/helpers/auth'; import { useAuth } from '@/context/AuthContext'; +import { handleAuthCallback } from '@/helpers/auth'; export default function AuthCallback() { const router = useRouter(); const { login } = useAuth(); - if (typeof window === 'undefined') { - return null; - } - const hash = window.location.hash || ''; - const params = new URLSearchParams(hash.slice(1)); + useEffect(() => { + const hash = window.location.hash || ''; + const params = new URLSearchParams(hash.slice(1)); - const accessToken = params.get('access_token'); - const refreshToken = params.get('refresh_token'); - const type = params.get('type'); - const next = params.get('next') ?? '/'; - const error = params.get('error'); - const errorDescription = params.get('error_description'); - const errorCode = params.get('error_code'); + const accessToken = params.get('access_token'); + const refreshToken = params.get('refresh_token'); + const type = params.get('type'); + const next = params.get('next') ?? '/'; + const error = params.get('error'); + const errorDescription = params.get('error_description'); + const errorCode = params.get('error_code'); - handleAuthCallback({ - accessToken, - refreshToken, - type, - next, - error, - errorCode, - errorDescription, - login, - navigate: router.push, - }); + handleAuthCallback({ + accessToken, + refreshToken, + type, + next, + error, + errorCode, + errorDescription, + login, + navigate: router.push, + }); + }, [login, router]); return (
- +
); } diff --git a/apps/readest-app/src/app/reader/components/ViewMenu.tsx b/apps/readest-app/src/app/reader/components/ViewMenu.tsx index 99be0325..3eccf7bf 100644 --- a/apps/readest-app/src/app/reader/components/ViewMenu.tsx +++ b/apps/readest-app/src/app/reader/components/ViewMenu.tsx @@ -107,7 +107,14 @@ const ViewMenu: React.FC = ({ return (