feat:设备号处理完成
This commit is contained in:
@@ -92,18 +92,12 @@ export const transferWechatFriends = async (sourceId: string | number, targetId:
|
|||||||
*/
|
*/
|
||||||
export const transformWechatAccount = (serverAccount: any): any => {
|
export const transformWechatAccount = (serverAccount: any): any => {
|
||||||
// 从deviceInfo中提取设备信息
|
// 从deviceInfo中提取设备信息
|
||||||
let deviceId = '';
|
|
||||||
let deviceName = '';
|
let deviceName = '';
|
||||||
|
|
||||||
if (serverAccount.deviceInfo) {
|
if (serverAccount.deviceInfo) {
|
||||||
// 尝试解析设备信息字符串
|
// 尝试解析设备信息字符串
|
||||||
const deviceInfo = serverAccount.deviceInfo.split(' ');
|
const deviceInfo = serverAccount.deviceInfo.split(' ');
|
||||||
if (deviceInfo.length > 0) {
|
if (deviceInfo.length > 0) {
|
||||||
// 提取数字部分作为设备ID,确保是整数
|
|
||||||
const possibleId = deviceInfo[0].trim();
|
|
||||||
// 验证是否为数字
|
|
||||||
deviceId = /^\d+$/.test(possibleId) ? possibleId : '';
|
|
||||||
|
|
||||||
// 提取设备名称
|
// 提取设备名称
|
||||||
if (deviceInfo.length > 1) {
|
if (deviceInfo.length > 1) {
|
||||||
deviceName = deviceInfo[1] ? deviceInfo[1].replace(/[()]/g, '').trim() : '';
|
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) {
|
if (!deviceName) {
|
||||||
deviceName = serverAccount.deviceMemo || '未命名设备';
|
deviceName = serverAccount.deviceMemo || '未命名设备';
|
||||||
@@ -135,7 +120,7 @@ export const transformWechatAccount = (serverAccount: any): any => {
|
|||||||
avatar: serverAccount.avatar || '',
|
avatar: serverAccount.avatar || '',
|
||||||
nickname: serverAccount.nickname || serverAccount.accountNickname || '未命名',
|
nickname: serverAccount.nickname || serverAccount.accountNickname || '未命名',
|
||||||
wechatId: serverAccount.wechatId || '',
|
wechatId: serverAccount.wechatId || '',
|
||||||
deviceId,
|
deviceId: serverAccount.deviceId || '',
|
||||||
deviceName,
|
deviceName,
|
||||||
friendCount: serverAccount.totalFriend || 0,
|
friendCount: serverAccount.totalFriend || 0,
|
||||||
todayAdded,
|
todayAdded,
|
||||||
|
|||||||
Reference in New Issue
Block a user