mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-18 07:47:26 +00:00
- Added internationalization (i18n) support across various components, enabling dynamic language switching and improved user experience. - Updated multiple components to utilize translation functions for labels, buttons, and messages, ensuring consistent language display. - Enhanced the user interface by refining text elements in the ChannelsTable, LogsTable, and various settings pages, improving clarity and accessibility. - Adjusted CSS styles for better responsiveness and layout consistency across different screen sizes.
77 lines
2.0 KiB
JavaScript
77 lines
2.0 KiB
JavaScript
import React, { useEffect, useState } from 'react';
|
|
import { Layout, TabPane, Tabs } from '@douyinfe/semi-ui';
|
|
import { useNavigate, useLocation } from 'react-router-dom';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import SystemSetting from '../../components/SystemSetting';
|
|
import { isRoot } from '../../helpers';
|
|
import OtherSetting from '../../components/OtherSetting';
|
|
import PersonalSetting from '../../components/PersonalSetting';
|
|
import OperationSetting from '../../components/OperationSetting';
|
|
|
|
const Setting = () => {
|
|
const { t } = useTranslation();
|
|
const navigate = useNavigate();
|
|
const location = useLocation();
|
|
const [tabActiveKey, setTabActiveKey] = useState('1');
|
|
let panes = [
|
|
{
|
|
tab: t('个人设置'),
|
|
content: <PersonalSetting />,
|
|
itemKey: 'personal',
|
|
},
|
|
];
|
|
|
|
if (isRoot()) {
|
|
panes.push({
|
|
tab: t('运营设置'),
|
|
content: <OperationSetting />,
|
|
itemKey: 'operation',
|
|
});
|
|
panes.push({
|
|
tab: t('系统设置'),
|
|
content: <SystemSetting />,
|
|
itemKey: 'system',
|
|
});
|
|
panes.push({
|
|
tab: t('其他设置'),
|
|
content: <OtherSetting />,
|
|
itemKey: 'other',
|
|
});
|
|
}
|
|
const onChangeTab = (key) => {
|
|
setTabActiveKey(key);
|
|
navigate(`?tab=${key}`);
|
|
};
|
|
useEffect(() => {
|
|
const searchParams = new URLSearchParams(window.location.search);
|
|
const tab = searchParams.get('tab');
|
|
if (tab) {
|
|
setTabActiveKey(tab);
|
|
} else {
|
|
onChangeTab('personal');
|
|
}
|
|
}, [location.search]);
|
|
return (
|
|
<div>
|
|
<Layout>
|
|
<Layout.Content>
|
|
<Tabs
|
|
type='line'
|
|
activeKey={tabActiveKey}
|
|
onChange={(key) => onChangeTab(key)}
|
|
>
|
|
{panes.map((pane) => (
|
|
<TabPane itemKey={pane.itemKey} tab={pane.tab} key={pane.itemKey}>
|
|
{tabActiveKey === pane.itemKey && pane.content}
|
|
</TabPane>
|
|
))}
|
|
</Tabs>
|
|
</Layout.Content>
|
|
</Layout>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Setting;
|