diff --git a/plugins/genshin/model/mys/mysApi.js b/plugins/genshin/model/mys/mysApi.js index 586d6db..7c2069f 100644 --- a/plugins/genshin/model/mys/mysApi.js +++ b/plugins/genshin/model/mys/mysApi.js @@ -70,7 +70,14 @@ export default class MysApi { } async getData (type, data = {}, cached = false) { - if (type == 'getFp') data = { seed_id: this.generateSeed(16) } + if (!this._device_fp && !data?.Getfp) { + this._device_fp = await this.getData('getFp', { + seed_id: this.generateSeed(16), + Getfp: true + }) + } + if (type === 'getFp' && !data?.Getfp) return this._device_fp + let { url, headers, body } = this.getUrl(type, data) if (!url) return false @@ -85,6 +92,10 @@ export default class MysApi { headers = { ...headers, ...data.headers } } + if (type !== 'getFp' && !headers['x-rpc-device_fp']) { + headers['x-rpc-device_fp'] = this._device_fp.data?.device_fp + } + let param = { headers, agent: await this.getAgent(), diff --git a/plugins/genshin/model/mys/mysInfo.js b/plugins/genshin/model/mys/mysInfo.js index 107a355..bf1306a 100644 --- a/plugins/genshin/model/mys/mysInfo.js +++ b/plugins/genshin/model/mys/mysInfo.js @@ -163,35 +163,11 @@ export default class MysInfo { let user = e.user?.getMysUser() let mysApi = new MysApi(mysInfo.uid, mysInfo.ckInfo.ck, option, e.isSr, user.device) - let devicefp = '' - if (!data?.headers?.['x-rpc-device_fp'] && api !== 'getFp') { - devicefp = (await mysApi.getData('getFp')).data?.device_fp - if (data?.headers) { - data.headers['x-rpc-device_fp'] = devicefp - } else { - if (!data) data = {} - data.headers = { - 'x-rpc-device_fp': devicefp - } - } - } - let res if (lodash.isObject(api)) { let all = [] + await mysApi.getData('getFp') /** 同步请求 */ - for (let i in api) { - if (!api[i]?.headers?.['x-rpc-device_fp']) { - if (api[i]?.headers) { - api[i].headers['x-rpc-device_fp'] = devicefp - } else { - if (!api[i]) api[i] = {} - api[i].headers = { - 'x-rpc-device_fp': devicefp - } - } - } - } if (e.apiSync) { res = [] for (let i in api) {