feat: 添加自动运行延迟状态管理,支持从消息更新界面状态
This commit is contained in:
@@ -1183,6 +1183,13 @@ function formatAutoRunScheduleTime(timestamp) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setAutoRunDelayEnabledState(enabled) {
|
||||||
|
const normalized = Boolean(enabled);
|
||||||
|
await setPersistentSettings({ autoRunDelayEnabled: normalized });
|
||||||
|
await setState({ autoRunDelayEnabled: normalized });
|
||||||
|
broadcastDataUpdate({ autoRunDelayEnabled: normalized });
|
||||||
|
}
|
||||||
|
|
||||||
async function ensureScheduledAutoRunAlarm(scheduledAt) {
|
async function ensureScheduledAutoRunAlarm(scheduledAt) {
|
||||||
if (!Number.isFinite(scheduledAt) || scheduledAt <= Date.now()) {
|
if (!Number.isFinite(scheduledAt) || scheduledAt <= Date.now()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1274,6 +1281,9 @@ async function launchScheduledAutoRun(trigger = 'alarm') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await clearScheduledAutoRunAlarm();
|
await clearScheduledAutoRunAlarm();
|
||||||
|
if (trigger !== 'manual' && state.autoRunDelayEnabled) {
|
||||||
|
await setAutoRunDelayEnabledState(false);
|
||||||
|
}
|
||||||
await broadcastAutoRunStatus(
|
await broadcastAutoRunStatus(
|
||||||
'running',
|
'running',
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1223,6 +1223,13 @@ chrome.runtime.onMessage.addListener((message) => {
|
|||||||
displayLocalhostUrl.textContent = message.payload.localhostUrl;
|
displayLocalhostUrl.textContent = message.payload.localhostUrl;
|
||||||
displayLocalhostUrl.classList.add('has-value');
|
displayLocalhostUrl.classList.add('has-value');
|
||||||
}
|
}
|
||||||
|
if (message.payload.autoRunDelayEnabled !== undefined) {
|
||||||
|
inputAutoDelayEnabled.checked = Boolean(message.payload.autoRunDelayEnabled);
|
||||||
|
updateAutoDelayInputState();
|
||||||
|
}
|
||||||
|
if (message.payload.autoRunDelayMinutes !== undefined) {
|
||||||
|
inputAutoDelayMinutes.value = String(normalizeAutoDelayMinutes(message.payload.autoRunDelayMinutes));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user