From 37199506e310be494ae78374f6eefbad2fa67024 Mon Sep 17 00:00:00 2001 From: haorwen Date: Fri, 26 Dec 2025 00:26:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E7=9A=84=E5=BC=80=E5=85=B3?= =?UTF-8?q?=20(#283)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add Web Client Auto Update feature with localization support - Introduced a new setting for automatic updates of the web client, available in both English and Chinese. - Added a new component for managing the auto-update feature in the settings overview. - Updated localization files to include descriptions and titles for the new feature. * chore: Update to v0.9.38 --- package.json | 2 +- public/locales/en/setting.json | 6 +++ public/locales/zh/setting.json | 6 +++ .../setting/Overview/WebClientAutoUpdate.tsx | 42 +++++++++++++++++++ src/routes/setting/Overview/index.tsx | 3 ++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/routes/setting/Overview/WebClientAutoUpdate.tsx diff --git a/package.json b/package.json index 3fc72c6c..ac5bbac4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vocechat-web", - "version": "0.9.37", + "version": "0.9.38", "homepage": "https://voce.chat", "dependencies": { "@metamask/onboarding": "^1.0.1", diff --git a/public/locales/en/setting.json b/public/locales/en/setting.json index ce8dc4fc..4eb1d5c9 100644 --- a/public/locales/en/setting.json +++ b/public/locales/en/setting.json @@ -144,6 +144,12 @@ "desc": "By default all server members can see each other. If you want server members to add and manage their own contacts, please enable the contact feature (admin will be in the contacts list by default).", "enable": "Enable", "disable": "Disable" + }, + "webclient_auto_update": { + "title": "Web Client Auto Update", + "desc": "If enabled, the web client will automatically update to the latest version. ⚠️ This feature is designed for advanced users only. Disabling it may prevent you from receiving the latest bug fixes and feature updates.", + "enable": "Enable", + "disable": "Disable" } }, "data": { diff --git a/public/locales/zh/setting.json b/public/locales/zh/setting.json index 62271ab2..950ec64f 100644 --- a/public/locales/zh/setting.json +++ b/public/locales/zh/setting.json @@ -142,6 +142,12 @@ "desc": "关闭:服务器内的所有成员能够互相看见;开启:通过搜索添加好友(管理员默认是所有人好友)", "enable": "开启", "disable": "关闭" + }, + "webclient_auto_update": { + "title": "前端自动更新", + "desc": "开启后,网页客户端将自动更新到最新版本。⚠️ 此功能仅为高级用户设计,关闭后可能无法接收到最新的 bug 修复、web 功能更新等", + "enable": "开启", + "disable": "关闭" } }, "data": { diff --git a/src/routes/setting/Overview/WebClientAutoUpdate.tsx b/src/routes/setting/Overview/WebClientAutoUpdate.tsx new file mode 100644 index 00000000..d59b7154 --- /dev/null +++ b/src/routes/setting/Overview/WebClientAutoUpdate.tsx @@ -0,0 +1,42 @@ +import { useEffect } from "react"; +import { toast } from "react-hot-toast"; +import { useTranslation } from "react-i18next"; + +import SettingBlock from "@/components/SettingBlock"; +import { + useGetSystemCommonQuery, + useUpdateSystemCommonMutation +} from "../../../app/services/server"; +import { useAppSelector } from "../../../app/store"; +import { shallowEqual } from "react-redux"; +import Toggle from "@/components/styled/Toggle"; + +const WebClientAutoUpdate = () => { + const currStatus = useAppSelector( + (store) => !!store.server.webclient_auto_update, + shallowEqual + ); + const { t } = useTranslation("setting", { keyPrefix: "overview.webclient_auto_update" }); + const { t: ct } = useTranslation(); + const { refetch } = useGetSystemCommonQuery(); + const [updateSetting, { isSuccess }] = useUpdateSystemCommonMutation(); + useEffect(() => { + if (isSuccess) { + refetch(); + toast.success(ct("tip.update")); + } + }, [isSuccess]); + const handleToggle = () => { + updateSetting({ webclient_auto_update: !currStatus }); + }; + return ( + } + > + ); +}; + +export default WebClientAutoUpdate; + diff --git a/src/routes/setting/Overview/index.tsx b/src/routes/setting/Overview/index.tsx index 71682ae2..043a74ff 100644 --- a/src/routes/setting/Overview/index.tsx +++ b/src/routes/setting/Overview/index.tsx @@ -19,6 +19,7 @@ import GuestMode from "./GuestMode"; import WhoCanSignUpSetting from "./WhoCanSignUpSetting"; import UserMsgEmailNotify from "./UserMsgEmailNotify"; import WhoCanInviteUsers from "./WhoCanInviteUsers"; +import WebClientAutoUpdate from "./WebClientAutoUpdate"; export default function Overview() { const { t } = useTranslation("setting"); @@ -54,6 +55,8 @@ export default function Overview() { {/* 联系人验证模式 */} + {/* 前端自动更新 */} + )}