) => {
+ const { id } = e.currentTarget.dataset;
+ if (!id) {
+ return;
+ }
+
+ setTheme(id);
+ localStorage.setItem("x-theme:v1", id);
+ }, []);
+
+ // 计算当前真正生效的激活 ID
+ const currentActiveId = theme === "system" || !theme ? systemTheme : theme;
+
return (
- {themes.map(({ id, name, color }) => (
-
- ))}
+ {themes.map(({ id, name, color }) => {
+ // 如果你的 themes 列表中包含一个 id 为 "system" 的按钮,
+ // 那么 isActive 直接对比 id === theme 即可。
+ // 如果这里只展示具体颜色按钮,则对比当前真正生效的 active 属性:
+ const isActive = id === theme ||
+ (theme === "system" && id === currentActiveId);
+
+ return (
+
+ );
+ })}
);
};