diff --git a/README.md b/README.md index 6b97211..8f57d52 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,11 @@ Core installation, version comparison, and offline installation are available fr mirror proxies or add custom HTTPS mirror prefixes; application and core updates prefer the selected channel and fall back automatically. -Application and core updates are each checked once in the background at startup, then automatically -on every fifth visit to **Version Management** (visits 5, 10, 15, and so on). Their respective -**Check for Updates** buttons remain available for manual checks. Re-renders do not count as visits, -and restarting the application resets the counter. Changing download sources does not trigger a -check, and reopening the page preserves the saved source. Checks do not automatically download or -install updates. +Application and core updates are each checked once in the background at startup and automatically +whenever you enter **Version Management**. Their respective **Check for Updates** buttons remain +available for manual checks. Re-rendering the page does not trigger another check. Changing download +sources does not trigger a check, and reopening the page preserves the saved source. Checks do not +automatically download or install updates. ### OAuth account authorization diff --git a/README.zh-CN.md b/README.zh-CN.md index b092399..84dc3e3 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -47,7 +47,7 @@ APIMart 是一个低成本的 AI 图像与视频生成 API 平台——GPT-Image 内核安装、版本对比和离线安装功能位于 **版本管理** 页面;可在此切换 GitHub 官方源、GitCode 国内源或 GitHub 镜像代理,也可以添加自定义 HTTPS 镜像前缀。软件与内核更新会优先使用所选渠道,并在失败时自动回退。 -每次启动软件时,软件和内核会各自在后台自动检查一次更新;之后每进入 **版本管理** 页面 5 次(第 5、10、15 次,以此类推)自动检查一次,也可随时通过各自的 **检查更新** 按钮手动检查。页面内部刷新不重复计数,重启软件后次数归零。修改下载源不会自动检查更新,重新进入页面也会保留已保存的下载源。检查不会自动下载或安装更新。 +每次启动软件时,软件和内核会各自在后台自动检查一次更新;之后每次进入 **版本管理** 页面时,也会自动检查软件和内核更新。也可随时通过各自的 **检查更新** 按钮手动检查。页面重新渲染不会再次触发检查;修改下载源也不会自动检查更新,重新进入页面仍会保留已保存的下载源。检查不会自动下载或安装更新。 **版本管理** 页面同时展示当前界面语言的最新版软件更新说明,升级后仍可查看。发布者在 [`docs/release-notes/`](docs/release-notes/README.md) 中按版本分别编辑简体中文、繁体中文、英文和日文 Markdown,CI 生成的 GitHub Release 正文仅按英文、简体中文的顺序展示,应用更新清单保留四种语言中已编写的正文。当前语言的说明缺失时直接提示,不回退到其他语言。 diff --git a/src/services/versionManagementVisits.ts b/src/services/versionManagementVisits.ts index 3f6e115..dd52c0d 100644 --- a/src/services/versionManagementVisits.ts +++ b/src/services/versionManagementVisits.ts @@ -1,13 +1,9 @@ export function createVersionManagementVisitTracker() { - const countedVisits = new WeakSet(); - let visitsSinceLastCheck = 0; + const seenVisits = new WeakSet(); return (visit: object) => { - if (countedVisits.has(visit)) return false; - countedVisits.add(visit); - visitsSinceLastCheck += 1; - if (visitsSinceLastCheck < 5) return false; - visitsSinceLastCheck = 0; + if (seenVisits.has(visit)) return false; + seenVisits.add(visit); return true; }; } diff --git a/tests/versionManagement.test.ts b/tests/versionManagement.test.ts index 5f67460..5cbd583 100644 --- a/tests/versionManagement.test.ts +++ b/tests/versionManagement.test.ts @@ -9,34 +9,34 @@ import { coreUpdateAvailable } from '../src/coreUpdate'; import { appUpdateIndicatorState } from '../src/appUpdateModel'; import { createVersionManagementVisitTracker } from '../src/services/versionManagementVisits'; -describe('VersionManagement visit counting', () => { - it('checks on the fifth, tenth, and fifteenth visits, but not in between', () => { +describe('VersionManagement visit checks', () => { + it('checks on every new page visit', () => { const recordVisit = createVersionManagementVisitTracker(); const checkedVisits: number[] = []; for (let visitNumber = 1; visitNumber <= 15; visitNumber += 1) { if (recordVisit({})) checkedVisits.push(visitNumber); } - expect(checkedVisits).toEqual([5, 10, 15]); + expect(checkedVisits).toEqual(Array.from({ length: 15 }, (_, index) => index + 1)); }); - it('counts each mounted page once despite repeated effects or re-renders', () => { + it('checks each mounted page once despite repeated effects or re-renders', () => { const recordVisit = createVersionManagementVisitTracker(); for (let visitNumber = 1; visitNumber <= 10; visitNumber += 1) { const visit = {}; - expect(recordVisit(visit)).toBe(visitNumber % 5 === 0); + expect(recordVisit(visit)).toBe(true); expect(recordVisit(visit)).toBe(false); expect(recordVisit(visit)).toBe(false); } }); - it('starts counting from zero for a new application session', () => { + it('starts with no recorded visits for a new application session', () => { const recordVisit = createVersionManagementVisitTracker(); - for (let visitNumber = 1; visitNumber <= 4; visitNumber += 1) { - expect(recordVisit({})).toBe(false); - } + const visit = {}; + expect(recordVisit(visit)).toBe(true); + expect(recordVisit(visit)).toBe(false); const recordNewSessionVisit = createVersionManagementVisitTracker(); - expect(recordNewSessionVisit({})).toBe(false); - expect(recordVisit({})).toBe(true); + expect(recordNewSessionVisit(visit)).toBe(true); + expect(recordNewSessionVisit(visit)).toBe(false); }); });