feat(ui): add classic frontend switch
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user