2023-05-06 16:29:11 +08:00
/ * *
* 整合接口用于查询数据
* 方便后续用于解耦
* 临时处理 , 后续大概率重写 主要原因 ( 懒 )
* /
export default class apiTool {
2023-05-09 11:03:38 +08:00
/ * *
*
* @ param { 用户uid } uid
* @ param { 区服 } server
* @ param { 是否为星穹铁道或其他游戏 ? type ( bool or string ) } isSr
* /
2023-05-30 03:48:16 +08:00
constructor ( uid , server , isSr = false ) {
2023-05-09 11:03:38 +08:00
this . uid = uid
this . isSr = isSr
this . server = server
this . game = 'genshin'
if ( isSr ) this . game = 'honkaisr'
if ( typeof isSr !== 'boolean' ) {
this . game = isSr
2023-05-06 16:29:11 +08:00
}
2023-05-09 11:03:38 +08:00
}
2023-05-06 16:29:11 +08:00
2023-05-09 11:03:38 +08:00
getUrlMap = ( data = { } ) => {
let host , hostRecord
if ( [ 'cn_gf01' , 'cn_qd01' , 'prod_gf_cn' , 'prod_qd_cn' ] . includes ( this . server ) ) {
host = 'https://api-takumi.mihoyo.com/'
hostRecord = 'https://api-takumi-record.mihoyo.com/'
} else if ( [ 'os_usa' , 'os_euro' , 'os_asia' , 'os_cht' ] . includes ( this . server ) ) {
host = 'https://api-os-takumi.mihoyo.com/'
hostRecord = 'https://bbs-api-os.mihoyo.com/'
}
let urlMap = {
genshin : {
/** 首页宝箱 */
index : {
url : ` ${ hostRecord } game_record/app/genshin/api/index ` ,
query : ` role_id= ${ this . uid } &server= ${ this . server } `
} ,
/** 深渊 */
spiralAbyss : {
url : ` ${ hostRecord } game_record/app/genshin/api/spiralAbyss ` ,
query : ` role_id= ${ this . uid } &schedule_type= ${ data . schedule _type || 1 } &server= ${ this . server } `
} ,
/** 角色详情 */
character : {
url : ` ${ hostRecord } game_record/app/genshin/api/character ` ,
body : { role _id : this . uid , server : this . server }
} ,
/** 树脂 */
dailyNote : {
url : ` ${ hostRecord } game_record/app/genshin/api/dailyNote ` ,
query : ` role_id= ${ this . uid } &server= ${ this . server } `
} ,
/** 详情 */
detail : {
url : ` ${ host } event/e20200928calculate/v1/sync/avatar/detail ` ,
query : ` uid= ${ this . uid } ®ion= ${ this . server } &avatar_id= ${ data . avatar _id } `
} ,
/** 札记 */
ys _ledger : {
url : 'https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo' ,
query : ` month= ${ data . month } &bind_uid= ${ this . uid } &bind_region= ${ this . server } `
} ,
/** 养成计算器 */
compute : {
url : ` ${ host } event/e20200928calculate/v2/compute ` ,
body : data
} ,
blueprintCompute : {
url : ` ${ host } event/e20200928calculate/v1/furniture/compute ` ,
body : data
} ,
/** 养成计算器 */
blueprint : {
url : ` ${ host } event/e20200928calculate/v1/furniture/blueprint ` ,
query : ` share_code= ${ data . share _code } ®ion= ${ this . server } `
} ,
/** 角色技能 */
avatarSkill : {
url : ` ${ host } event/e20200928calculate/v1/avatarSkill/list ` ,
query : ` avatar_id= ${ data . avatar _id } `
} ,
/** 七圣召唤数据 */
basicInfo : {
url : ` ${ hostRecord } game_record/app/genshin/api/gcg/basicInfo ` ,
query : ` role_id= ${ this . uid } &server= ${ this . server } `
} ,
2023-07-10 14:20:02 +08:00
/**七圣牌组 */
deckList : {
url : ` ${ hostRecord } game_record/app/genshin/api/gcg/deckList ` ,
query : ` role_id= ${ this . uid } &server= ${ this . server } `
} ,
/** 七圣召唤角色牌数据 */
avatar _cardList : {
url : ` ${ hostRecord } game_record/app/genshin/api/gcg/cardList ` ,
query : ` limit=999&need_action=false&need_avatar=true&need_stats=true&offset=0&role_id= ${ this . uid } &server= ${ this . server } `
} ,
/** 七圣召唤行动牌数据 */
action _cardList : {
url : ` ${ hostRecord } game_record/app/genshin/api/gcg/cardList ` ,
query : ` limit=999&need_action=true&need_avatar=false&need_stats=true&offset=0&role_id= ${ this . uid } &server= ${ this . server } `
} ,
2023-05-09 11:03:38 +08:00
/**使用兑换码 目前仅限国际服,来自于国服的uid请求已在myinfo.js的init方法提前拦截 */
useCdk : {
url : 'PLACE_HOLDER' ,
query : null
2023-05-30 03:48:16 +08:00
} ,
/** 体力接口fp参数用于避开验证码 */
getFp : {
url : ` https://public-data-api.mihoyo.com/device-fp/api/getFp ` ,
body : {
seed _id : data . seed _id ,
device _id : data . deviceId ,
platform : '5' ,
seed _time : new Date ( ) . getTime ( ) + '' ,
ext _fields : '{"userAgent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.40.1","browserScreenSize":281520,"maxTouchPoints":5,"isTouchSupported":true,"browserLanguage":"zh-CN","browserPlat":"iPhone","browserTimeZone":"Asia/Shanghai","webGlRender":"Apple GPU","webGlVendor":"Apple Inc.","numOfPlugins":0,"listOfPlugins":"unknown","screenRatio":3,"deviceMemory":"unknown","hardwareConcurrency":"4","cpuClass":"unknown","ifNotTrack":"unknown","ifAdBlock":0,"hasLiedResolution":1,"hasLiedOs":0,"hasLiedBrowser":0}' ,
app _name : 'account_cn' ,
device _fp : '38d7ee834d1e9'
} ,
2023-05-06 16:29:11 +08:00
}
2023-05-09 11:03:38 +08:00
} ,
honkaisr : {
/** 首页宝箱 */
index : {
url : ` ${ hostRecord } game_record/app/hkrpg/api/index ` ,
query : ` role_id= ${ this . uid } &server= ${ this . server } `
} ,
2023-05-28 14:01:31 +08:00
basicInfo : {
url : ` ${ hostRecord } game_record/app/hkrpg/api/role/basicInfo ` ,
query : ` role_id= ${ this . uid } &server= ${ this . server } `
} ,
2023-05-09 11:03:38 +08:00
UserGame : {
2023-05-28 14:01:31 +08:00
url : ` ${ host } binding/api/getUserGameRolesByCookie ` ,
query : ` game_biz=hkrpg_cn `
} ,
/** 深渊 (混沌回忆) */
spiralAbyss : {
url : ` ${ hostRecord } game_record/app/hkrpg/api/challenge ` ,
query : ` role_id= ${ this . uid } &schedule_type= ${ data . schedule _type || 1 } &server= ${ this . server } `
} ,
avatarInfo : {
url : ` ${ hostRecord } game_record/app/hkrpg/api/avatar/info ` ,
query : ` need_wiki=true&role_id= ${ this . uid } &server= ${ this . server } `
} ,
/** 体力接口fp参数用于避开验证码 */
getFp : {
url : ` https://public-data-api.mihoyo.com/device-fp/api/getFp ` ,
body : {
seed _id : data . seed _id ,
device _id : data . deviceId ,
platform : '5' ,
seed _time : new Date ( ) . getTime ( ) + '' ,
ext _fields : '{"userAgent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.40.1","browserScreenSize":281520,"maxTouchPoints":5,"isTouchSupported":true,"browserLanguage":"zh-CN","browserPlat":"iPhone","browserTimeZone":"Asia/Shanghai","webGlRender":"Apple GPU","webGlVendor":"Apple Inc.","numOfPlugins":0,"listOfPlugins":"unknown","screenRatio":3,"deviceMemory":"unknown","hardwareConcurrency":"4","cpuClass":"unknown","ifNotTrack":"unknown","ifAdBlock":0,"hasLiedResolution":1,"hasLiedOs":0,"hasLiedBrowser":0}' ,
app _name : 'account_cn' ,
device _fp : '38d7ee834d1e9'
} ,
2023-05-09 11:03:38 +08:00
} ,
/ * *
* 开拓阅历接口
* /
ys _ledger : {
url : ` ${ host } /event/srledger/month_info ` ,
query : ` region= ${ this . server } &uid= ${ this . uid } &month= ${ data . month } `
} ,
/** 角色详情 */
character : {
2023-05-28 14:01:31 +08:00
url : ` ${ hostRecord } game_record/app/hkrpg/api/avatar/basic ` ,
query : ` role_id= ${ this . uid } &server= ${ this . server } `
2023-05-09 11:03:38 +08:00
} ,
/** 树脂 */
dailyNote : {
url : ` ${ hostRecord } game_record/app/hkrpg/api/note ` ,
query : ` role_id= ${ this . uid } &server= ${ this . server } `
2023-05-06 16:29:11 +08:00
}
2023-05-09 11:03:38 +08:00
}
}
2023-05-06 16:29:11 +08:00
2023-05-09 11:03:38 +08:00
if ( this . server . startsWith ( 'os' ) ) {
urlMap . genshin . detail . url = 'https://sg-public-api.hoyolab.com/event/calculateos/sync/avatar/detail' // 角色天赋详情
urlMap . genshin . detail . query = ` lang=zh-cn&uid= ${ this . uid } ®ion= ${ this . server } &avatar_id= ${ data . avatar _id } `
urlMap . genshin . avatarSkill . url = 'https://sg-public-api.hoyolab.com/event/calculateos/avatar/skill_list' // 查询未持有的角色天赋
urlMap . genshin . avatarSkill . query = ` lang=zh-cn&avatar_id= ${ data . avatar _id } `
urlMap . genshin . compute . url = 'https://sg-public-api.hoyolab.com/event/calculateos/compute' // 已支持养成计算
urlMap . genshin . blueprint . url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/blueprint'
urlMap . genshin . blueprint . query = ` share_code= ${ data . share _code } ®ion= ${ this . server } &lang=zh-cn `
urlMap . genshin . blueprintCompute . url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/compute'
urlMap . genshin . blueprintCompute . body = { lang : 'zh-cn' , ... data }
urlMap . genshin . ys _ledger . url = 'https://hk4e-api-os.mihoyo.com/event/ysledgeros/month_info' // 支持了国际服札记
urlMap . genshin . ys _ledger . query = ` lang=zh-cn&month= ${ data . month } &uid= ${ this . uid } ®ion= ${ this . server } `
urlMap . genshin . useCdk . url = 'https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey'
urlMap . genshin . useCdk . query = ` uid= ${ this . uid } ®ion= ${ this . server } &lang=zh-cn&cdkey= ${ data . cdk } &game_biz=hk4e_global `
2023-05-06 16:29:11 +08:00
}
2023-05-09 11:03:38 +08:00
return urlMap [ this . game ]
}
2023-05-06 16:29:11 +08:00
}