!171 添加国际服支持

* 修改判断
* 更新星铁fp避开验证码
* 添加国际服支持
This commit is contained in:
kissnavel 2024-05-13 17:42:02 +00:00 committed by Kokomi
parent 9df1e4c440
commit 189a4315a1
4 changed files with 92 additions and 52 deletions

View File

@ -348,7 +348,7 @@ export default class MysUser extends BaseModel {
let ck = this.ck
let url = {
mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie',
hoyolab: 'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie'
hoyolab: 'https://sg-public-api.hoyolab.com/binding/api/getUserGameRolesByCookie'
}
let res = await fetch(url[serv], { method: 'get', headers: { Cookie: ck } })
@ -373,7 +373,7 @@ export default class MysUser extends BaseModel {
Connection: 'keep-alive',
Host: 'bbs-api.mihoyo.com',
Origin: 'https://m.bbs.mihoyo.com',
Referer: ' https://m.bbs.mihoyo.com/'
Referer: 'https://m.bbs.mihoyo.com/'
}
})
if (!res.ok) return res
@ -395,7 +395,6 @@ export default class MysUser extends BaseModel {
return cache[game]
}
// 初始化数据
async initDB(db = false) {
if (this.db && !db) {
@ -549,4 +548,4 @@ export default class MysUser extends BaseModel {
let uids = this.uids[gameKey]
return uids.includes(uid + '')
}
}
}

View File

@ -21,18 +21,47 @@ export default class apiTool {
}
}
getUrlMap = (data = {}) => {
let host, hostRecord
let host, hostRecord, hostPublicData
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/'
hostPublicData = 'https://public-data-api.mihoyo.com/'
} else if (/os_|official/.test(this.server)) {
host = 'https://sg-public-api.hoyolab.com/'
hostRecord = 'https://bbs-api-os.hoyolab.com/'
hostPublicData = 'https://sg-public-data-api.hoyoverse.com/'
}
let urlMap = {
genshin: {
/** 体力接口fp参数用于避开验证码 */
...(['cn_gf01', 'cn_qd01'].includes(this.server) ? {
getFp: {
url: `${hostPublicData}device-fp/api/getFp`,
body: {
seed_id: data.seed_id,
device_id: data.deviceId.toUpperCase(),
platform: '1',
seed_time: new Date().getTime() + '',
ext_fields: `{"proxyStatus":"0","accelerometer":"-0.159515x-0.830887x-0.682495","ramCapacity":"3746","IDFV":"${data.deviceId.toUpperCase()}","gyroscope":"-0.191951x-0.112927x0.632637","isJailBreak":"0","model":"iPhone12,5","ramRemain":"115","chargeStatus":"1","networkType":"WIFI","vendor":"--","osVersion":"17.0.2","batteryStatus":"50","screenSize":"414×896","cpuCores":"6","appMemory":"55","romCapacity":"488153","romRemain":"157348","cpuType":"CPU_TYPE_ARM64","magnetometer":"-84.426331x-89.708435x-37.117889"}`,
app_name: 'bbs_cn',
device_fp: '38d7ee834d1e9'
}
}
} : {
getFp: {
url: `${hostPublicData}device-fp/api/getFp`,
body: {
seed_id: data.seed_id,
device_id: data.deviceId.toUpperCase(),
platform: '1',
seed_time: new Date().getTime() + '',
ext_fields: `{"proxyStatus":"0","accelerometer":"-0.159515x-0.830887x-0.682495","ramCapacity":"3746","IDFV":"${data.deviceId.toUpperCase()}","gyroscope":"-0.191951x-0.112927x0.632637","isJailBreak":"0","model":"iPhone12,5","ramRemain":"115","chargeStatus":"1","networkType":"WIFI","vendor":"--","osVersion":"17.0.2","batteryStatus":"50","screenSize":"414×896","cpuCores":"6","appMemory":"55","romCapacity":"488153","romRemain":"157348","cpuType":"CPU_TYPE_ARM64","magnetometer":"-84.426331x-89.708435x-37.117889"}`,
app_name: 'hk4e_global',
device_fp: '38d7ee834d1e9'
}
}
}),
/** 首页宝箱 */
index: {
url: `${hostRecord}game_record/app/genshin/api/index`,
@ -106,22 +135,46 @@ export default class apiTool {
useCdk: {
url: 'PLACE_HOLDER',
query: null
},
/** 体力接口fp参数用于避开验证码 */
getFp: {
url: `https://public-data-api.mihoyo.com/device-fp/api/getFp`,
body: {
seed_id: data.seed_id,
device_id: data.deviceId.toUpperCase(),
platform: '1',
seed_time: new Date().getTime() + '',
ext_fields: `{"proxyStatus":"0","accelerometer":"-0.159515x-0.830887x-0.682495","ramCapacity":"3746","IDFV":"${data.deviceId.toUpperCase()}","gyroscope":"-0.191951x-0.112927x0.632637","isJailBreak":"0","model":"iPhone12,5","ramRemain":"115","chargeStatus":"1","networkType":"WIFI","vendor":"--","osVersion":"17.0.2","batteryStatus":"50","screenSize":"414×896","cpuCores":"6","appMemory":"55","romCapacity":"488153","romRemain":"157348","cpuType":"CPU_TYPE_ARM64","magnetometer":"-84.426331x-89.708435x-37.117889"}`,
app_name: 'bbs_cn',
device_fp: '38d7ee834d1e9'
},
}
},
honkaisr: {
...(['prod_gf_cn', 'prod_qd_cn'].includes(this.server) ? {
UserGame: {
url: `${host}binding/api/getUserGameRolesByCookie`,
query: `game_biz=hkrpg_cn`
},
/** 体力接口fp参数用于避开验证码 */
getFp: {
url: `${hostPublicData}device-fp/api/getFp`,
body: {
seed_id: data.seed_id,
device_id: data.deviceId.toUpperCase(),
platform: '1',
seed_time: new Date().getTime() + '',
ext_fields: `{"proxyStatus":"0","accelerometer":"-0.159515x-0.830887x-0.682495","ramCapacity":"3746","IDFV":"${data.deviceId.toUpperCase()}","gyroscope":"-0.191951x-0.112927x0.632637","isJailBreak":"0","model":"iPhone12,5","ramRemain":"115","chargeStatus":"1","networkType":"WIFI","vendor":"--","osVersion":"17.0.2","batteryStatus":"50","screenSize":"414×896","cpuCores":"6","appMemory":"55","romCapacity":"488153","romRemain":"157348","cpuType":"CPU_TYPE_ARM64","magnetometer":"-84.426331x-89.708435x-37.117889"}`,
app_name: 'bbs_cn',
device_fp: '38d7ee834d1e9'
}
}
} : {
UserGame: {
url: `${host}binding/api/getUserGameRolesByCookie`,
query: `game_biz=hkrpg_global`
},
/** 体力接口fp参数用于避开验证码 */
getFp: {
url: `${hostPublicData}device-fp/api/getFp`,
body: {
seed_id: data.seed_id,
device_id: data.deviceId.toUpperCase(),
platform: '1',
seed_time: new Date().getTime() + '',
ext_fields: `{"proxyStatus":"0","accelerometer":"-0.159515x-0.830887x-0.682495","ramCapacity":"3746","IDFV":"${data.deviceId.toUpperCase()}","gyroscope":"-0.191951x-0.112927x0.632637","isJailBreak":"0","model":"iPhone12,5","ramRemain":"115","chargeStatus":"1","networkType":"WIFI","vendor":"--","osVersion":"17.0.2","batteryStatus":"50","screenSize":"414×896","cpuCores":"6","appMemory":"55","romCapacity":"488153","romRemain":"157348","cpuType":"CPU_TYPE_ARM64","magnetometer":"-84.426331x-89.708435x-37.117889"}`,
app_name: 'hkrpg_global',
device_fp: '38d7ee834d1e9'
}
}
}),
/** 首页宝箱 */
index: {
url: `${hostRecord}game_record/app/hkrpg/api/index`,
@ -131,10 +184,6 @@ export default class apiTool {
url: `${hostRecord}game_record/app/hkrpg/api/role/basicInfo`,
query: `role_id=${this.uid}&server=${this.server}`
},
UserGame: {
url: `${host}binding/api/getUserGameRolesByCookie`,
query: `game_biz=hkrpg_cn`
},
/** 深渊 (混沌回忆) */
spiralAbyss: {
url: `${hostRecord}game_record/app/hkrpg/api/challenge`,
@ -144,25 +193,10 @@ export default class apiTool {
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: '1',
seed_time: new Date().getTime() + '',
ext_fields: '{"proxyStatus":"0","accelerometer":"-0.159515x-0.830887x-0.682495","ramCapacity":"3746","IDFV":"8F4E403B-4C28-4F7F-B740-2DD317948B8A","gyroscope":"-0.191951x-0.112927x0.632637","isJailBreak":"0","model":"iPhone12,5","ramRemain":"115","chargeStatus":"1","networkType":"WIFI","vendor":"--","osVersion":"17.0.2","batteryStatus":"50","screenSize":"414×896","cpuCores":"6","appMemory":"55","romCapacity":"488153","romRemain":"157348","cpuType":"CPU_TYPE_ARM64","magnetometer":"-84.426331x-89.708435x-37.117889"}',
app_name: 'bbs_cn',
device_fp: '38d7ee834d1e9'
},
},
/**
* 开拓阅历接口
*/
/** 开拓阅历接口 */
ys_ledger: {
url: `${host}event/srledger/month_info`,
query: `region=${this.server}&uid=${this.uid}&month=${data.month}`
query: `lang=zh-cn&region=${this.server}&uid=${this.uid}&month=${data.month}`
},
/** 角色详情 */
character: {
@ -198,11 +232,11 @@ export default class apiTool {
urlMap.genshin.blueprint.query = `share_code=${data.share_code}&region=${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.body }
urlMap.genshin.ys_ledger.url = 'https://hk4e-api-os.mihoyo.com/event/ysledgeros/month_info'// 支持了国际服札记
urlMap.genshin.ys_ledger.url = 'https://sg-hk4e-api.hoyolab.com/event/ysledgeros/month_info'// 支持了国际服札记
urlMap.genshin.ys_ledger.query = `lang=zh-cn&month=${data.month}&uid=${this.uid}&region=${this.server}`
urlMap.genshin.useCdk.url = 'https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey'
urlMap.genshin.useCdk.query = `uid=${this.uid}&region=${this.server}&lang=zh-cn&cdkey=${data.cdk}&game_biz=hk4e_global`
}
return urlMap[this.game]
}
}
}

View File

@ -141,7 +141,7 @@ export default class MysApi {
const cn = {
app_version: '2.40.1',
User_Agent: `Mozilla/5.0 (Linux; Android 12; ${this.device}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBS/2.40.1`,
client_type: 5,
client_type: '5',
Origin: 'https://webstatic.mihoyo.com',
X_Requested_With: 'com.mihoyo.hyperion',
Referer: 'https://webstatic.mihoyo.com'
@ -155,7 +155,7 @@ export default class MysApi {
Referer: 'https://webstatic-sea.hoyolab.com'
}
let client
if (this.server.startsWith('os')) {
if (/os_|official/.test(this.server)) {
client = os
} else {
client = cn
@ -204,7 +204,7 @@ export default class MysApi {
if (!proxyAddress) return null
if (proxyAddress === 'http://0.0.0.0:0') return null
if (!this.server.startsWith('os')) return null
if (!/os_|official/.test(this.server)) return null
if (HttpsProxyAgent === '') {
HttpsProxyAgent = await import('https-proxy-agent').catch((err) => {
@ -229,4 +229,4 @@ export default class MysApi {
}
return result
}
}
}

View File

@ -133,7 +133,7 @@ export default class User extends base {
'【#体力】查询当前树脂',
'【#原石】查看原石札记',
'【#原石统计】原石统计数据',
'【#练度统计】技能统计列表',
'【#练度统计】角色列表数据',
'【#面板】【#更新面板】面板信息'
)
button.push([
@ -155,13 +155,20 @@ export default class User extends base {
'星穹铁道支持:',
'【*uid】当前绑定ck uid列表',
'【*删除ck】删除当前绑定ck',
'【*体力】体力信息',
'【*体力】查询当前开拓力',
'【*星琼】查看星琼月历',
'【*星琼统计】星琼统计数据',
'【*练度统计】角色列表数据',
'【*面板】【*更新面板】面板信息'
)
button.push([
{ text: '*uid', callback: '*uid' },
{ text: '*删除ck', callback: '*删除ck' },
{ text: '*体力', callback: '*体力' }
], [
{ text: '*星琼', callback: '*星琼' },
{ text: '*星琼统计', callback: '*星琼统计' },
{ text: '*练度统计', callback: '*练度统计' }
], [
{ text: '*面板', callback: '*面板' },
{ text: '*更新面板', callback: '*更新面板' }
@ -653,4 +660,4 @@ export default class User extends base {
`#绑定主用户[${id}]`].join('\n'))
}
}
}
}