Skip to content

Commit

Permalink
添加检查超时检测
Browse files Browse the repository at this point in the history
  • Loading branch information
ljxi committed Dec 17, 2023
1 parent 971a157 commit d5a21b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ const checkUrl = async (url: string) => {
if (structUrl.host.indexOf("ljxnet.cn") + structUrl.host.indexOf("netart.cn") != -2) {
throw '你不对劲,我要拿小本本把你记下来然后交给警察蜀黍!'
}
const response = await fetch(url, { cache: "no-store", mode: 'cors', referrerPolicy: 'no-referrer' })
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), 5000);
const response = await fetch(url, { cache: "no-store", mode: 'cors', referrerPolicy: 'no-referrer' ,signal: controller.signal})
if (response.status == 404) throw "资源响应异常" + response.status
if (!response.body) throw "资源响应异常 Nobody"
const reader = response.body.getReader();
Expand Down

0 comments on commit d5a21b3

Please sign in to comment.