feat:设备号处理完成
This commit is contained in:
@@ -92,18 +92,12 @@ export const transferWechatFriends = async (sourceId: string | number, targetId:
|
||||
*/
|
||||
export const transformWechatAccount = (serverAccount: any): any => {
|
||||
// 从deviceInfo中提取设备信息
|
||||
let deviceId = '';
|
||||
let deviceName = '';
|
||||
|
||||
if (serverAccount.deviceInfo) {
|
||||
// 尝试解析设备信息字符串
|
||||
const deviceInfo = serverAccount.deviceInfo.split(' ');
|
||||
if (deviceInfo.length > 0) {
|
||||
// 提取数字部分作为设备ID,确保是整数
|
||||
const possibleId = deviceInfo[0].trim();
|
||||
// 验证是否为数字
|
||||
deviceId = /^\d+$/.test(possibleId) ? possibleId : '';
|
||||
|
||||
// 提取设备名称
|
||||
if (deviceInfo.length > 1) {
|
||||
deviceName = deviceInfo[1] ? deviceInfo[1].replace(/[()]/g, '').trim() : '';
|
||||
@@ -111,16 +105,7 @@ export const transformWechatAccount = (serverAccount: any): any => {
|
||||
}
|
||||
}
|
||||
|
||||
// 如果从deviceInfo无法获取有效的设备ID,使用imei作为备选
|
||||
if (!deviceId && serverAccount.imei) {
|
||||
deviceId = serverAccount.imei;
|
||||
}
|
||||
|
||||
// 如果仍然没有设备ID,使用微信账号的ID作为最后的备选
|
||||
if (!deviceId && serverAccount.id) {
|
||||
deviceId = serverAccount.id.toString();
|
||||
}
|
||||
|
||||
|
||||
// 如果没有设备名称,使用备用名称
|
||||
if (!deviceName) {
|
||||
deviceName = serverAccount.deviceMemo || '未命名设备';
|
||||
@@ -135,7 +120,7 @@ export const transformWechatAccount = (serverAccount: any): any => {
|
||||
avatar: serverAccount.avatar || '',
|
||||
nickname: serverAccount.nickname || serverAccount.accountNickname || '未命名',
|
||||
wechatId: serverAccount.wechatId || '',
|
||||
deviceId,
|
||||
deviceId: serverAccount.deviceId || '',
|
||||
deviceName,
|
||||
friendCount: serverAccount.totalFriend || 0,
|
||||
todayAdded,
|
||||
|
||||
Reference in New Issue
Block a user