mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-15 20:57:43 +00:00
fix:'User-Agent'尝试写入已绑定的设备信息
This commit is contained in:
parent
c5f40f6a24
commit
ada1b9bdad
2 changed files with 11 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import fs from 'fs';
|
||||
import MysZZZApi from './mysapi.js';
|
||||
import YAML from 'yaml';
|
||||
import fetch from 'node-fetch';
|
||||
import request from '../utils/request.js';
|
||||
let User;
|
||||
try {
|
||||
User = (await import('../../xiaoyao-cvs-plugin/model/user.js')).default;
|
||||
|
|
@ -84,7 +84,7 @@ export const getAuthKey = async (e, _user, zzzUid, authAppid = 'csc') => {
|
|||
// 获取链接
|
||||
const { url, headers, body } = api.getUrl(type);
|
||||
// 发送请求
|
||||
let res = await fetch(url, {
|
||||
let res = await request(url, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body,
|
||||
|
|
|
|||
|
|
@ -131,12 +131,18 @@ export default class MysZZZApi extends MysApi {
|
|||
headers['x-rpc-device_id'] = data.deviceId;
|
||||
}
|
||||
// 如果有绑定设备信息,写入绑定设备信息,否则写入默认设备信息
|
||||
if (data?.deviceInfo && data?.modelName) {
|
||||
if (data?.deviceInfo && data?.modelName && data?.osVersion) {
|
||||
const osVersion = data.osVersion;
|
||||
const modelName = data.modelName;
|
||||
const deviceBrand = data.deviceInfo?.split('/')[0];
|
||||
const deviceDisplay = data.deviceInfo?.split('/')[3];
|
||||
try {
|
||||
headers['x-rpc-device_name'] = `${deviceBrand} ${data.modelName}`;
|
||||
headers['x-rpc-device_model'] = data.modelName;
|
||||
headers['x-rpc-device_name'] = `${deviceBrand} ${modelName}`;
|
||||
headers['x-rpc-device_model'] = modelName;
|
||||
headers['x-rpc-csm_source'] = 'myself';
|
||||
// 国际服不需要绑定设备,故写入的'User-Agent'为国服
|
||||
headers['User-Agent'] =
|
||||
`Mozilla/5.0 (Linux; Android ${osVersion}; ${modelName} Build/${deviceDisplay}; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.179 Mobile Safari/537.36 miHoYoBBS/2.73.1`;
|
||||
} catch (error) {
|
||||
logger.error(`[ZZZ]设备信息解析失败:${error.message}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue