mirror of
https://github.com/sean2077/obsidian-dynamic-theme-background.git
synced 2026-07-22 06:44:57 +00:00
feat: Add active time rule indicator in settings and update hints
This commit is contained in:
parent
d2dd5a67bc
commit
451f265e24
3 changed files with 19 additions and 5 deletions
|
|
@ -61,13 +61,15 @@ export default {
|
|||
clear_time_rules_tooltip: "Clear all time slot rules",
|
||||
reset_time_rules_button: "Restore Defaults",
|
||||
reset_time_rules_tooltip: "Reset the time slot rules to their default settings.",
|
||||
time_rule_hint: "💡 When time slot rules overlap, the first matching rule takes precedence.",
|
||||
time_rule_hint:
|
||||
"💡 When time slot rules overlap, the first matching rule takes precedence. The indicator 🔥 means the current active rule.",
|
||||
rule_name_label: "Rule Name:",
|
||||
start_time_label: "Start Time (HH:MM):",
|
||||
end_time_label: "End Time (HH:MM):",
|
||||
interval_name: "Switch Interval",
|
||||
interval_desc: "How often to switch the background (in minutes).",
|
||||
confirm_clear_time_rules: "Are you sure you want to clear all time slot rules?",
|
||||
active_time_rule: "Currently Active Time Slot Rule",
|
||||
|
||||
// ===== 背景管理 =====
|
||||
bg_management_title: "Background Management",
|
||||
|
|
|
|||
|
|
@ -55,13 +55,14 @@ export default {
|
|||
clear_time_rules_tooltip: "清除所有时段规则",
|
||||
reset_time_rules_button: "恢复默认",
|
||||
reset_time_rules_tooltip: "将时段规则重置为默认设置",
|
||||
time_rule_hint: "💡 当时段规则存在重叠,优先使用第一个匹配的规则",
|
||||
time_rule_hint: "💡 当时段规则存在重叠,优先使用第一个匹配的规则;带有 🔥 标识的规则为当前应用的规则",
|
||||
rule_name_label: "规则名称:",
|
||||
start_time_label: "开始时间(HH:MM):",
|
||||
end_time_label: "结束时间(HH:MM):",
|
||||
interval_name: "切换间隔",
|
||||
interval_desc: "背景切换的间隔时间(分钟)",
|
||||
confirm_clear_time_rules: "您确定要清除所有时段规则吗?",
|
||||
active_time_rule: "当前激活的时段规则",
|
||||
|
||||
// ===== 背景管理 =====
|
||||
bg_management_title: "背景管理",
|
||||
|
|
|
|||
|
|
@ -460,15 +460,26 @@ export class DTBSettingTab extends PluginSettingTab {
|
|||
},
|
||||
});
|
||||
|
||||
// 获取当前激活的时间规则
|
||||
const activeRule = this.plugin.getCurrentTimeRule();
|
||||
|
||||
this.plugin.settings.timeRules.forEach((rule: TimeRule) => {
|
||||
const setting = new Setting(container)
|
||||
.setName(rule.name)
|
||||
.setDesc(`${rule.startTime} - ${rule.endTime}`)
|
||||
const setting = new Setting(container).setName(rule.name).setDesc(`${rule.startTime} - ${rule.endTime}`);
|
||||
|
||||
// 如果是激活的时间规则,则添加一个提示图标
|
||||
if (rule.id === activeRule?.id) {
|
||||
const indicator = setting.controlEl.createDiv();
|
||||
indicator.setText("🔥");
|
||||
indicator.title = t("active_time_rule");
|
||||
}
|
||||
|
||||
setting
|
||||
.addToggle((toggle) =>
|
||||
toggle.setValue(rule.enabled).onChange(async (value) => {
|
||||
rule.enabled = value;
|
||||
this.plugin.startBackgroundManager(); // 重新启动背景管理器以应用更改
|
||||
await this.plugin.saveSettings();
|
||||
this.displayTimeRules(container);
|
||||
})
|
||||
)
|
||||
.addDropdown((dropdown) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue