mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
添加使用代理请求enka api配置 (#101)
This commit is contained in:
parent
7108726c56
commit
fe0a82dd01
@ -1,6 +1,6 @@
|
||||
import fetch from 'node-fetch'
|
||||
import EnkaData from './enka-data.js'
|
||||
|
||||
import HttpsProxyAgent from "https-proxy-agent";
|
||||
let Enka = {
|
||||
key: 'enka',
|
||||
cd: 5,
|
||||
@ -11,8 +11,11 @@ let Enka = {
|
||||
if (diyCfg?.enkaApi?.apiKey) {
|
||||
api += '?key=' + diyCfg.enkaApi.apiKey
|
||||
}
|
||||
let headers = { headers: { 'User-Agent': diyCfg?.enkaApi?.userAgent || sysCfg.enkaApi.userAgent } }
|
||||
let req = await fetch(api, headers)
|
||||
let config = { headers: { 'User-Agent': diyCfg?.enkaApi?.userAgent || sysCfg.enkaApi.userAgent } }
|
||||
if (diyCfg?.enkaApi?.proxyAgent){
|
||||
config.agent=new HttpsProxyAgent(diyCfg.enkaApi.proxyAgent)
|
||||
}
|
||||
let req = await fetch(api, config)
|
||||
let data = await req.json()
|
||||
if (!data.playerInfo) {
|
||||
e.reply(`请求失败:${data.msg || '可能是面板服务并发过高,请稍后重试'}`)
|
||||
|
@ -19,10 +19,13 @@
|
||||
* 推荐使用【广州】或【上海】节点,如访问enka官网相对稳定的话推荐优先使用官方地址
|
||||
* 感谢@MiniGrayGay 大佬提供的服务(Github: https://github.com/MiniGrayGay)
|
||||
*
|
||||
* 使用代理(科学上网)可以配置proxyAgent
|
||||
* 例如: http://127.0.0.1:1080
|
||||
* */
|
||||
|
||||
export const enkaApi = {
|
||||
url: 'https://enka.network/'
|
||||
url: 'https://enka.network/',
|
||||
proxyAgent:''
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user