From e9d912f118239148b38311091da3b50998672d70 Mon Sep 17 00:00:00 2001 From: kissnavel Date: Mon, 30 Jun 2025 21:19:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:enka=E9=80=82=E9=85=8D=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E6=9C=8D=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- defSet/config.yaml | 2 +- model/Enka/enkaApi.js | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/defSet/config.yaml b/defSet/config.yaml index 0900cda..bde6e0a 100644 --- a/defSet/config.yaml +++ b/defSet/config.yaml @@ -12,4 +12,4 @@ mysCode: # 自定义绑定设备下载url url: https://ghproxy.mihomo.me/https://raw.githubusercontent.com/forchannot/get_device_info/main/app/build/outputs/apk/debug/app-debug.apk # 自定义enkaApi地址 -enkaApi: \ No newline at end of file +enkaApi: https://enka.network/api/zzz/uid/ \ No newline at end of file diff --git a/model/Enka/enkaApi.js b/model/Enka/enkaApi.js index 73415d3..1ce23f3 100644 --- a/model/Enka/enkaApi.js +++ b/model/Enka/enkaApi.js @@ -4,18 +4,35 @@ import settings from '../../lib/settings.js' import _ from 'lodash' const config = settings.getConfig('config') -const EnkaApi = _.get(config, 'enkaApi') || 'https://enka.network/api/zzz/uid/' +const defConfig = settings.getdefSet('config') +const EnkaApi = _.get(config, 'enkaApi') || _.get(defConfig, 'enkaApi') + +export function getGameRoles(uid, region = false) { + const _uid = String(uid) + switch (_uid.slice(0, -8)) { + case '10': + return region == true ? 'prod_gf_us' : 'America' // 美服 + case '15': + return region == true ? 'prod_gf_eu' :'Europe' // 欧服 + case '13': + return region == true ? 'prod_gf_jp' :'Asia' // 亚服 + case '17': + return region == true ? 'prod_gf_sg' : 'TW,HK,MO' // 港澳台服 + } + return region == true ? 'prod_gf_cn' : '新艾利都' // 官服 +} export function parsePlayerInfo(SocialDetail = {}) { const ProfileDetail = SocialDetail.ProfileDetail || {} + const game_uid = ProfileDetail.Uid || SocialDetail.uid || '114514' return { - game_biz: 'nap_cn', - region: 'prod_gf_cn', - game_uid: ProfileDetail.Uid || SocialDetail.uid || '114514', + game_biz: String(game_uid).length < 10 ? 'nap_cn' : 'nap_global', + region: getGameRoles(game_uid, true), + game_uid: game_uid, nickname: ProfileDetail.Nickname || 'Fairy', level: ProfileDetail.Level || 60, is_chosen: true, - region_name: '新艾利都', + region_name: getGameRoles(game_uid, false), is_official: true, desc: SocialDetail.Desc || '', }