mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
fix nettest
This commit is contained in:
@@ -11,6 +11,7 @@ interface Status {
|
|||||||
OK: string;
|
OK: string;
|
||||||
Fail: string;
|
Fail: string;
|
||||||
Normal: string;
|
Normal: string;
|
||||||
|
Doing?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Address {
|
interface Address {
|
||||||
@@ -21,7 +22,6 @@ interface Address {
|
|||||||
status: keyof Status;
|
status: keyof Status;
|
||||||
time: string;
|
time: string;
|
||||||
message: string;
|
message: string;
|
||||||
btntext: string;
|
|
||||||
btndisable: boolean;
|
btndisable: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,12 +30,11 @@ const targets = ref<Address[]>([
|
|||||||
{
|
{
|
||||||
image: tmdb,
|
image: tmdb,
|
||||||
name: "api.themoviedb.org",
|
name: "api.themoviedb.org",
|
||||||
url: "https://api.themoviedb.org/docs",
|
url: "https://api.themoviedb.org/3/movie/550?api_key={TMDBAPIKEY}",
|
||||||
proxy: true,
|
proxy: true,
|
||||||
status: "Normal",
|
status: "Normal",
|
||||||
time: "",
|
time: "",
|
||||||
message: "",
|
message: "",
|
||||||
btntext: "测试",
|
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -46,7 +45,6 @@ const targets = ref<Address[]>([
|
|||||||
status: "Normal",
|
status: "Normal",
|
||||||
time: "",
|
time: "",
|
||||||
message: "未测试",
|
message: "未测试",
|
||||||
btntext: "测试",
|
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -57,7 +55,6 @@ const targets = ref<Address[]>([
|
|||||||
status: "Normal",
|
status: "Normal",
|
||||||
time: "",
|
time: "",
|
||||||
message: "未测试",
|
message: "未测试",
|
||||||
btntext: "测试",
|
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,7 +65,6 @@ const targets = ref<Address[]>([
|
|||||||
status: "Normal",
|
status: "Normal",
|
||||||
time: "",
|
time: "",
|
||||||
message: "未测试",
|
message: "未测试",
|
||||||
btntext: "测试",
|
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -79,7 +75,6 @@ const targets = ref<Address[]>([
|
|||||||
status: "Normal",
|
status: "Normal",
|
||||||
time: "",
|
time: "",
|
||||||
message: "未测试",
|
message: "未测试",
|
||||||
btntext: "测试",
|
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -90,7 +85,6 @@ const targets = ref<Address[]>([
|
|||||||
status: "Normal",
|
status: "Normal",
|
||||||
time: "",
|
time: "",
|
||||||
message: "未测试",
|
message: "未测试",
|
||||||
btntext: "测试",
|
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -101,7 +95,6 @@ const targets = ref<Address[]>([
|
|||||||
status: "Normal",
|
status: "Normal",
|
||||||
time: "",
|
time: "",
|
||||||
message: "未测试",
|
message: "未测试",
|
||||||
btntext: "测试",
|
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -112,7 +105,6 @@ const targets = ref<Address[]>([
|
|||||||
status: "Normal",
|
status: "Normal",
|
||||||
time: "",
|
time: "",
|
||||||
message: "未测试",
|
message: "未测试",
|
||||||
btntext: "测试",
|
|
||||||
btndisable: false,
|
btndisable: false,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -121,14 +113,16 @@ const resolveStatusColor: Status = {
|
|||||||
OK: "success",
|
OK: "success",
|
||||||
Fail: "error",
|
Fail: "error",
|
||||||
Normal: "",
|
Normal: "",
|
||||||
|
Doing: "warning",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 调用API测试网络连接
|
// 调用API测试网络连接
|
||||||
const netTest = async (index: number) => {
|
const netTest = async (index: number) => {
|
||||||
try {
|
try {
|
||||||
const target = targets.value[index];
|
const target = targets.value[index];
|
||||||
target.btntext = "测试中...";
|
|
||||||
target.btndisable = true;
|
target.btndisable = true;
|
||||||
|
target.status = "Doing";
|
||||||
|
target.message = "测试中...";
|
||||||
const result: { [key: string]: any } = await api.get("system/nettest", {
|
const result: { [key: string]: any } = await api.get("system/nettest", {
|
||||||
params: {
|
params: {
|
||||||
url: target.url,
|
url: target.url,
|
||||||
@@ -143,7 +137,6 @@ const netTest = async (index: number) => {
|
|||||||
target.message = result.message;
|
target.message = result.message;
|
||||||
}
|
}
|
||||||
target.time = result.data?.time;
|
target.time = result.data?.time;
|
||||||
target.btntext = "测试";
|
|
||||||
target.btndisable = false;
|
target.btndisable = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -183,8 +176,12 @@ onMounted(async () => {
|
|||||||
</span>
|
</span>
|
||||||
</VListItemSubtitle>
|
</VListItemSubtitle>
|
||||||
<template #append>
|
<template #append>
|
||||||
<VBtn size="small" @click="netTest(index)" :disabled="target.btndisable">
|
<VBtn
|
||||||
{{ target.btntext }}
|
size="small"
|
||||||
|
icon="mdi-connection"
|
||||||
|
@click="netTest(index)"
|
||||||
|
:disabled="target.btndisable"
|
||||||
|
>
|
||||||
</VBtn>
|
</VBtn>
|
||||||
</template>
|
</template>
|
||||||
</VListItem>
|
</VListItem>
|
||||||
|
|||||||
Reference in New Issue
Block a user