feat: 游客登录机制完善

This commit is contained in:
binaryify
2024-04-30 15:14:32 +08:00
parent eb92cef0b2
commit 780f30f0b1
15 changed files with 24693 additions and 20 deletions

View File

@@ -29,4 +29,21 @@ module.exports = {
)
return random
},
generateRandomChineseIP() {
const chinaIPPrefixes = ['116.25', '116.76', '116.77', '116.78']
const randomPrefix =
chinaIPPrefixes[Math.floor(Math.random() * chinaIPPrefixes.length)]
return `${randomPrefix}.${generateIPSegment()}.${generateIPSegment()}}`
},
}
// 生成一个随机整数
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min
}
// 生成一个随机IP地址段
function generateIPSegment() {
return getRandomInt(1, 255)
}

View File

@@ -105,7 +105,7 @@ const createRequest = (method, url, data = {}, options) => {
const csrfToken = cookie['__csrf'] || ''
const header = {
osver: cookie.osver || '17.4.1', //系统版本
deviceId: cookie.deviceId || '', //encrypt.base64.encode(imei + '\t02:00:00:00:00:00\t5106025eb79a5247\t70ffbaac7')
deviceId: cookie.deviceId || global.deviceId,
appver: cookie.appver || iosAppVersion, // app版本
versioncode: cookie.versioncode || '140', //版本号
mobilename: cookie.mobilename || '', //设备model
@@ -113,7 +113,7 @@ const createRequest = (method, url, data = {}, options) => {
resolution: cookie.resolution || '1920x1080', //设备分辨率
__csrf: csrfToken,
os: cookie.os || 'ios',
channel: cookie.channel,
channel: cookie.channel || '',
requestId: `${Date.now()}_${Math.floor(Math.random() * 1000)
.toString()
.padStart(4, '0')}`,