refactor: 精简主题模板为设置页主题二选一
去掉之前多余的6套模板配色(ocean/sunset/forest/mono等), 只保留一个清晰的二选一功能: - 动物岛风 (默认) — 当前 Animal Island 固定配色,不变 - 系统莫奈色 — 设置页 UI 使用系统 Monet 色系,与主面板一致 改动: - THEME_TEMPLATE → SETTINGS_THEME (animal/monet) - 删除 th_04_theme.js 的 getThemeTemplate/applyThemeTemplate - buildSettingsGroupPanelView 直接根据 SETTINGS_THEME 用 ui.colors 的 Monet 色构造 T 结构 - setPendingValue 中 SETTINGS_THEME 切换时重建设置页
This commit is contained in:
@@ -747,67 +747,14 @@ FloatBallAppWM.prototype.safeParseColor = function(hex, fallbackInt) {
|
||||
try { return android.graphics.Color.parseColor(String(hex)); } catch (e) { return fallbackInt; }
|
||||
};
|
||||
|
||||
// =======================【主题模板:一键切换配色预设】======================
|
||||
// 每个模板定义日间/夜间 背景+文字色。选择模板后如果用户没单独覆盖那4个颜色配置,
|
||||
// 就在 getPanelBgColorInt/getPanelTextColorInt 中自动填充模板值。
|
||||
FloatBallAppWM.prototype.getThemeTemplate = function(name) {
|
||||
var tplMap = {
|
||||
system: { dayBg: null, dayText: null, nightBg: null, nightText: null },
|
||||
animal: { dayBg: "#A8DDB4", dayText: "#5E472D", nightBg: "#2F4034", nightText: "#FFF1D2" },
|
||||
ocean: { dayBg: "#B3E5FC", dayText: "#1A237E", nightBg: "#1A237E", nightText: "#B3E5FC" },
|
||||
sunset: { dayBg: "#FFE0B2", dayText: "#4E342E", nightBg: "#3E2723", nightText: "#FFCCBC" },
|
||||
forest: { dayBg: "#C8E6C9", dayText: "#1B5E20", nightBg: "#1B5E20", nightText: "#C8E6C9" },
|
||||
mono: { dayBg: "#F5F5F5", dayText: "#212121", nightBg: "#212121", nightText: "#F5F5F5" }
|
||||
};
|
||||
return tplMap[name] || tplMap.system;
|
||||
};
|
||||
|
||||
// 应用主题模板:如果选择非 system 模板且那4个颜色未手动覆盖,用模板值填充。
|
||||
// preview=true 时从 pendingUserCfg 读/写(预览态),否则从 this.config 读/写。
|
||||
FloatBallAppWM.prototype.applyThemeTemplate = function(preview) {
|
||||
try {
|
||||
var cfg = preview && this.state.pendingUserCfg ? this.state.pendingUserCfg : this.config;
|
||||
var tpl = String(cfg.THEME_TEMPLATE || "system");
|
||||
if (tpl === "system") return; // system 走 Monet,不填充
|
||||
|
||||
var t = this.getThemeTemplate(tpl);
|
||||
var _isNull = function(v) { return v == null || String(v) === "" || String(v) === "null"; };
|
||||
|
||||
if (t.dayBg != null && _isNull(cfg.THEME_DAY_BG_HEX)) {
|
||||
cfg.THEME_DAY_BG_HEX = String(t.dayBg);
|
||||
}
|
||||
if (t.dayText != null && _isNull(cfg.THEME_DAY_TEXT_HEX)) {
|
||||
cfg.THEME_DAY_TEXT_HEX = String(t.dayText);
|
||||
}
|
||||
if (t.nightBg != null && _isNull(cfg.THEME_NIGHT_BG_HEX)) {
|
||||
cfg.THEME_NIGHT_BG_HEX = String(t.nightBg);
|
||||
}
|
||||
if (t.nightText != null && _isNull(cfg.THEME_NIGHT_TEXT_HEX)) {
|
||||
cfg.THEME_NIGHT_TEXT_HEX = String(t.nightText);
|
||||
}
|
||||
|
||||
try { _th_log(this.L, "d", "[theme:template] applied " + tpl + " dayBg=" + String(t.dayBg) + " preview=" + !!preview); } catch(eL) {}
|
||||
} catch(e) {
|
||||
try { _th_log(this.L, "e", "[theme:template] apply err=" + String(e)); } catch(eL2) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
FloatBallAppWM.prototype.getPanelBgColorInt = function() {
|
||||
// 这段代码的主要内容/用途:配合"白天/夜晚"两档主题,返回统一的背景颜色(不再依赖自动亮度推断)。
|
||||
|
||||
// 应用主题模板(如果选择模板且用户未手动覆盖)
|
||||
// 预览态从 pendingUserCfg 读模板值并填充 pendingUserCfg 的颜色字段
|
||||
var inPreview = this.state.pendingUserCfg != null;
|
||||
try { this.applyThemeTemplate(inPreview); } catch(eAT) {}
|
||||
|
||||
var isDark = this.isDarkTheme();
|
||||
|
||||
// 预览态优先从 pendingUserCfg 读颜色值
|
||||
var cfg = inPreview && this.state.pendingUserCfg ? this.state.pendingUserCfg : this.config;
|
||||
var dayBgHex = (cfg.THEME_DAY_BG_HEX != null) ? String(cfg.THEME_DAY_BG_HEX) : null;
|
||||
var nightBgHex = (cfg.THEME_NIGHT_BG_HEX != null) ? String(cfg.THEME_NIGHT_BG_HEX) : null;
|
||||
var dayBgHex = (this.config.THEME_DAY_BG_HEX != null) ? String(this.config.THEME_DAY_BG_HEX) : null;
|
||||
var nightBgHex = (this.config.THEME_NIGHT_BG_HEX != null) ? String(this.config.THEME_NIGHT_BG_HEX) : null;
|
||||
|
||||
// # 兼容旧版默认配色:若仍为旧默认值,自动回退到莫奈色
|
||||
if (dayBgHex === "#FAF4E3") dayBgHex = null;
|
||||
@@ -835,18 +782,10 @@ FloatBallAppWM.prototype.getPanelBgColorInt = function() {
|
||||
|
||||
FloatBallAppWM.prototype.getPanelTextColorInt = function(bgInt) {
|
||||
// 这段代码的主要内容/用途:配合"白天/夜晚"两档主题,返回统一的文字颜色(不再依赖自动亮度推断)。
|
||||
|
||||
// 应用主题模板(如果选择模板且用户未手动覆盖)
|
||||
// 预览态从 pendingUserCfg 读模板值并填充 pendingUserCfg 的颜色字段
|
||||
var inPreviewText = this.state.pendingUserCfg != null;
|
||||
try { this.applyThemeTemplate(inPreviewText); } catch(eAT) {}
|
||||
|
||||
var isDark = this.isDarkTheme();
|
||||
|
||||
// 预览态优先从 pendingUserCfg 读颜色值
|
||||
var cfgT = inPreviewText && this.state.pendingUserCfg ? this.state.pendingUserCfg : this.config;
|
||||
var dayTextHex = (cfgT.THEME_DAY_TEXT_HEX != null) ? String(cfgT.THEME_DAY_TEXT_HEX) : null;
|
||||
var nightTextHex = (cfgT.THEME_NIGHT_TEXT_HEX != null) ? String(cfgT.THEME_NIGHT_TEXT_HEX) : null;
|
||||
var dayTextHex = (this.config.THEME_DAY_TEXT_HEX != null) ? String(this.config.THEME_DAY_TEXT_HEX) : null;
|
||||
var nightTextHex = (this.config.THEME_NIGHT_TEXT_HEX != null) ? String(this.config.THEME_NIGHT_TEXT_HEX) : null;
|
||||
|
||||
// # 兼容旧版默认配色:若仍为旧默认值,自动回退到莫奈色
|
||||
if (dayTextHex === "#333333") dayTextHex = null;
|
||||
|
||||
Reference in New Issue
Block a user