feat(ui): add classic frontend switch

This commit is contained in:
CaIon
2026-04-30 20:36:46 +08:00
parent 938dc9522b
commit dac55f0fde
9 changed files with 86 additions and 0 deletions
+46
View File
@@ -82,6 +82,7 @@ const OtherSetting = () => {
About: false,
Footer: false,
CheckUpdate: false,
FrontendTheme: false,
});
const handleInputChange = async (value, e) => {
const name = e.target.id;
@@ -278,6 +279,45 @@ const OtherSetting = () => {
}));
}
};
const switchToDefaultFrontend = () => {
Modal.confirm({
title: t('切换到新版前端'),
content: t('切换后页面会自动刷新,并进入新版前端。是否继续?'),
okText: t('确认切换'),
cancelText: t('取消'),
onOk: async () => {
try {
setLoadingInput((loadingInput) => ({
...loadingInput,
FrontendTheme: true,
}));
const res = await API.put('/api/option/', {
key: 'theme.frontend',
value: 'default',
});
const { success, message } = res.data;
if (!success) {
showError(message);
return;
}
showSuccess(t('已切换到新版前端,正在刷新页面'));
setTimeout(() => {
window.location.reload();
}, 600);
} catch (error) {
console.error('切换新版前端失败', error);
showError(t('切换失败,请稍后重试'));
} finally {
setLoadingInput((loadingInput) => ({
...loadingInput,
FrontendTheme: false,
}));
}
},
});
};
const getOptions = async () => {
const res = await API.get('/api/option/');
const { success, message, data } = res.data;
@@ -342,6 +382,12 @@ const OtherSetting = () => {
>
{t('检查更新')}
</Button>
<Button
onClick={switchToDefaultFrontend}
loading={loadingInput['FrontendTheme']}
>
{t('切换到新版前端')}
</Button>
</Space>
</Col>
</Row>