From eb0e86ff3d0ca938deb2980e96847a2c0e06b514 Mon Sep 17 00:00:00 2001 From: kissnavel Date: Tue, 16 Jul 2024 19:53:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:mysapi=E3=80=81fix:tool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mysapi.js | 29 ++++++----------------------- lib/mysapi/tool.js | 18 ++++++++---------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/lib/mysapi.js b/lib/mysapi.js index f36e5a0..d5cd8bf 100644 --- a/lib/mysapi.js +++ b/lib/mysapi.js @@ -8,14 +8,6 @@ import MysApi from '../../genshin/model/mys/mysApi.js'; // const DEVICE_ID = randomString(32).toUpperCase() // const DEVICE_NAME = randomString(_.random(1, 10)); -const game_region = [ - 'prod_gf_cn', - 'prod_gf_us', - 'prod_gf_eu', - 'prod_gf_jp', - 'prod_gf_sg', -]; - /** * 米游社ZZZAPI(继承自MysApi) */ @@ -48,17 +40,17 @@ export default class MysZZZApi extends MysApi { getServer() { const _uid = this.uid?.toString(); if (_uid.length < 10) { - return game_region[0]; // 官服 + return 'prod_gf_cn'; // 官服 } switch (_uid.slice(0, -8)) { case '10': - return game_region[1]; // 美服 + return 'prod_gf_us'; // 美服 case '15': - return game_region[2]; // 欧服 + return 'prod_gf_eu'; // 欧服 case '13': - return game_region[3]; // 亚服 + return 'prod_gf_jp'; // 亚服 case '17': - return game_region[4]; // 港澳台服 + return 'prod_gf_sg'; // 港澳台服 } } @@ -301,13 +293,4 @@ export default class MysZZZApi extends MysApi { if (!_data || _data.retcode !== 0) return false; return _data.data; } -} - -export function generateSeed(length = 16) { - const characters = '0123456789abcdef'; - let result = ''; - for (let i = 0; i < length; i++) { - result += characters[Math.floor(Math.random() * characters.length)]; - } - return result; -} +} \ No newline at end of file diff --git a/lib/mysapi/tool.js b/lib/mysapi/tool.js index dead57e..9286ccb 100644 --- a/lib/mysapi/tool.js +++ b/lib/mysapi/tool.js @@ -16,15 +16,21 @@ export default class ZZZApiTool { this.game = 'zzz'; this.uuid = crypto.randomUUID(); if (['prod_gf_cn'].includes(this.server)) { + this.game_biz = 'nap_cn' this.host = 'https://api-takumi.mihoyo.com/'; this.hostRecord = 'https://api-takumi-record.mihoyo.com/'; this.hostPublicData = 'https://public-data-api.mihoyo.com/'; } else { + this.game_biz = 'nap_global' this.host = 'https://sg-public-api.hoyolab.com/'; this.hostRecord = 'https://sg-act-nap-api.hoyolab.com/'; this.hostPublicData = 'https://sg-public-data-api.hoyoverse.com/'; } this.zzzUrlMap = { + zzzUser: { + url: `${this.host}binding/api/getUserGameRolesByCookie`, + query: `game_biz=${this.game_biz}®ion=${this.server}&game_uid=${this.uid}`, + }, zzzNote: { url: `${this.hostRecord}event/game_record_zzz/api/zzz/note`, query: `role_id=${this.uid}&server=${this.server}`, @@ -53,7 +59,7 @@ export default class ZZZApiTool { url: `${this.host}binding/api/genAuthKey`, body: { auth_appid: 'webview_gacha', - game_biz: 'nap_cn', + game_biz: this.game_biz, game_uid: this.uid * 1, region: this.server, }, @@ -67,10 +73,6 @@ export default class ZZZApiTool { zzz: { ...(['prod_gf_cn'].includes(this.server) ? { - zzzUser: { - url: `${this.host}binding/api/getUserGameRolesByCookie`, - query: `game_biz=nap_cn®ion=${this.server}&game_uid=${this.uid}`, - }, getFp: { url: `${this.hostPublicData}device-fp/api/getFp`, body: { @@ -86,10 +88,6 @@ export default class ZZZApiTool { }, } : { - zzzUser: { - url: `${this.host}binding/api/getUserGameRolesByCookie`, - query: `game_biz=nap_global®ion=${this.server}&game_uid=${this.uid}`, - }, getFp: { url: `${this.hostPublicData}device-fp/api/getFp`, body: { @@ -110,4 +108,4 @@ export default class ZZZApiTool { }; return urlMap[this.game]; }; -} +} \ No newline at end of file