Skip to content

feat: 支持每日定时检查更新 - #399

Open
moranfanhua wants to merge 2 commits into
MaaXYZ:mainfrom
moranfanhua:feat/scheduled-update-check
Open

moranfanhua wants to merge 2 commits into
MaaXYZ:mainfrom
moranfanhua:feat/scheduled-update-check

Conversation

@moranfanhua

@moranfanhua moranfanhua commented Oct 23, 2026 •

Copy link
Copy Markdown

close: #358,ref: MaaEnd/MaaEnd#5326

Sourcery 总结

支持从桌面应用程序启用可选的每日更新检查,并提供可配置的计划安排和持久化设置。

新功能:

  • 添加可选的每日自动更新检查,并允许用户配置本地时间。
  • 添加设置控件,以启用计划检查并选择每日检查时间。

增强功能:

  • 启动时检查和计划检查共用更新结果处理流程,同时避免重复或冲突的更新操作。
  • 持久化并验证计划更新设置,并为所有受支持的语言提供本地化标签。
Original summary in English

Sourcery 摘要

为桌面应用启用可配置的每日更新检查,并使其与现有更新流程协调运行。

新功能:

  • 添加可选的每日更新检查,可在设置中启用并安排本地时间。
  • 在支持的语言中保存并本地化已安排的更新检查偏好设置。

改进:

  • 统一处理启动时和定时更新检查的结果,同时避免重复检查以及与正在进行的更新操作发生冲突。
  • 验证定时检查时间,并安全地从现有配置中恢复设置。
Original summary in English

Summary by Sourcery

Enable configurable daily update checks for the desktop application while coordinating them with existing update flows.

New Features:

  • Add an optional daily update check that can be enabled and scheduled for a local time from the settings.
  • Persist and localize the scheduled update check preferences across supported languages.

Enhancements:

  • Unify startup and scheduled update result handling while preventing duplicate checks and conflicts with active update operations.
  • Validate scheduled check times and restore the settings safely from existing configuration.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗨——我发现了 2 个问题

提供给 AI 智能体的提示
请处理此代码审查中的评论:

## 单条评论

### 评论 1
<location path="src/App.tsx" line_range="564" />
<code_context>
+    };
+
+    const checkForScheduledUpdate = async () => {
+      if (scheduledUpdateCheckInProgressRef.current || isUpdateBusy()) return;
+      scheduledUpdateCheckInProgressRef.current = true;
+      const { mirrorChyanSettings, proxySettings } = useAppStore.getState();
</code_context>
<issue_to_address>
**手动检查结果会被覆盖**

当计划检查请求正在进行时启动手动检查,并且手动检查先完成,`checkForScheduledUpdate` 并未设置 `updateCheckLoading`,因此手动检查仍处于可用状态;手动检查结果可能先返回,随后计划检查结果传入 `handleAutoUpdateCheckResult` 并覆盖手动检查结果,或意外启动自动下载。调用方会看到相互冲突的结果,或发生未经请求的下载。

为计划检查发布一个共享的进行中状态,防止手动检查与其发生竞争。
</issue_to_address>

### 评论 2
<location path="src/stores/appStore.ts" line_range="1385-1386" />
<code_context>
         confirmBeforeDelete: config.settings.confirmBeforeDelete ?? false,
         maxLogsPerInstance: config.settings.maxLogsPerInstance ?? DEFAULT_MAX_LOGS_PER_INSTANCE,
         autoClearLogsOnLaunch: config.settings.autoClearLogsOnLaunch ?? true,
+        scheduledUpdateCheckEnabled: config.settings.scheduledUpdateCheckEnabled === true,
+        scheduledUpdateCheckTime: normalizeScheduledUpdateCheckTime(
+          config.settings.scheduledUpdateCheckTime,
+        ),
</code_context>
<issue_to_address>
**计划检查偏好设置会丢失**

当保存的配置中没有任何实例时,`loadInterface` 会跳过 `importConfig(config)`,因此计划检查设置会保留默认值;重启后,计划检查会被禁用,保存的时间也可能丢失。

即使配置中没有实例,也要加载计划检查设置。
</issue_to_address>

Sourcery 为开源项目免费提供服务——如果您喜欢我们的审查结果,欢迎分享 ✨
Original comment in English

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/App.tsx" line_range="564" />
<code_context>
+    };
+
+    const checkForScheduledUpdate = async () => {
+      if (scheduledUpdateCheckInProgressRef.current || isUpdateBusy()) return;
+      scheduledUpdateCheckInProgressRef.current = true;
+      const { mirrorChyanSettings, proxySettings } = useAppStore.getState();
</code_context>
<issue_to_address>
**Manual results get overwritten**

When a manual check starts while a scheduled request is in flight and finishes first, `checkForScheduledUpdate` does not set `updateCheckLoading`, so the manual check remains enabled; its result can finish first, after which the scheduled result reaches `handleAutoUpdateCheckResult` and overwrites it or starts an unexpected automatic download. The caller sees conflicting results or an unrequested download.

Publish a shared in-progress state for scheduled checks so manual checks cannot race with them.
</issue_to_address>

### Comment 2
<location path="src/stores/appStore.ts" line_range="1385-1386" />
<code_context>
         confirmBeforeDelete: config.settings.confirmBeforeDelete ?? false,
         maxLogsPerInstance: config.settings.maxLogsPerInstance ?? DEFAULT_MAX_LOGS_PER_INSTANCE,
         autoClearLogsOnLaunch: config.settings.autoClearLogsOnLaunch ?? true,
+        scheduledUpdateCheckEnabled: config.settings.scheduledUpdateCheckEnabled === true,
+        scheduledUpdateCheckTime: normalizeScheduledUpdateCheckTime(
+          config.settings.scheduledUpdateCheckTime,
+        ),
</code_context>
<issue_to_address>
**Scheduled preferences are lost**

When the saved configuration has no instances, `loadInterface` skips `importConfig(config)`, so the scheduled-check settings stay at their defaults; after restart, scheduled checks are disabled and the saved time can be lost.

Load the scheduled-check settings even when the configuration has no instances.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/App.tsx Outdated
Comment thread src/stores/appStore.ts
- 在更新设置中增加定时检查开关,默认关闭,时间默认为 08:00
- 将开关和时间独立保存到应用设置,修改后立即重排每日检查
- 复用更新结果处理,保持原有启动检查及自动任务挂起行为
- 仅为定时入口增加并发与参数变化校验,并同步五种语言文案

关联 MaaXYZ#358

验证:构建、类型及格式检查通过,启动逻辑通过与原代码的 16 种模拟场景对照。
@moranfanhua
moranfanhua force-pushed the feat/scheduled-update-check branch from 736a063 to 5a4c3e9 Compare October 23, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

是否需要为检查更新添加定时触发器

1 participant