feat(web): add settings & pages of privacy policy & user agreement

This commit is contained in:
キュビビイ
2025-10-08 10:43:47 +08:00
parent a610ef48e4
commit 6891057647
12 changed files with 786 additions and 3 deletions

View File

@@ -38,6 +38,8 @@ const OtherSetting = () => {
const { t } = useTranslation();
let [inputs, setInputs] = useState({
Notice: '',
UserAgreement: '',
PrivacyPolicy: '',
SystemName: '',
Logo: '',
Footer: '',
@@ -69,6 +71,8 @@ const OtherSetting = () => {
const [loadingInput, setLoadingInput] = useState({
Notice: false,
UserAgreement: false,
PrivacyPolicy: false,
SystemName: false,
Logo: false,
HomePageContent: false,
@@ -96,6 +100,32 @@ const OtherSetting = () => {
setLoadingInput((loadingInput) => ({ ...loadingInput, Notice: false }));
}
};
// 通用设置 - UserAgreement
const submitUserAgreement = async () => {
try {
setLoadingInput((loadingInput) => ({ ...loadingInput, UserAgreement: true }));
await updateOption('UserAgreement', inputs.UserAgreement);
showSuccess(t('用户协议已更新'));
} catch (error) {
console.error(t('用户协议更新失败'), error);
showError(t('用户协议更新失败'));
} finally {
setLoadingInput((loadingInput) => ({ ...loadingInput, UserAgreement: false }));
}
};
// 通用设置 - PrivacyPolicy
const submitPrivacyPolicy = async () => {
try {
setLoadingInput((loadingInput) => ({ ...loadingInput, PrivacyPolicy: true }));
await updateOption('PrivacyPolicy', inputs.PrivacyPolicy);
showSuccess(t('隐私政策已更新'));
} catch (error) {
console.error(t('隐私政策更新失败'), error);
showError(t('隐私政策更新失败'));
} finally {
setLoadingInput((loadingInput) => ({ ...loadingInput, PrivacyPolicy: false }));
}
};
// 个性化设置
const formAPIPersonalization = useRef();
// 个性化设置 - SystemName
@@ -324,6 +354,34 @@ const OtherSetting = () => {
<Button onClick={submitNotice} loading={loadingInput['Notice']}>
{t('设置公告')}
</Button>
<Form.TextArea
label={t('用户协议')}
placeholder={t(
'在此输入用户协议内容,支持 Markdown & HTML 代码',
)}
field={'UserAgreement'}
onChange={handleInputChange}
style={{ fontFamily: 'JetBrains Mono, Consolas' }}
autosize={{ minRows: 6, maxRows: 12 }}
helpText={t('填写用户协议内容后,用户注册时将被要求勾选已阅读用户协议')}
/>
<Button onClick={submitUserAgreement} loading={loadingInput['UserAgreement']}>
{t('设置用户协议')}
</Button>
<Form.TextArea
label={t('隐私政策')}
placeholder={t(
'在此输入隐私政策内容,支持 Markdown & HTML 代码',
)}
field={'PrivacyPolicy'}
onChange={handleInputChange}
style={{ fontFamily: 'JetBrains Mono, Consolas' }}
autosize={{ minRows: 6, maxRows: 12 }}
helpText={t('填写隐私政策内容后,用户注册时将被要求勾选已阅读隐私政策')}
/>
<Button onClick={submitPrivacyPolicy} loading={loadingInput['PrivacyPolicy']}>
{t('设置隐私政策')}
</Button>
</Form.Section>
</Card>
</Form>