feat(frontend): add theme real-time sync feature

1. 新增ThemeSync组件实现站点主题色无刷新同步
2. 给获取站点设置的接口添加no-store缓存策略确保拿到最新配置
3. 调整主题应用代码的属性设置顺序避免逻辑问题
This commit is contained in:
2026-09-15 05:04:25 +08:00
parent a7b6421840
commit 29db9ae9b5
4 changed files with 75 additions and 2 deletions

View File

@@ -949,7 +949,8 @@ export async function apiAdminSetUserBan(
// ===== 站点外观设置 =====
export async function apiGetSettings(): Promise<PublicSettings> {
const res = await fetchWithRefresh("/api/settings", { method: "GET" });
// no-store:主题同步轮询必须读到管理员刚保存的最新配色,不走浏览器缓存
const res = await fetchWithRefresh("/api/settings", { method: "GET", cache: "no-store" });
if (!res.ok) throw new Error("获取站点设置失败");
return res.json();
}