From 33ac322bb27d25cdebd3966c75f462bad1f22c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B7=9D=E7=99=BD=E6=B5=AA?= <1679659@qq.com> Date: Sun, 29 Nov 2026 01:43:08 -0700 Subject: [PATCH] fix(net): honor Windows system proxy, fall back on GitHub rate limit, and add UI retry --- frontend/src/components/RuntimeOnline.tsx | 16 ++- frontend/src/i18n.ts | 4 + internal/installer/oc_cache.go | 4 +- internal/netproxy/proxy.go | 145 ++++++++++++++++++++ internal/netproxy/proxy_test.go | 65 +++++++++ internal/netproxy/system_other.go | 12 ++ internal/netproxy/system_windows.go | 38 +++++ internal/runtime/remote.go | 160 +++++++++++++++++++++- internal/runtime/remote_test.go | 61 +++++++++ internal/version/version.go | 11 +- 10 files changed, 508 insertions(+), 8 deletions(-) create mode 100644 internal/netproxy/proxy.go create mode 100644 internal/netproxy/proxy_test.go create mode 100644 internal/netproxy/system_other.go create mode 100644 internal/netproxy/system_windows.go diff --git a/frontend/src/components/RuntimeOnline.tsx b/frontend/src/components/RuntimeOnline.tsx index 8c80b8e..2991d56 100644 --- a/frontend/src/components/RuntimeOnline.tsx +++ b/frontend/src/components/RuntimeOnline.tsx @@ -1,4 +1,4 @@ -import { Download, LoaderCircle, Pause } from 'lucide-react' +import { Download, LoaderCircle, Pause, RefreshCw } from 'lucide-react' import React, { useEffect, useState } from 'react' import { I18nKey, t } from '../i18n' import { taskDetail } from '../lib/tasks' @@ -29,6 +29,7 @@ export const RuntimeOnline: React.FC = ({ locale, channel, installed, tas const tr = (k: I18nKey, v?: Record) => t(locale, k, v) const [remote, setRemote] = useState(null) const [error, setError] = useState('') + const [reload, setReload] = useState(0) useEffect(() => { let live = true @@ -38,7 +39,7 @@ export const RuntimeOnline: React.FC = ({ locale, channel, installed, tas .then((list) => { if (live) setRemote(list ?? []) }) .catch((e) => { if (live) setError(String(e).replace(/^Error:\s*/, '')) }) return () => { live = false } - }, [channel, task?.status === 'done']) + }, [channel, task?.status === 'done', reload]) const active = installed.find((i) => i.active) ?? installed[0] const latest = remote?.[0] @@ -63,7 +64,9 @@ export const RuntimeOnline: React.FC = ({ locale, channel, installed, tas } else if (active && !updatable) { sub =
{shortQemu(active.manifest.qemu_version)}
} else if (error) { - sub =
{tr('runtimeLookupFailed')}
+ const isRateLimit = /rate limit|HTTP 403|HTTP 429/i.test(error) + const msg = isRateLimit ? tr('runtimeLookupRateLimit') : `${tr('runtimeLookupFailed')}: ${error}` + sub =
{msg}
} else if (!remote) { sub =
…
} else if (!latest) { @@ -72,7 +75,8 @@ export const RuntimeOnline: React.FC = ({ locale, channel, installed, tas sub = (
{active ? tr('runtimeNewer', { v: latest.commit }) : tr('runtimeLatest', { v: latest.commit })} - {' · '}{tr(`runtimeChannel_${latest.channel}` as I18nKey)} · {gb(latest.archive_size)} + {' · '}{tr(`runtimeChannel_${latest.channel}` as I18nKey)} + {latest.archive_size > 0 ? ` · ${gb(latest.archive_size)}` : ''}
) } @@ -89,6 +93,10 @@ export const RuntimeOnline: React.FC = ({ locale, channel, installed, tas
{running && task?.cancelable ? ( } onClick={() => onCancel(task.id)} /> + ) : !running && error ? ( + ) : !running && updatable ? (