Skip to content

Commit 0f5b46d

Browse files
committed
在前端处理,马赛克掉用户IP,保护用户信息
1 parent b49d484 commit 0f5b46d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/MainPage/analytics.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,18 @@
447447
userActionObject = data.userAction;
448448
449449
for(let i in userActionObject){
450-
if(JSON.stringify(userActionObject[i].location) === '[]'){
451-
userActionObject[i].location = '地球';
450+
// 保护用户隐私,马赛克掉ip最后一组数字
451+
let array = i.split('.'),
452+
currentIp = array[0] + '.' + array[1] + '.' + array[2] + '.***',
453+
item = userActionObject[i];
454+
455+
// 为用户IP打码
456+
userActionObject[currentIp] = item;
457+
delete userActionObject[i];
458+
459+
// 因为对象当前本来的属性名已经被删掉了,所以得修改新的属性名对应的属性值
460+
if(JSON.stringify(userActionObject[currentIp].location) === '[]'){
461+
userActionObject[currentIp].location = '地球';
452462
}
453463
}
454464

0 commit comments

Comments
 (0)