From 27204a1c11c9e4b3cc9a321560f1f9390fc2f5a6 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Mon, 15 May 2023 13:14:29 +0800 Subject: [PATCH] refactor: setting overview --- public/locales/en/setting.json | 8 ++++++++ public/locales/zh/setting.json | 8 ++++++++ src/routes/setting/Overview/DarkMode.tsx | 10 +++------- src/routes/setting/Overview/FrontendURL.tsx | 11 ++++------ src/routes/setting/Overview/Language.tsx | 9 +++------ src/routes/setting/Overview/OnlineStatus.tsx | 11 +++------- src/routes/setting/Overview/Server.tsx | 2 +- src/routes/setting/Overview/SettingBlock.tsx | 21 ++++++++++++++++++++ src/routes/setting/Overview/language.tsx | 9 +++------ src/routes/setting/Overview/server.tsx | 2 +- 10 files changed, 55 insertions(+), 36 deletions(-) create mode 100644 src/routes/setting/Overview/SettingBlock.tsx diff --git a/public/locales/en/setting.json b/public/locales/en/setting.json index a72b1721..ecafc970 100644 --- a/public/locales/en/setting.json +++ b/public/locales/en/setting.json @@ -41,6 +41,8 @@ "delete_desc": "Are you sure want to delete this user?" }, "overview": { + "title_feat": "Features", + "title_feat_desc": "you can toggle features as you need", "name": "Server Name", "desc": "Server Description", "upload_desc": "Minimum size is 128x128, We recommend at least 512x512 for the server. Max size limited to 5M.", @@ -80,6 +82,12 @@ "desc": "Toggle users' online status visible", "enable": "Enable", "disable": "Disable" + }, + "chat_layout": { + "title": "Chat Layout", + "desc": "message self send on the left or right", + "left": "Left", + "self_right": "Self Right" } }, "license": { diff --git a/public/locales/zh/setting.json b/public/locales/zh/setting.json index f22cd782..ddc68999 100644 --- a/public/locales/zh/setting.json +++ b/public/locales/zh/setting.json @@ -38,6 +38,8 @@ "private": "私密" }, "overview": { + "title_feat": "特性开关", + "title_feat_desc": "根据你的需要开启或关闭特性", "name": "服务器名", "desc": "服务器描述", "upload_desc": "图片最小 128x128,我们推荐上传 512x512 大小的图片,最大不要超过5M。", @@ -74,6 +76,12 @@ "desc": "开启或关闭用户在线状态", "enable": "开启", "disable": "关闭" + }, + "chat_layout": { + "title": "聊天布局", + "desc": "你可以决定自己发的消息居左还是居右", + "left": "居左", + "self_right": "居右" } }, "license": { diff --git a/src/routes/setting/Overview/DarkMode.tsx b/src/routes/setting/Overview/DarkMode.tsx index a3630234..c8477905 100644 --- a/src/routes/setting/Overview/DarkMode.tsx +++ b/src/routes/setting/Overview/DarkMode.tsx @@ -2,6 +2,7 @@ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import Radio from '../../../common/component/styled/Radio'; import { Theme } from '../../../types/common'; +import SettingBlock from './SettingBlock'; // type Props = {} @@ -19,15 +20,10 @@ const DarkMode = () => { } else { const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; document.documentElement.classList.add(isDark ? "dark" : 'light'); - } }; return ( -
-

{t("overview.theme.title")}

-

- {t("overview.theme.desc")} -

+ { handleThemeToggle(v); }} /> -
+ ); }; diff --git a/src/routes/setting/Overview/FrontendURL.tsx b/src/routes/setting/Overview/FrontendURL.tsx index 707b6467..239eae57 100644 --- a/src/routes/setting/Overview/FrontendURL.tsx +++ b/src/routes/setting/Overview/FrontendURL.tsx @@ -1,10 +1,11 @@ // import React from 'react' import { useTranslation } from 'react-i18next'; +import { toast } from 'react-hot-toast'; import { useGetFrontendUrlQuery, useUpdateFrontendUrlMutation } from '../../../app/services/server'; import StyledInput from "../../../common/component/styled/Input"; import StyledButton from "../../../common/component/styled/Button"; import { ChangeEvent, useState, useEffect } from 'react'; -import { toast } from 'react-hot-toast'; +import SettingBlock from './SettingBlock'; // type Props = {} const Index = () => { @@ -32,16 +33,12 @@ const Index = () => { }, [getUrlSuccess, data]); // if(!fetch) return ( -
-

{t("overview.url.title")}

-

- {t("overview.url.desc")} -

+
{ct("action.update")}
-
+ ); }; diff --git a/src/routes/setting/Overview/Language.tsx b/src/routes/setting/Overview/Language.tsx index 9c147543..2bab374f 100644 --- a/src/routes/setting/Overview/Language.tsx +++ b/src/routes/setting/Overview/Language.tsx @@ -1,6 +1,7 @@ // import React from 'react' import { useTranslation } from 'react-i18next'; import StyledRadio from "../../../common/component/styled/Radio"; +import SettingBlock from './SettingBlock'; // type Props = {} @@ -10,11 +11,7 @@ const Index = () => { i18n.changeLanguage(v); }; return ( -
-

{t("overview.lang.title")}

-

- {t("overview.lang.desc")} -

+ { handleGuestToggle(v); }} /> -
+ ); }; diff --git a/src/routes/setting/Overview/OnlineStatus.tsx b/src/routes/setting/Overview/OnlineStatus.tsx index f4d3bcca..8267bd02 100644 --- a/src/routes/setting/Overview/OnlineStatus.tsx +++ b/src/routes/setting/Overview/OnlineStatus.tsx @@ -5,6 +5,7 @@ import { useEffect } from 'react'; import { toast } from 'react-hot-toast'; import StyledRadio from "../../../common/component/styled/Radio"; import { useAppSelector } from '../../../app/store'; +import SettingBlock from './SettingBlock'; // type Props = {} const Index = () => { @@ -24,20 +25,14 @@ const Index = () => { }; // if (!loadSuccess) return null; return ( -
-

{t("title")}

-

- - {t("desc")} - -

+ -
+ ); }; diff --git a/src/routes/setting/Overview/Server.tsx b/src/routes/setting/Overview/Server.tsx index 86c6b3a2..6d9b2ecd 100644 --- a/src/routes/setting/Overview/Server.tsx +++ b/src/routes/setting/Overview/Server.tsx @@ -78,7 +78,7 @@ const Index = () => { )} -
+
{ + return ( +
+

{title}

+

+ {desc} +

+ {children} +
+ ); +}; + +export default SettingBlock; \ No newline at end of file diff --git a/src/routes/setting/Overview/language.tsx b/src/routes/setting/Overview/language.tsx index 9c147543..2bab374f 100644 --- a/src/routes/setting/Overview/language.tsx +++ b/src/routes/setting/Overview/language.tsx @@ -1,6 +1,7 @@ // import React from 'react' import { useTranslation } from 'react-i18next'; import StyledRadio from "../../../common/component/styled/Radio"; +import SettingBlock from './SettingBlock'; // type Props = {} @@ -10,11 +11,7 @@ const Index = () => { i18n.changeLanguage(v); }; return ( -
-

{t("overview.lang.title")}

-

- {t("overview.lang.desc")} -

+ { handleGuestToggle(v); }} /> -
+ ); }; diff --git a/src/routes/setting/Overview/server.tsx b/src/routes/setting/Overview/server.tsx index 86c6b3a2..6d9b2ecd 100644 --- a/src/routes/setting/Overview/server.tsx +++ b/src/routes/setting/Overview/server.tsx @@ -78,7 +78,7 @@ const Index = () => {
)}
-
+