From ad847f1e4c25578c248afb4fcdf60ca209c6de63 Mon Sep 17 00:00:00 2001 From: charilezhou Date: Tue, 20 Jan 2026 17:32:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor(web):=20=E5=B0=86=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=9D=83=E9=99=90=E7=BC=93=E5=AD=98=E5=8A=9F=E8=83=BD=E7=A7=BB?= =?UTF-8?q?=E8=87=B3=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 PermissionSettings 组件 - 从个人中心页面移除刷新权限缓存功能 - 在系统设置页面添加权限缓存设置卡片 Co-Authored-By: Claude Opus 4.5 --- apps/web/src/app/(dashboard)/profile/page.tsx | 38 -------------- .../web/src/app/(dashboard)/settings/page.tsx | 3 +- .../settings/PermissionSettings.tsx | 51 +++++++++++++++++++ apps/web/src/components/settings/index.ts | 1 + 4 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 apps/web/src/components/settings/PermissionSettings.tsx diff --git a/apps/web/src/app/(dashboard)/profile/page.tsx b/apps/web/src/app/(dashboard)/profile/page.tsx index 00696cd..5df4d07 100644 --- a/apps/web/src/app/(dashboard)/profile/page.tsx +++ b/apps/web/src/app/(dashboard)/profile/page.tsx @@ -1,13 +1,8 @@ 'use client'; -import { RefreshCw } from 'lucide-react'; -import { useState } from 'react'; -import { toast } from 'sonner'; - import { AvatarUpload } from '@/components/forms/AvatarUpload'; import { PasswordForm } from '@/components/forms/PasswordForm'; import { ProfileForm } from '@/components/forms/ProfileForm'; -import { Button } from '@/components/ui/button'; import { Card, CardContent, @@ -15,26 +10,8 @@ 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 (
@@ -72,21 +49,6 @@ export default function ProfilePage() { - - - - 刷新权限缓存 - - 如果您的权限或菜单发生变化,可以手动刷新以获取最新数据。 - - - - - -
); diff --git a/apps/web/src/app/(dashboard)/settings/page.tsx b/apps/web/src/app/(dashboard)/settings/page.tsx index 36cecb9..bad9cd6 100644 --- a/apps/web/src/app/(dashboard)/settings/page.tsx +++ b/apps/web/src/app/(dashboard)/settings/page.tsx @@ -1,6 +1,6 @@ 'use client'; -import { ThemeSettings, SidebarSettings } from '@/components/settings'; +import { ThemeSettings, SidebarSettings, PermissionSettings } from '@/components/settings'; export default function SettingsPage() { return ( @@ -13,6 +13,7 @@ export default function SettingsPage() {
+
); diff --git a/apps/web/src/components/settings/PermissionSettings.tsx b/apps/web/src/components/settings/PermissionSettings.tsx new file mode 100644 index 0000000..ee0b1c4 --- /dev/null +++ b/apps/web/src/components/settings/PermissionSettings.tsx @@ -0,0 +1,51 @@ +'use client'; + +import { RefreshCw } from 'lucide-react'; +import { useState } from 'react'; +import { toast } from 'sonner'; + +import { Button } from '@/components/ui/button'; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from '@/components/ui/card'; +import { getUserMenusAndPermissions } from '@/services/permission.service'; +import { usePermissionStore } from '@/stores'; + +export function PermissionSettings() { + 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 ( + + + 权限缓存 + + 如果您的权限或菜单发生变化,可以手动刷新以获取最新数据。 + + + + + + + ); +} diff --git a/apps/web/src/components/settings/index.ts b/apps/web/src/components/settings/index.ts index f5df33b..6fb8f71 100644 --- a/apps/web/src/components/settings/index.ts +++ b/apps/web/src/components/settings/index.ts @@ -1,2 +1,3 @@ export { ThemeSettings } from './ThemeSettings'; export { SidebarSettings } from './SidebarSettings'; +export { PermissionSettings } from './PermissionSettings';