友情链接管理;用户提问管理

This commit is contained in:
linxd
2025-06-17 21:06:27 +08:00
parent ebc4dfe1f9
commit 763871a465
35 changed files with 5466 additions and 99 deletions

View File

@ -1,10 +1,10 @@
import React, { useState } from 'react';
import { getLocale,setLocale } from 'umi';
import React, { useState, useEffect } from 'react';
import { getLocale, setLocale } from 'umi';
import './Language.less'
const Language: React.FC = (props) => {
const locale = getLocale();
const [currentLocale, setCurrentLocale] = useState(getLocale());
const [languageList, setLanguageList] = useState([
{
label: '中',
@ -15,12 +15,32 @@ const Language: React.FC = (props) => {
value: 'en-US',
},
]);
// 处理语言切换
const handleChangeLanguage = (value: string) => {
setLocale(value, false);
setCurrentLocale(value);
};
// 组件挂载时确保当前语言状态正确
useEffect(() => {
const locale = getLocale();
setCurrentLocale(locale);
}, []);
return (
<div className="language">
{languageList.map((item) => (
<span onClick={() => setLocale(item.value, false)} className={item.value === locale ? 'active' : ''} key={item.value}>{item.label}</span>
<span
onClick={() => handleChangeLanguage(item.value)}
className={item.value === currentLocale ? 'active' : ''}
key={item.value}
>
{item.label}
</span>
))}
</div>
);
};
export default Language;

View File

@ -5,8 +5,9 @@ import IconFont from '@/components/IconFont/IconFont';
interface IMenuItem {
label: string;
key: string;
path: string;
path?: string;
icon: string;
children?: IMenuItem[];
}
// 引入样式文件 useIntl().formatMessage({ id: 'menu.首页' }),
const items: IMenuItem[] = [
@ -50,7 +51,46 @@ const items: IMenuItem[] = [
label: 'menu.帮助中心管理',
key: 'helpManage',
path: '/helpManage',
icon: 'icon-bangzhuzhongxin',
icon: 'icon-bangzhuzhongxin'
},
{
label: 'menu.用户提问管理',
key: 'userQuestionManage',
icon: 'icon-yonghutiwen',
path: '/userQuestionManage',
children: [
{
label: 'menu.已阅问题',
key: 'readQuestionManage',
icon: 'icon-yiyue',
path: '/readQuestionManage',
},
{
label: 'menu.未阅问题',
key: 'unreadQuestionManage',
icon: 'icon-weiyuedu',
path: '/unreadQuestionManage',
},
],
},
{
label: 'menu.友情链接管理',
key: 'friendLinkManage',
icon: 'icon-youqinglianjie',
children: [
{
label: 'menu.友情链接分类',
key: 'friendLinkCategory',
icon: 'icon-fenlei',
path: '/friendLinkCategory',
},
{
label: 'menu.友情链接列表',
key: 'friendLinkList',
icon: 'icon-liebiaomoshi',
path: '/friendLinkManage',
},
],
},
];
@ -73,13 +113,26 @@ const SiderMenu: React.FC = (props) => {
}, [history.location.pathname]);
return (
<div className="header-menu">
<Menu selectedKeys={[current]} mode="vertical">
{items.map((item: IMenuItem) => (
<Menu.Item key={item.key}>
<IconFont type={item.icon} />
<Link to={item.path}>{intl.formatMessage({ id: item.label })}</Link>
</Menu.Item>
))}
<Menu selectedKeys={[current]} mode="inline">
{items.map((item: IMenuItem) =>
item.children ? (
<Menu.SubMenu
key={item.key}
title={intl.formatMessage({ id: item.label })}
icon={<IconFont type={item.icon} />}
>
{item.children?.map((child: IMenuItem) => (
<Menu.Item key={child.key} icon={<IconFont type={child.icon} />}>
<Link to={child.path}>{intl.formatMessage({ id: child.label })}</Link>
</Menu.Item>
))}
</Menu.SubMenu>
) : (
<Menu.Item key={item.key} icon={<IconFont type={item.icon} />}>
<Link to={item.path}>{intl.formatMessage({ id: item.label })}</Link>
</Menu.Item>
),
)}
</Menu>
</div>
);