From aa5d6f3cb64be456701f36a6fb0adcb9b7e9abb0 Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 26 Aug 2023 00:16:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=B3=BB=E7=BB=9F=E8=AF=AD=E8=A8=80=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 3 ++ src/locales/en-US.json | 3 +- src/locales/zh-CN.json | 3 +- src/pages/setting/index.tsx | 35 ++++++++++++---------- src/pages/setting/other.tsx | 60 +++++++++++++++++++++++++++++-------- 5 files changed, 74 insertions(+), 30 deletions(-) diff --git a/src/app.ts b/src/app.ts index aae44ab3..8aa3dfac 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,5 @@ const baseUrl = window.__ENV__QlBaseUrl || '/'; +import { setLocale } from '@umijs/max'; import intl from 'react-intl-universal'; export function rootContainer(container: any) { @@ -9,6 +10,7 @@ export function rootContainer(container: any) { let currentLocale = intl.determineLocale({ urlLocaleKey: 'lang', cookieLocaleKey: 'lang', + localStorageLocaleKey: 'lang', }).slice(0, 2); if (!currentLocale || !Object.keys(locales).includes(currentLocale)) { @@ -16,6 +18,7 @@ export function rootContainer(container: any) { } intl.init({ currentLocale, locales }); + setLocale(currentLocale === 'zh' ? 'zh-CN' : 'en-US'); return container; } diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 26a1289f..1beda10d 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -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)", "登录已过期,请重新登录": "Login session has expired, please log in again", "系统日志": "System Logs", - "主题": "Theme" + "主题": "Theme", + "语言": "Language" } diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json index cac7fd91..f382b838 100644 --- a/src/locales/zh-CN.json +++ b/src/locales/zh-CN.json @@ -450,5 +450,6 @@ "一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)", "登录已过期,请重新登录": "登录已过期,请重新登录", "系统日志": "系统日志", - "主题": "主题" + "主题": "主题", + "语言": "语言" } diff --git a/src/pages/setting/index.tsx b/src/pages/setting/index.tsx index f4872879..20aab29c 100644 --- a/src/pages/setting/index.tsx +++ b/src/pages/setting/index.tsx @@ -243,6 +243,9 @@ const Setting = () => { }) .then(async (res) => { setSystemLogData(await res.text()); + setTimeout(() => { + getSystemLog(); + }, 5000); }) .catch((error: any) => { console.log(error); @@ -335,22 +338,6 @@ const Setting = () => { label: intl.get('通知设置'), children: , }, - { - key: 'login', - label: intl.get('登录日志'), - children: , - }, - { - key: 'other', - label: intl.get('其他设置'), - children: ( - - ), - }, { key: 'syslog', label: intl.get('系统日志'), @@ -375,6 +362,22 @@ const Setting = () => { /> ), }, + { + key: 'login', + label: intl.get('登录日志'), + children: , + }, + { + key: 'other', + label: intl.get('其他设置'), + children: ( + + ), + }, { key: 'about', label: intl.get('关于'), diff --git a/src/pages/setting/other.tsx b/src/pages/setting/other.tsx index 7046e8d4..668031af 100644 --- a/src/pages/setting/other.tsx +++ b/src/pages/setting/other.tsx @@ -9,7 +9,7 @@ import { Input, Upload, Modal, - Progress, + Select, } from 'antd'; import * as DarkReader from '@umijs/ssr-darkreader'; import config from '@/utils/config'; @@ -22,12 +22,6 @@ import { UploadOutlined } from '@ant-design/icons'; import Countdown from 'antd/lib/statistic/Countdown'; import useProgress from './progress'; -const optionsWithDisabled = [ - { label: intl.get('亮色'), value: 'light' }, - { label: intl.get('暗色'), value: 'dark' }, - { label: intl.get('跟随系统'), value: 'auto' }, -]; - const Other = ({ systemInfo, socketMessage, @@ -67,6 +61,13 @@ const Other = ({ reloadTheme(); }; + const handleLangChange = (v: string) => { + localStorage.setItem('lang', v); + setTimeout(() => { + window.location.reload(); + }, 500); + }; + const getSystemConfig = () => { request .get(`${config.apiPrefix}system/config`) @@ -167,12 +168,27 @@ const Other = ({ initialValue={defaultTheme} > + > + + {intl.get('亮色')} + + + {intl.get('暗色')} + + + {intl.get('跟随系统')} + + - @@ -198,18 +218,34 @@ const Other = ({ { setSystemConfig({ ...systemConfig, cronConcurrency: value }); }} /> - + +