Commit efd0c2c9 by haojie[

预请求超时时间设置为3秒

parent 1ce3f9eb
......@@ -55,6 +55,7 @@ export default defineNuxtConfig({
},
},
experimental: {
// 加载慢的问题
writeEarlyHints: false,
},
vite: {
......
<template>
<div class="">1</div>
<div class=""></div>
</template>
<script lang="ts" setup></script>
<script lang="ts" setup>
</script>
<style lang="less"></style>
(function () {
var ua = window.navigator.userAgent.toLowerCase();
if (
!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
)
) {
return;
} else if (ua.indexOf('iphone') > 0 || ua.indexOf('android') > 0) {
try {
let url = window.location.href;
let curpath = url.indexOf('//');
if (curpath !== -1 && url.indexOf('m.') === -1) {
let pathValue = curpath + 1;
if (url.indexOf('https') !== -1) {
url = url.replace('https', 'http');
window.location.href =
url.slice(0, pathValue) + 'm.' + url.slice(pathValue);
} else {
window.location.href =
url.slice(0, pathValue + 1) + 'm.' + url.slice(pathValue + 1);
}
}
} catch (e) {
window.location.href = 'http://m.dexfilter.com';
}
}
})();
......@@ -178,12 +178,12 @@
</table>
</div>
<div class="page-footer">
<CustPagination
<cust-pagination
:pageNum="pageNum"
:total="resultData.total"
:continues="8"
@pageChange="onCurrentChange"
></CustPagination>
></cust-pagination>
</div>
</div>
</template>
......@@ -493,17 +493,18 @@ const getBaseUrl = () => {
return "/v1";
}
};
//创建AbortController对象
const abortController = new AbortController();
let controller = new AbortController();
let signal = controller.signal;
const clear_fetch = setTimeout(() => {
controller.abort();
console.log("请求已断开");
}, 3);
// 预取数据
const { data }: any = await useFetch(() => `/v1${chain.value}/indexV1`, {
params: getParams(),
lazy: true,
// method: "GET",
// mode: "cors",
// credentials: "include",
signal: signal,
baseURL: getBaseUrl(),
signal: abortController.signal,
onRequest(context: any) {},
onResponse({ request, response, options }) {
try {
......@@ -524,6 +525,8 @@ const { data }: any = await useFetch(() => `/v1${chain.value}/indexV1`, {
console.log(error, "返回的error");
},
});
// 超时断开请求
clearTimeout(clear_fetch);
// 获取默认数据
const getDefaultList = () => {
if (process.client && data.value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment