From fe0a82dd01affb4dc2432cb0e4756ce9d859970f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B8=E6=81=92=E7=9A=84=E5=B0=8F=E9=BB=91=E5=B1=8B?= <35549419+47479380@users.noreply.github.com> Date: Thu, 4 Aug 2022 01:01:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BD=BF=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E8=AF=B7=E6=B1=82enka=20api=E9=85=8D=E7=BD=AE=20(#101?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/profile-data/enka.js | 9 ++++++--- config/profile_default.js | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/components/profile-data/enka.js b/components/profile-data/enka.js index 00625adb..70ed0274 100644 --- a/components/profile-data/enka.js +++ b/components/profile-data/enka.js @@ -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 || '可能是面板服务并发过高,请稍后重试'}`) diff --git a/config/profile_default.js b/config/profile_default.js index 659f5910..f6b4c28d 100644 --- a/config/profile_default.js +++ b/config/profile_default.js @@ -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:'' } /*