From 583ece0a6401a721bc9ad40a84ad1e1b51a77901 Mon Sep 17 00:00:00 2001 From: Memory <134070804+Memory2314@users.noreply.github.com> Date: Tue, 25 Nov 2025 22:21:14 +0800 Subject: [PATCH] feat: support disabling autoupdate --- src/main/config/profile.ts | 1 + src/main/core/profileUpdater.ts | 6 +- .../components/profiles/edit-info-modal.tsx | 125 ++++++++++-------- src/renderer/src/locales/en-US.json | 1 + src/renderer/src/locales/zh-CN.json | 1 + src/shared/types.d.ts | 1 + 6 files changed, 76 insertions(+), 59 deletions(-) diff --git a/src/main/config/profile.ts b/src/main/config/profile.ts index 06557a6..9ec6796 100644 --- a/src/main/config/profile.ts +++ b/src/main/config/profile.ts @@ -141,6 +141,7 @@ export async function createProfile(item: Partial): Promise { const currentItem = await getCurrentProfileItem() for (const item of items.filter((i) => i.id !== current)) { - if (item.type === 'remote' && item.interval) { + if (item.type === 'remote' && item.autoUpdate && item.interval) { if (typeof item.interval === 'number') { // 数字间隔使用setInterval intervalPool[item.id] = setInterval( @@ -40,7 +40,7 @@ export async function initProfileUpdater(): Promise { } } - if (currentItem?.type === 'remote' && currentItem.interval) { + if (currentItem?.type === 'remote' && currentItem.autoUpdate && currentItem.interval) { if (typeof currentItem.interval === 'number') { intervalPool[currentItem.id] = setInterval( async () => { @@ -82,7 +82,7 @@ export async function initProfileUpdater(): Promise { } export async function addProfileUpdater(item: IProfileItem): Promise { - if (item.type === 'remote' && item.interval) { + if (item.type === 'remote' && item.autoUpdate && item.interval) { if (intervalPool[item.id]) { if (intervalPool[item.id] instanceof Cron) { (intervalPool[item.id] as Cron).stop() diff --git a/src/renderer/src/components/profiles/edit-info-modal.tsx b/src/renderer/src/components/profiles/edit-info-modal.tsx index cfea1f6..1d56612 100644 --- a/src/renderer/src/components/profiles/edit-info-modal.tsx +++ b/src/renderer/src/components/profiles/edit-info-modal.tsx @@ -100,68 +100,81 @@ const EditInfoModal: React.FC = (props) => { }} /> - -
- { - // 输入限制 - if (/^[\d\s*\-,\/]*$/.test(v)) { - // 纯数字 - if (/^\d+$/.test(v)) { - setValues({ ...values, interval: parseInt(v, 10) || 0 }); - return; - } - // 非纯数字 - try { - setValues({ ...values, interval: v }); - } catch (e) { - // ignore - } - } - }} - placeholder={t('profiles.editInfo.intervalPlaceholder')} - /> - - {/* 动态提示信息 */} -
- {typeof values.interval === 'number' ? ( - t('profiles.editInfo.intervalMinutes') - ) : /^\d+$/.test(values.interval?.toString() || '') ? ( - t('profiles.editInfo.intervalMinutes') - ) : isValidCron(values.interval?.toString() || '', { seconds: false }) ? ( - t('profiles.editInfo.intervalCron') - ) : ( - t('profiles.editInfo.intervalHint') - )} -
-
-
- + { - setValues({ ...values, allowFixedInterval: v }) + setValues({ ...values, autoUpdate: v }) }} /> + {values.autoUpdate && ( + <> + +
+ { + // 输入限制 + if (/^[\d\s*\-,\/]*$/.test(v)) { + // 纯数字 + if (/^\d+$/.test(v)) { + setValues({ ...values, interval: parseInt(v, 10) || 0 }); + return; + } + // 非纯数字 + try { + setValues({ ...values, interval: v }); + } catch (e) { + // ignore + } + } + }} + placeholder={t('profiles.editInfo.intervalPlaceholder')} + /> + + {/* 动态提示信息 */} +
+ {typeof values.interval === 'number' ? ( + t('profiles.editInfo.intervalMinutes') + ) : /^\d+$/.test(values.interval?.toString() || '') ? ( + t('profiles.editInfo.intervalMinutes') + ) : isValidCron(values.interval?.toString() || '', { seconds: false }) ? ( + t('profiles.editInfo.intervalCron') + ) : ( + t('profiles.editInfo.intervalHint') + )} +
+
+
+ + { + setValues({ ...values, allowFixedInterval: v }) + }} + /> + + + )} )} diff --git a/src/renderer/src/locales/en-US.json b/src/renderer/src/locales/en-US.json index ebcbdcb..bb3dd3e 100644 --- a/src/renderer/src/locales/en-US.json +++ b/src/renderer/src/locales/en-US.json @@ -446,6 +446,7 @@ "profiles.editInfo.intervalCron": "Valid Cron expression", "profiles.editInfo.intervalHint": "Please enter a number or a valid Cron expression (e.g.: 0 * * * *)", "profiles.editInfo.fixedInterval": "Fixed Update Interval", + "profiles.editInfo.autoUpdate": "Auto Update", "profiles.editInfo.override.title": "Override", "profiles.editInfo.override.global": "Global", "profiles.editInfo.override.noAvailable": "No available overrides", diff --git a/src/renderer/src/locales/zh-CN.json b/src/renderer/src/locales/zh-CN.json index a46053b..d2dea9e 100644 --- a/src/renderer/src/locales/zh-CN.json +++ b/src/renderer/src/locales/zh-CN.json @@ -451,6 +451,7 @@ "profiles.editInfo.intervalCron": "有效的Cron表达式", "profiles.editInfo.intervalHint": "请输入数字或合法的Cron表达式(如:0 * * * *)", "profiles.editInfo.fixedInterval": "固定更新间隔", + "profiles.editInfo.autoUpdate": "自动更新", "profiles.editInfo.override.title": "覆写", "profiles.editInfo.override.global": "全局", "profiles.editInfo.override.noAvailable": "没有可用的覆写", diff --git a/src/shared/types.d.ts b/src/shared/types.d.ts index e7e975d..b74b825 100644 --- a/src/shared/types.d.ts +++ b/src/shared/types.d.ts @@ -491,6 +491,7 @@ interface IProfileItem { extra?: ISubscriptionUserInfo substore?: boolean allowFixedInterval?: boolean + autoUpdate?: boolean } interface ISubStoreSub {