不重复生成fp
This commit is contained in:
		
							parent
							
								
									72fc40ea49
								
							
						
					
					
						commit
						af19c2959c
					
				|  | @ -68,24 +68,8 @@ export default class MysApi { | |||
|     return this.isSr ? 'prod_gf_cn' : 'cn_gf01' | ||||
|   } | ||||
| 
 | ||||
|   async getData(type, data = {}, cached = false, isGetFP = false) { | ||||
|     if (!isGetFP && !this.device_fp && !data?.headers?.['x-rpc-device_fp']) { | ||||
|       let seed_id = this.generateSeed(16) | ||||
|       let device_fp = await this.getData('getFp', { | ||||
|         seed_id | ||||
|       }, false, true) | ||||
|       this.device_fp = device_fp?.data?.device_fp | ||||
|     } | ||||
|     if (!isGetFP && this.device_fp && !data?.headers?.['x-rpc-device_fp']) { | ||||
|       if (data?.headers) { | ||||
|         data.headers['x-rpc-device_fp'] = this.device_fp | ||||
|       } else { | ||||
|         if (!data) data = {} | ||||
|         data.headers = { | ||||
|           'x-rpc-device_fp': this.device_fp | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   async getData(type, data = {}, cached = false) { | ||||
|     if (type == 'getFp') data = { seed_id: this.generateSeed(16) } | ||||
|     let { url, headers, body } = this.getUrl(type, data) | ||||
| 
 | ||||
|     if (!url) return false | ||||
|  |  | |||
|  | @ -161,10 +161,34 @@ export default class MysInfo { | |||
|     let user = e.user?.getMysUser() | ||||
|     let mysApi = new MysApi(mysInfo.uid, mysInfo.ckInfo.ck, option, e.isSr, user.device) | ||||
| 
 | ||||
|     if (!data?.headers?.['x-rpc-device_fp']){ | ||||
|       let device_fp = (await mysApi.getData('getFp')).data?.device_fp | ||||
|       if (data?.headers) { | ||||
|         data.headers['x-rpc-device_fp'] = device_fp | ||||
|       } else { | ||||
|         if (!data) data = {} | ||||
|         data.headers = { | ||||
|           'x-rpc-device_fp': device_fp | ||||
|         } | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     let res | ||||
|     if (lodash.isObject(api)) { | ||||
|       let all = [] | ||||
|       /** 同步请求 */ | ||||
|       for (let i in api) { | ||||
|         if (!api[i]?.headers?.['x-rpc-device_fp']){ | ||||
|           if (api[i]?.headers) { | ||||
|             api[i].headers['x-rpc-device_fp'] = device_fp | ||||
|           } else { | ||||
|             if (!api[i]) api[i] = {} | ||||
|             api[i].headers = { | ||||
|               'x-rpc-device_fp': device_fp | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       if (e.apiSync) { | ||||
|         res = [] | ||||
|         for (let i in api) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue