Skip to content

Commit a205393

Browse files
committed
fix(settings): stabilize update check status
1 parent 833077a commit a205393

File tree

5 files changed

+48
-49
lines changed

5 files changed

+48
-49
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 4.9.2 - 2026-04-12
4+
5+
- 设置页首次自动检查更新时不再让“检查更新”按钮自己持续转圈。
6+
- 移除会反复闪烁的“正在整理结果”提示,避免用户误以为页面异常。
7+
- 手动点击“检查更新”时才显示按钮转圈,状态反馈与用户操作保持一致。
8+
39
## 4.9.1 - 2026-04-12
410

511
- 移除仅支持 Node.js 的 `/api/site-icon` 路由,避免 `next-on-pages` 因非 Edge 路由中止构建。

app-release.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@
44
"name": "KVideo",
55
"branch": "main"
66
},
7-
"currentVersion": "4.9.1",
7+
"currentVersion": "4.9.2",
88
"releases": [
9+
{
10+
"version": "4.9.2",
11+
"publishedAt": "2026-04-12",
12+
"title": "修复检查更新状态闪烁",
13+
"notes": [
14+
"设置页首次自动检查更新时不再让“检查更新”按钮自己持续转圈。",
15+
"移除会反复闪烁的“正在整理结果”提示,避免用户误以为页面异常。",
16+
"手动点击“检查更新”时才显示按钮转圈,状态反馈与用户操作保持一致。"
17+
]
18+
},
919
{
1020
"version": "4.9.1",
1121
"publishedAt": "2026-04-12",

components/settings/AppVersionSettings.tsx

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import Link from 'next/link';
4-
import { useEffect, useEffectEvent, useState, useTransition } from 'react';
4+
import { useEffect, useEffectEvent, useState } from 'react';
55
import { ExternalLink, RefreshCw } from 'lucide-react';
66
import { SettingsSection } from './SettingsSection';
77
import type { AppReleaseEntry, AppUpdateResponse } from '@/lib/types/app-update';
@@ -107,11 +107,12 @@ function ReleaseNotesBlock({
107107
export function AppVersionSettings() {
108108
const [data, setData] = useState<AppUpdateResponse | null>(null);
109109
const [hasLoaded, setHasLoaded] = useState(false);
110-
const [isPending, startTransition] = useTransition();
111110
const [isRefreshing, setIsRefreshing] = useState(false);
112111

113-
const fetchUpdateInfo = useEffectEvent(async () => {
114-
setIsRefreshing(true);
112+
const fetchUpdateInfo = useEffectEvent(async (manual: boolean = false) => {
113+
if (manual) {
114+
setIsRefreshing(true);
115+
}
115116

116117
try {
117118
const response = await fetch('/api/app-update', {
@@ -126,53 +127,36 @@ export function AppVersionSettings() {
126127
}
127128

128129
const payload = (await response.json()) as AppUpdateResponse;
129-
130-
startTransition(() => {
131-
setData(payload);
132-
setHasLoaded(true);
133-
});
130+
setData(payload);
131+
setHasLoaded(true);
132+
} catch (error) {
133+
setHasLoaded(true);
134+
setData((previous) => ({
135+
currentVersion: previous?.currentVersion || '未知',
136+
currentRelease: previous?.currentRelease || null,
137+
latestVersion: previous?.latestVersion || previous?.currentVersion || '未知',
138+
latestRelease: previous?.latestRelease || previous?.currentRelease || null,
139+
status: 'check-failed',
140+
updateAvailable: false,
141+
checkedAt: new Date().toISOString(),
142+
checkedRemotely: false,
143+
usedRemoteManifest: false,
144+
source: previous?.source || DEFAULT_SOURCE,
145+
error: error instanceof Error ? error.message : '未知错误',
146+
}));
134147
} finally {
135-
setIsRefreshing(false);
148+
if (manual) {
149+
setIsRefreshing(false);
150+
}
136151
}
137152
});
138153

139154
useEffect(() => {
140-
void fetchUpdateInfo().catch((error) => {
141-
startTransition(() => {
142-
setHasLoaded(true);
143-
setData((previous) => ({
144-
currentVersion: previous?.currentVersion || '未知',
145-
currentRelease: previous?.currentRelease || null,
146-
latestVersion: previous?.latestVersion || previous?.currentVersion || '未知',
147-
latestRelease: previous?.latestRelease || previous?.currentRelease || null,
148-
status: 'check-failed',
149-
updateAvailable: false,
150-
checkedAt: new Date().toISOString(),
151-
checkedRemotely: false,
152-
usedRemoteManifest: false,
153-
source: previous?.source || DEFAULT_SOURCE,
154-
error: error instanceof Error ? error.message : '未知错误',
155-
}));
156-
});
157-
});
158-
}, [fetchUpdateInfo, startTransition]);
155+
void fetchUpdateInfo(false);
156+
}, []);
159157

160158
const handleRefresh = () => {
161-
void fetchUpdateInfo().catch((error) => {
162-
startTransition(() => {
163-
setData((previous) =>
164-
previous
165-
? {
166-
...previous,
167-
status: 'check-failed',
168-
error: error instanceof Error ? error.message : '未知错误',
169-
checkedAt: new Date().toISOString(),
170-
}
171-
: previous,
172-
);
173-
setHasLoaded(true);
174-
});
175-
});
159+
void fetchUpdateInfo(true);
176160
};
177161

178162
const statusMeta = getStatusMeta(data);
@@ -215,7 +199,6 @@ export function AppVersionSettings() {
215199
<p className="mt-3 text-sm text-[var(--text-color-secondary)]">{statusMeta.description}</p>
216200
<p className="mt-2 text-xs text-[var(--text-color-secondary)]">
217201
上次检查:{hasLoaded ? formatDateLabel(data?.checkedAt) : '正在检查'}
218-
{isPending ? '(正在整理结果)' : ''}
219202
</p>
220203
</div>
221204
</div>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kvideo",
3-
"version": "4.9.1",
3+
"version": "4.9.2",
44
"private": true,
55
"scripts": {
66
"dev": "next dev --port ${PORT:-3000}",

0 commit comments

Comments
 (0)