!122 将fp移至mysApi

* fix
* 优化
* 优化
This commit is contained in:
帮帮 2023-10-22 17:17:39 +00:00 committed by Kokomi
parent edf20783a5
commit 8c991f02e8
2 changed files with 13 additions and 26 deletions

View File

@ -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(),

View File

@ -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) {