mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-07 20:06:08 +08:00
系统设置增加系统语言切换
This commit is contained in:
parent
e9416c23df
commit
aa5d6f3cb6
|
@ -1,4 +1,5 @@
|
||||||
const baseUrl = window.__ENV__QlBaseUrl || '/';
|
const baseUrl = window.__ENV__QlBaseUrl || '/';
|
||||||
|
import { setLocale } from '@umijs/max';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
export function rootContainer(container: any) {
|
export function rootContainer(container: any) {
|
||||||
|
@ -9,6 +10,7 @@ export function rootContainer(container: any) {
|
||||||
let currentLocale = intl.determineLocale({
|
let currentLocale = intl.determineLocale({
|
||||||
urlLocaleKey: 'lang',
|
urlLocaleKey: 'lang',
|
||||||
cookieLocaleKey: 'lang',
|
cookieLocaleKey: 'lang',
|
||||||
|
localStorageLocaleKey: 'lang',
|
||||||
}).slice(0, 2);
|
}).slice(0, 2);
|
||||||
|
|
||||||
if (!currentLocale || !Object.keys(locales).includes(currentLocale)) {
|
if (!currentLocale || !Object.keys(locales).includes(currentLocale)) {
|
||||||
|
@ -16,6 +18,7 @@ export function rootContainer(container: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
intl.init({ currentLocale, locales });
|
intl.init({ currentLocale, locales });
|
||||||
|
setLocale(currentLocale === 'zh' ? 'zh-CN' : 'en-US');
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -450,5 +450,6 @@
|
||||||
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "The 'Group Code' for One-to-Many Push (Below One-to-Many Push->Your Group (if not, create one)->Group Code, if you are the creator of the group, you also need to click 'View QR Code' to scan and bind, otherwise you cannot receive group messages)",
|
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "The 'Group Code' for One-to-Many Push (Below One-to-Many Push->Your Group (if not, create one)->Group Code, if you are the creator of the group, you also need to click 'View QR Code' to scan and bind, otherwise you cannot receive group messages)",
|
||||||
"登录已过期,请重新登录": "Login session has expired, please log in again",
|
"登录已过期,请重新登录": "Login session has expired, please log in again",
|
||||||
"系统日志": "System Logs",
|
"系统日志": "System Logs",
|
||||||
"主题": "Theme"
|
"主题": "Theme",
|
||||||
|
"语言": "Language"
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,5 +450,6 @@
|
||||||
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)",
|
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)",
|
||||||
"登录已过期,请重新登录": "登录已过期,请重新登录",
|
"登录已过期,请重新登录": "登录已过期,请重新登录",
|
||||||
"系统日志": "系统日志",
|
"系统日志": "系统日志",
|
||||||
"主题": "主题"
|
"主题": "主题",
|
||||||
|
"语言": "语言"
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,6 +243,9 @@ const Setting = () => {
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
setSystemLogData(await res.text());
|
setSystemLogData(await res.text());
|
||||||
|
setTimeout(() => {
|
||||||
|
getSystemLog();
|
||||||
|
}, 5000);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
@ -335,22 +338,6 @@ const Setting = () => {
|
||||||
label: intl.get('通知设置'),
|
label: intl.get('通知设置'),
|
||||||
children: <NotificationSetting data={notificationInfo} />,
|
children: <NotificationSetting data={notificationInfo} />,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'login',
|
|
||||||
label: intl.get('登录日志'),
|
|
||||||
children: <LoginLog data={loginLogData} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'other',
|
|
||||||
label: intl.get('其他设置'),
|
|
||||||
children: (
|
|
||||||
<Other
|
|
||||||
reloadTheme={reloadTheme}
|
|
||||||
socketMessage={socketMessage}
|
|
||||||
systemInfo={systemInfo}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'syslog',
|
key: 'syslog',
|
||||||
label: intl.get('系统日志'),
|
label: intl.get('系统日志'),
|
||||||
|
@ -375,6 +362,22 @@ const Setting = () => {
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'login',
|
||||||
|
label: intl.get('登录日志'),
|
||||||
|
children: <LoginLog data={loginLogData} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'other',
|
||||||
|
label: intl.get('其他设置'),
|
||||||
|
children: (
|
||||||
|
<Other
|
||||||
|
reloadTheme={reloadTheme}
|
||||||
|
socketMessage={socketMessage}
|
||||||
|
systemInfo={systemInfo}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'about',
|
key: 'about',
|
||||||
label: intl.get('关于'),
|
label: intl.get('关于'),
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
Input,
|
Input,
|
||||||
Upload,
|
Upload,
|
||||||
Modal,
|
Modal,
|
||||||
Progress,
|
Select,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import * as DarkReader from '@umijs/ssr-darkreader';
|
import * as DarkReader from '@umijs/ssr-darkreader';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
|
@ -22,12 +22,6 @@ import { UploadOutlined } from '@ant-design/icons';
|
||||||
import Countdown from 'antd/lib/statistic/Countdown';
|
import Countdown from 'antd/lib/statistic/Countdown';
|
||||||
import useProgress from './progress';
|
import useProgress from './progress';
|
||||||
|
|
||||||
const optionsWithDisabled = [
|
|
||||||
{ label: intl.get('亮色'), value: 'light' },
|
|
||||||
{ label: intl.get('暗色'), value: 'dark' },
|
|
||||||
{ label: intl.get('跟随系统'), value: 'auto' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const Other = ({
|
const Other = ({
|
||||||
systemInfo,
|
systemInfo,
|
||||||
socketMessage,
|
socketMessage,
|
||||||
|
@ -67,6 +61,13 @@ const Other = ({
|
||||||
reloadTheme();
|
reloadTheme();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLangChange = (v: string) => {
|
||||||
|
localStorage.setItem('lang', v);
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
|
||||||
const getSystemConfig = () => {
|
const getSystemConfig = () => {
|
||||||
request
|
request
|
||||||
.get(`${config.apiPrefix}system/config`)
|
.get(`${config.apiPrefix}system/config`)
|
||||||
|
@ -167,12 +168,27 @@ const Other = ({
|
||||||
initialValue={defaultTheme}
|
initialValue={defaultTheme}
|
||||||
>
|
>
|
||||||
<Radio.Group
|
<Radio.Group
|
||||||
options={optionsWithDisabled}
|
|
||||||
onChange={themeChange}
|
onChange={themeChange}
|
||||||
value={defaultTheme}
|
value={defaultTheme}
|
||||||
optionType="button"
|
optionType="button"
|
||||||
buttonStyle="solid"
|
buttonStyle="solid"
|
||||||
/>
|
>
|
||||||
|
<Radio.Button
|
||||||
|
value="light"
|
||||||
|
style={{ width: 70, textAlign: 'center' }}
|
||||||
|
>
|
||||||
|
{intl.get('亮色')}
|
||||||
|
</Radio.Button>
|
||||||
|
<Radio.Button value="dark" style={{ width: 66, textAlign: 'center' }}>
|
||||||
|
{intl.get('暗色')}
|
||||||
|
</Radio.Button>
|
||||||
|
<Radio.Button
|
||||||
|
value="auto"
|
||||||
|
style={{ width: 129, textAlign: 'center' }}
|
||||||
|
>
|
||||||
|
{intl.get('跟随系统')}
|
||||||
|
</Radio.Button>
|
||||||
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={intl.get('日志删除频率')}
|
label={intl.get('日志删除频率')}
|
||||||
|
@ -190,7 +206,11 @@ const Other = ({
|
||||||
setSystemConfig({ ...systemConfig, logRemoveFrequency: value });
|
setSystemConfig({ ...systemConfig, logRemoveFrequency: value });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button type="primary" onClick={updateSystemConfig}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={updateSystemConfig}
|
||||||
|
style={{ width: 84 }}
|
||||||
|
>
|
||||||
{intl.get('确认')}
|
{intl.get('确认')}
|
||||||
</Button>
|
</Button>
|
||||||
</Input.Group>
|
</Input.Group>
|
||||||
|
@ -198,18 +218,34 @@ const Other = ({
|
||||||
<Form.Item label={intl.get('定时任务并发数')} name="frequency">
|
<Form.Item label={intl.get('定时任务并发数')} name="frequency">
|
||||||
<Input.Group compact>
|
<Input.Group compact>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
style={{ width: 150 }}
|
style={{ width: 180 }}
|
||||||
min={1}
|
min={1}
|
||||||
value={systemConfig?.cronConcurrency}
|
value={systemConfig?.cronConcurrency}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
setSystemConfig({ ...systemConfig, cronConcurrency: value });
|
setSystemConfig({ ...systemConfig, cronConcurrency: value });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button type="primary" onClick={updateSystemConfig}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={updateSystemConfig}
|
||||||
|
style={{ width: 84 }}
|
||||||
|
>
|
||||||
{intl.get('确认')}
|
{intl.get('确认')}
|
||||||
</Button>
|
</Button>
|
||||||
</Input.Group>
|
</Input.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item label={intl.get('语言')} name="lang">
|
||||||
|
<Select
|
||||||
|
defaultValue={localStorage.getItem('lang') || ''}
|
||||||
|
style={{ width: 264 }}
|
||||||
|
onChange={handleLangChange}
|
||||||
|
options={[
|
||||||
|
{ value: '', label: intl.get('跟随系统') },
|
||||||
|
{ value: 'zh', label: '简体中文' },
|
||||||
|
{ value: 'en', label: 'English' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
<Form.Item label={intl.get('数据备份还原')} name="frequency">
|
<Form.Item label={intl.get('数据备份还原')} name="frequency">
|
||||||
<Button type="primary" onClick={exportData} loading={exportLoading}>
|
<Button type="primary" onClick={exportData} loading={exportLoading}>
|
||||||
{exportLoading ? intl.get('生成数据中...') : intl.get('备份')}
|
{exportLoading ? intl.get('生成数据中...') : intl.get('备份')}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user