feat: 增加关闭自动更新的开关 (#283)
* 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
This commit is contained in:
@@ -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 (
|
||||
<SettingBlock
|
||||
title={t("title")}
|
||||
desc={t("desc")}
|
||||
toggler={<Toggle onClick={handleToggle} checked={currStatus} />}
|
||||
></SettingBlock>
|
||||
);
|
||||
};
|
||||
|
||||
export default WebClientAutoUpdate;
|
||||
|
||||
@@ -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() {
|
||||
<ChatLayout />
|
||||
{/* 联系人验证模式 */}
|
||||
<ContactVerification />
|
||||
{/* 前端自动更新 */}
|
||||
<WebClientAutoUpdate />
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user