From aaea47d7ae7595929822bc5e1ab1dcfad7217069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Thu, 21 Nov 2024 16:59:59 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=8F=AF=E9=85=8D=E7=BD=AE=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Config.js | 1 + config/default_config/steam.yaml | 3 +++ models/setting/index.js | 14 ++++++++++++++ models/utils/request.js | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/Config.js b/components/Config.js index e50df94..7098040 100644 --- a/components/Config.js +++ b/components/Config.js @@ -70,6 +70,7 @@ class Config { * @returns {{ * apiKey: string, * proxy: string, + * timeout: number, * }} */ get steam () { diff --git a/config/default_config/steam.yaml b/config/default_config/steam.yaml index d31667f..c5cafe2 100644 --- a/config/default_config/steam.yaml +++ b/config/default_config/steam.yaml @@ -4,3 +4,6 @@ apiKey: "" # proxy代理 proxy: "" + +# api请求超时时间 单位: 秒 +timeout: 5 diff --git a/models/setting/index.js b/models/setting/index.js index eede7f5..4e23d1e 100644 --- a/models/setting/index.js +++ b/models/setting/index.js @@ -17,6 +17,20 @@ export const cfgSchema = { type: 'string', def: '', desc: '用于加速访问' + }, + timeout: { + title: '请求超时时间', + key: '超时', + type: 'number', + input: (n) => { + if (n > 0) { + return n * 1 + } else { + return 5 + } + }, + desc: '请求超时时间,单位秒', + def: 5 } } }, diff --git a/models/utils/request.js b/models/utils/request.js index 91ec284..db2faf5 100644 --- a/models/utils/request.js +++ b/models/utils/request.js @@ -20,7 +20,7 @@ export default async function request (url, options = {}) { key: baseURL === ateamApi ? Config.steam.apiKey : undefined, ...options.params }, - timeout: 5000 + timeout: Config.steam.timeout * 1000 }) }