Skip to content

Commit

Permalink
perf: 可配置超时时间
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Nov 21, 2024
1 parent a946ce8 commit aaea47d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Config {
* @returns {{
* apiKey: string,
* proxy: string,
* timeout: number,
* }}
*/
get steam () {
Expand Down
3 changes: 3 additions & 0 deletions config/default_config/steam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ apiKey: ""

# proxy代理
proxy: ""

# api请求超时时间 单位: 秒
timeout: 5
14 changes: 14 additions & 0 deletions models/setting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion models/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

Expand Down

0 comments on commit aaea47d

Please sign in to comment.