From e9160ecefd68360ceebad04551f7fa32d1cd23f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A7=E4=BE=A0?= Date: Fri, 13 Jun 2025 18:38:59 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E7=BD=91=E7=BB=9C=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81GitHub=E5=8A=A0=E9=80=9F=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E3=80=81=E6=96=B0=E5=A2=9Epip=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/NetTestView.vue | 52 +++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/src/views/system/NetTestView.vue b/src/views/system/NetTestView.vue index 26a452a6..4af04e57 100644 --- a/src/views/system/NetTestView.vue +++ b/src/views/system/NetTestView.vue @@ -8,6 +8,7 @@ import tmdb from '@images/logos/tmdb.png' import wechat from '@images/logos/wechat.png' import fanart from '@images/logos/fanart.webp' import tvdb from '@images/logos/thetvdb.jpeg' +import plugin from '@images/logos/plugin.png' import { useI18n } from 'vue-i18n' // 国际化 @@ -29,6 +30,7 @@ interface Address { time: string message: string btndisable: boolean + include?: string } // 测试集 @@ -46,7 +48,7 @@ const targets = ref([ { image: tmdb, name: 'api.tmdb.org', - url: 'https://api.tmdb.org', + url: 'https://api.tmdb.org/3/movie/550?api_key={TMDBAPIKEY}', proxy: true, status: 'Normal', time: '', @@ -123,10 +125,32 @@ const targets = ref([ message: t('netTest.notTested'), btndisable: false, }, + { + image: plugin, + name: 'pip', + url: '{PIP_PROXY}rsa/', + proxy: true, + status: 'Normal', + time: '', + message: t('netTest.notTested'), + btndisable: false, + include: 'pypi:repository-version', + }, { image: github, name: 'github.com', - url: 'https://github.com', + url: '{GITHUB_PROXY}https://github.com/jxxghp/MoviePilot/blob/v2/README.md', + proxy: true, + status: 'Normal', + time: '', + message: t('netTest.notTested'), + btndisable: false, + include: 'MoviePilot', + }, + { + image: github, + name: 'codeload.github.com', + url: 'https://codeload.github.com', proxy: true, status: 'Normal', time: '', @@ -146,12 +170,13 @@ const targets = ref([ { image: github, name: 'raw.githubusercontent.com', - url: 'https://raw.githubusercontent.com', + url: '{GITHUB_PROXY}https://raw.githubusercontent.com/jxxghp/MoviePilot/v2/README.md', proxy: true, status: 'Normal', time: '', message: t('netTest.notTested'), btndisable: false, + include: 'MoviePilot', }, ]) @@ -162,9 +187,15 @@ const resolveStatusColor: Status = { Doing: 'warning', } +const abortControllers = new Set() +const isUnmounting = ref(false); + // 调用API测试网络连接 async function netTest(index: number) { try { + const abortController = new AbortController() + abortControllers.add(abortController) + const { signal } = abortController const target = targets.value[index] target.btndisable = true @@ -175,9 +206,13 @@ async function netTest(index: number) { params: { url: target.url, proxy: target.proxy, + include: target.include, }, + signal, }) + abortControllers.delete(abortController) + if (result.success) { target.status = 'OK' target.message = t('netTest.normal') @@ -194,8 +229,17 @@ async function netTest(index: number) { // 加载时测试所有连接 onMounted(async () => { - for (let i = 0; i < targets.value.length; i++) await netTest(i) + isUnmounting.value = false; + for (let i = 0; !isUnmounting.value && i < targets.value.length; i++) + await netTest(i) }) +onBeforeUnmount(() => { + isUnmounting.value = true; + for (const controller of abortControllers) { + controller.abort() + } + abortControllers.clear() +});