From f2fc249d04d36fde79b326e903709a24d98d55c3 Mon Sep 17 00:00:00 2001 From: gaoziman <2942894660@qq.com> Date: Thu, 6 Nov 2025 00:43:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=AF=BC=E8=88=AA):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=AF=BC=E8=88=AA=E7=BB=93=E6=9E=84=E5=92=8C=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 简化路由配置,添加用户信息路由 - 简化NavBar用户下拉菜单,仅保留个人信息和退出登录 - 更新国际化配置,添加用户管理相关翻译 - 优化Settings主题色配置模块 --- src/components/NavBar/index.tsx | 58 ++++--------------------------- src/components/Settings/color.tsx | 20 +++++------ src/locale/index.ts | 14 ++++---- src/routes.ts | 21 +++-------- 4 files changed, 26 insertions(+), 87 deletions(-) diff --git a/src/components/NavBar/index.tsx b/src/components/NavBar/index.tsx index 41a4210..1afe766 100644 --- a/src/components/NavBar/index.tsx +++ b/src/components/NavBar/index.tsx @@ -18,13 +18,10 @@ import { IconUser, IconSettings, IconPoweroff, - IconExperiment, - IconDashboard, - IconInteraction, - IconTag, IconLoading, } from '@arco-design/web-react/icon'; import { useSelector, useDispatch } from 'react-redux'; +import { useHistory } from 'react-router-dom'; import { GlobalState } from '@/store'; import { GlobalContext } from '@/context'; import useLocale from '@/utils/useLocale'; @@ -39,6 +36,7 @@ import { generatePermission } from '@/routes'; function Navbar({ show }: { show: boolean }) { const t = useLocale(); + const history = useHistory(); const { userInfo, userLoading } = useSelector((state: GlobalState) => state); const dispatch = useDispatch(); @@ -55,8 +53,8 @@ function Navbar({ show }: { show: boolean }) { function onMenuItemClick(key) { if (key === 'logout') { logout(); - } else { - Message.info(`You clicked ${key}`); + } else if (key === 'userInfo') { + history.push('/user-info'); } } @@ -84,54 +82,12 @@ function Navbar({ show }: { show: boolean }) { ); } - const handleChangeRole = () => { - const newRole = role === 'admin' ? 'user' : 'admin'; - setRole(newRole); - }; - const droplist = ( - - - - {role === 'admin' - ? t['menu.user.role.admin'] - : t['menu.user.role.user']} - - - } - > - - - {t['menu.user.switchRoles']} - - - - - {t['menu.user.setting']} + + + {t['navbar.userInfo']} - - - {t['message.seeMore']} - - } - > - - - {t['menu.dashboard.workplace']} - - - - {t['menu.list.cardList']} - - - diff --git a/src/components/Settings/color.tsx b/src/components/Settings/color.tsx index ef259ba..c861f9f 100644 --- a/src/components/Settings/color.tsx +++ b/src/components/Settings/color.tsx @@ -1,10 +1,11 @@ import React from 'react'; import { Trigger, Typography } from '@arco-design/web-react'; import { SketchPicker } from 'react-color'; -import { generate, getRgbStr } from '@arco-design/color'; +import { generate } from '@arco-design/color'; import { useSelector, useDispatch } from 'react-redux'; import { GlobalState } from '../../store'; import useLocale from '@/utils/useLocale'; +import initThemeColor from '@/utils/initThemeColor'; import styles from './style/color-panel.module.less'; function ColorPanel() { @@ -26,21 +27,16 @@ function ColorPanel() { color={themeColor} onChangeComplete={(color) => { const newColor = color.hex; + + // 更新 Redux 状态 dispatch({ type: 'update-settings', payload: { settings: { ...settings, themeColor: newColor } }, }); - const newList = generate(newColor, { - list: true, - dark: theme === 'dark', - }); - newList.forEach((l, index) => { - const rgbStr = getRgbStr(l); - document.body.style.setProperty( - `--arcoblue-${index + 1}`, - rgbStr - ); - }); + + // 使用统一的初始化函数生成并注入梯度色 + const isDark = theme === 'dark'; + initThemeColor(newColor, isDark); }} /> )} diff --git a/src/locale/index.ts b/src/locale/index.ts index 8513e14..4741e37 100644 --- a/src/locale/index.ts +++ b/src/locale/index.ts @@ -1,9 +1,8 @@ const i18n = { 'en-US': { - 'menu.dashboard': 'Dashboard', - 'menu.list': 'List', - 'menu.list.searchTable': 'Search Table', - 'menu.dashboard.workplace': 'Workplace', + 'menu.userManagement': 'User Management', + 'menu.userInfo': 'User Info', + 'navbar.userInfo': 'User Info', 'navbar.logout': 'Logout', 'settings.title': 'Settings', 'settings.themeColor': 'Theme Color', @@ -35,10 +34,9 @@ const i18n = { 'navbar.search.placeholder': 'Please search', }, 'zh-CN': { - 'menu.dashboard': '仪表盘', - 'menu.list': '列表页', - 'menu.list.searchTable': '查询表格', - 'menu.dashboard.workplace': '工作台', + 'menu.userManagement': '用户管理', + 'menu.userInfo': '个人信息', + 'navbar.userInfo': '个人信息', 'navbar.logout': '退出登录', 'settings.title': '页面配置', 'settings.themeColor': '主题色', diff --git a/src/routes.ts b/src/routes.ts index 722faba..f173cae 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -13,24 +13,13 @@ export type IRoute = AuthParams & { export const routes: IRoute[] = [ { - name: 'menu.dashboard', - key: 'dashboard', - children: [ - { - name: 'menu.dashboard.workplace', - key: 'dashboard/workplace', - }, - ], + name: 'menu.userManagement', + key: 'user-management', }, { - name: 'menu.list', - key: 'list', - children: [ - { - name: 'menu.list.searchTable', - key: 'list/search-table', - }, - ], + name: 'menu.userInfo', + key: 'user-info', + ignore: true, // 不在菜单中显示 }, ];