mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
Merge pull request #347 from cddjr/feat_nettest
feat 网络测试支持GitHub加速代理、新增pip测试
This commit is contained in:
@@ -8,6 +8,7 @@ import tmdb from '@images/logos/tmdb.png'
|
|||||||
import wechat from '@images/logos/wechat.png'
|
import wechat from '@images/logos/wechat.png'
|
||||||
import fanart from '@images/logos/fanart.webp'
|
import fanart from '@images/logos/fanart.webp'
|
||||||
import tvdb from '@images/logos/thetvdb.jpeg'
|
import tvdb from '@images/logos/thetvdb.jpeg'
|
||||||
|
import plugin from '@images/logos/plugin.png'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
// 国际化
|
// 国际化
|
||||||
@@ -29,6 +30,7 @@ interface Address {
|
|||||||
time: string
|
time: string
|
||||||
message: string
|
message: string
|
||||||
btndisable: boolean
|
btndisable: boolean
|
||||||
|
include?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试集
|
// 测试集
|
||||||
@@ -46,7 +48,7 @@ const targets = ref<Address[]>([
|
|||||||
{
|
{
|
||||||
image: tmdb,
|
image: tmdb,
|
||||||
name: 'api.tmdb.org',
|
name: 'api.tmdb.org',
|
||||||
url: 'https://api.tmdb.org',
|
url: 'https://api.tmdb.org/3/movie/550?api_key={TMDBAPIKEY}',
|
||||||
proxy: true,
|
proxy: true,
|
||||||
status: 'Normal',
|
status: 'Normal',
|
||||||
time: '',
|
time: '',
|
||||||
@@ -123,10 +125,32 @@ const targets = ref<Address[]>([
|
|||||||
message: t('netTest.notTested'),
|
message: t('netTest.notTested'),
|
||||||
btndisable: false,
|
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,
|
image: github,
|
||||||
name: 'github.com',
|
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,
|
proxy: true,
|
||||||
status: 'Normal',
|
status: 'Normal',
|
||||||
time: '',
|
time: '',
|
||||||
@@ -146,12 +170,13 @@ const targets = ref<Address[]>([
|
|||||||
{
|
{
|
||||||
image: github,
|
image: github,
|
||||||
name: 'raw.githubusercontent.com',
|
name: 'raw.githubusercontent.com',
|
||||||
url: 'https://raw.githubusercontent.com',
|
url: '{GITHUB_PROXY}https://raw.githubusercontent.com/jxxghp/MoviePilot/v2/README.md',
|
||||||
proxy: true,
|
proxy: true,
|
||||||
status: 'Normal',
|
status: 'Normal',
|
||||||
time: '',
|
time: '',
|
||||||
message: t('netTest.notTested'),
|
message: t('netTest.notTested'),
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
|
include: 'MoviePilot',
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -162,9 +187,15 @@ const resolveStatusColor: Status = {
|
|||||||
Doing: 'warning',
|
Doing: 'warning',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const abortControllers = new Set<AbortController>()
|
||||||
|
const isUnmounting = ref(false);
|
||||||
|
|
||||||
// 调用API测试网络连接
|
// 调用API测试网络连接
|
||||||
async function netTest(index: number) {
|
async function netTest(index: number) {
|
||||||
try {
|
try {
|
||||||
|
const abortController = new AbortController()
|
||||||
|
abortControllers.add(abortController)
|
||||||
|
const { signal } = abortController
|
||||||
const target = targets.value[index]
|
const target = targets.value[index]
|
||||||
|
|
||||||
target.btndisable = true
|
target.btndisable = true
|
||||||
@@ -175,9 +206,13 @@ async function netTest(index: number) {
|
|||||||
params: {
|
params: {
|
||||||
url: target.url,
|
url: target.url,
|
||||||
proxy: target.proxy,
|
proxy: target.proxy,
|
||||||
|
include: target.include,
|
||||||
},
|
},
|
||||||
|
signal,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
abortControllers.delete(abortController)
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
target.status = 'OK'
|
target.status = 'OK'
|
||||||
target.message = t('netTest.normal')
|
target.message = t('netTest.normal')
|
||||||
@@ -194,8 +229,17 @@ async function netTest(index: number) {
|
|||||||
|
|
||||||
// 加载时测试所有连接
|
// 加载时测试所有连接
|
||||||
onMounted(async () => {
|
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()
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in New Issue
Block a user