Commit efd0c2c9 by haojie[

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

parent 1ce3f9eb
...@@ -55,6 +55,7 @@ export default defineNuxtConfig({ ...@@ -55,6 +55,7 @@ export default defineNuxtConfig({
}, },
}, },
experimental: { experimental: {
// 加载慢的问题
writeEarlyHints: false, writeEarlyHints: false,
}, },
vite: { vite: {
......
<template> <template>
<div class="">1</div> <div class=""></div>
</template> </template>
<script lang="ts" setup></script> <script lang="ts" setup>
</script>
<style lang="less"></style> <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 @@ ...@@ -178,12 +178,12 @@
</table> </table>
</div> </div>
<div class="page-footer"> <div class="page-footer">
<CustPagination <cust-pagination
:pageNum="pageNum" :pageNum="pageNum"
:total="resultData.total" :total="resultData.total"
:continues="8" :continues="8"
@pageChange="onCurrentChange" @pageChange="onCurrentChange"
></CustPagination> ></cust-pagination>
</div> </div>
</div> </div>
</template> </template>
...@@ -493,17 +493,18 @@ const getBaseUrl = () => { ...@@ -493,17 +493,18 @@ const getBaseUrl = () => {
return "/v1"; return "/v1";
} }
}; };
//创建AbortController对象 let controller = new AbortController();
const abortController = new AbortController(); let signal = controller.signal;
const clear_fetch = setTimeout(() => {
controller.abort();
console.log("请求已断开");
}, 3);
// 预取数据 // 预取数据
const { data }: any = await useFetch(() => `/v1${chain.value}/indexV1`, { const { data }: any = await useFetch(() => `/v1${chain.value}/indexV1`, {
params: getParams(), params: getParams(),
lazy: true, lazy: true,
// method: "GET", signal: signal,
// mode: "cors",
// credentials: "include",
baseURL: getBaseUrl(), baseURL: getBaseUrl(),
signal: abortController.signal,
onRequest(context: any) {}, onRequest(context: any) {},
onResponse({ request, response, options }) { onResponse({ request, response, options }) {
try { try {
...@@ -524,6 +525,8 @@ const { data }: any = await useFetch(() => `/v1${chain.value}/indexV1`, { ...@@ -524,6 +525,8 @@ const { data }: any = await useFetch(() => `/v1${chain.value}/indexV1`, {
console.log(error, "返回的error"); console.log(error, "返回的error");
}, },
}); });
// 超时断开请求
clearTimeout(clear_fetch);
// 获取默认数据 // 获取默认数据
const getDefaultList = () => { const getDefaultList = () => {
if (process.client && data.value) { 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