From 55dbe844afdc429b53e8f003ab8f1b0ec0fa8a6d Mon Sep 17 00:00:00 2001 From: charilezhou Date: Sat, 17 Jan 2026 21:43:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20=E6=B7=BB=E5=8A=A0=E5=92=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=B6=E4=BB=96=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 not-found.tsx 404 页面 - 更新 profile 页面 - LoginForm 代码优化 Co-Authored-By: Claude Opus 4.5 --- apps/web/src/app/(dashboard)/profile/page.tsx | 38 +++++++++++++++++ apps/web/src/app/not-found.tsx | 42 +++++++++++++++++++ apps/web/src/components/forms/LoginForm.tsx | 6 +-- 3 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 apps/web/src/app/not-found.tsx diff --git a/apps/web/src/app/(dashboard)/profile/page.tsx b/apps/web/src/app/(dashboard)/profile/page.tsx index 9028214..1a88fb6 100644 --- a/apps/web/src/app/(dashboard)/profile/page.tsx +++ b/apps/web/src/app/(dashboard)/profile/page.tsx @@ -1,7 +1,12 @@ 'use client'; +import { RefreshCw } from 'lucide-react'; +import { useState } from 'react'; +import { toast } from 'sonner'; + import { PasswordForm } from '@/components/forms/PasswordForm'; import { ProfileForm } from '@/components/forms/ProfileForm'; +import { Button } from '@/components/ui/button'; import { Card, CardContent, @@ -9,8 +14,26 @@ import { CardHeader, CardTitle, } from '@/components/ui/card'; +import { getUserMenusAndPermissions } from '@/services/permission.service'; +import { usePermissionStore } from '@/stores'; export default function ProfilePage() { + const [isRefreshing, setIsRefreshing] = useState(false); + const setPermissionData = usePermissionStore((state) => state.setPermissionData); + + const handleRefreshPermissions = async () => { + setIsRefreshing(true); + try { + const data = await getUserMenusAndPermissions(); + setPermissionData(data); + toast.success('权限缓存已刷新'); + } catch (error) { + toast.error(error instanceof Error ? error.message : '刷新失败'); + } finally { + setIsRefreshing(false); + } + }; + return (
@@ -38,6 +61,21 @@ export default function ProfilePage() { + + + + 刷新权限缓存 + + 如果您的权限或菜单发生变化,可以手动刷新以获取最新数据。 + + + + + +
); diff --git a/apps/web/src/app/not-found.tsx b/apps/web/src/app/not-found.tsx new file mode 100644 index 0000000..a237ad7 --- /dev/null +++ b/apps/web/src/app/not-found.tsx @@ -0,0 +1,42 @@ +'use client'; + +import { FileQuestion } from 'lucide-react'; +import Link from 'next/link'; +import { useRouter } from 'next/navigation'; + +import { Button } from '@/components/ui/button'; + +export default function NotFoundPage() { + const router = useRouter(); + + return ( +
+
+
+
+ +
+
+ +
+

404

+

+ 页面未找到 +

+

+ 抱歉,您访问的页面不存在。可能已被删除或输入了错误的地址。 +

+
+ +
+ + +
+
+
+ ); +} diff --git a/apps/web/src/components/forms/LoginForm.tsx b/apps/web/src/components/forms/LoginForm.tsx index 59dbbe7..b0e5562 100644 --- a/apps/web/src/components/forms/LoginForm.tsx +++ b/apps/web/src/components/forms/LoginForm.tsx @@ -3,7 +3,6 @@ import { zodResolver } from '@hookform/resolvers/zod'; import { CaptchaScene } from '@seclusion/shared'; import { Loader2 } from 'lucide-react'; -import { useRouter, useSearchParams } from 'next/navigation'; import { useState } from 'react'; import { useForm } from 'react-hook-form'; import { toast } from 'sonner'; @@ -25,9 +24,6 @@ import { useAuthStore } from '@/stores'; export function LoginForm() { - const router = useRouter(); - const searchParams = useSearchParams(); - const redirectUri = searchParams.get('redirect') || '/dashboard'; const { setAuth } = useAuthStore(); const [isLoading, setIsLoading] = useState(false); @@ -59,7 +55,7 @@ export function LoginForm() { response.refreshTokenExpiresIn ); toast.success('登录成功'); - router.push(redirectUri); + // 登录成功后,AuthRedirect 组件会自动处理重定向(包括权限检查) } catch (error) { toast.error(error instanceof Error ? error.message : '登录失败'); // 刷新验证码