Merge pull request #17 from kissnavel/main

fix:mysapi、fix:tool
This commit is contained in:
bietiaop 2024-07-16 20:00:14 +08:00 committed by GitHub
commit 4376e80e74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 33 deletions

View file

@ -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;
}
}

View file

@ -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}&region=${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&region=${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&region=${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];
};
}
}