fix(theme): 切换前端主题后重置到首页,避免路由 404 (#5612)

* fix(theme): 切换前端主题后重置到首页,避免路由 404
经典前端与新版前端的路由路径不同,切换主题后停留在原路径会导致 404:
- 经典前端切换到新版前端时跳转首页,不再原地刷新当前路径
- 新版前端保存时若前端主题发生变化,保存成功后跳转首页

Fixes #4947

* fix: 更新前端切换提示信息,修正页面跳转逻辑
This commit is contained in:
peakchao
2026-06-26 21:44:23 +08:00
committed by GitHub
parent 35074345e8
commit c0e42bfbdc
10 changed files with 48 additions and 12 deletions
+5 -2
View File
@@ -301,9 +301,12 @@ const OtherSetting = () => {
showError(message);
return;
}
showSuccess(t('已切换到新版前端,正在刷新页面'));
showSuccess(t('已切换到新版前端,正在跳转首页'));
setTimeout(() => {
window.location.reload();
// 新版前端的路由与经典前端不同,原地刷新当前路径会 404,
// 因此切换后重置到首页,由后端按新主题返回对应前端。
// 使用 replace 避免在历史中留下已失效的路由,防止返回时再次 404。
window.location.replace('/');
}, 600);
} catch (error) {
console.error('切换新版前端失败', error);