文本聊天已完成
This commit is contained in:
@@ -529,6 +529,12 @@
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// 头像颜色
|
||||
const AVATAR_COLORS = [
|
||||
'#6a55fa', '#f87171', '#4ade80', '#fbbf24',
|
||||
'#60a5fa', '#c084fc', '#fb923c', '#34d399'
|
||||
];
|
||||
|
||||
// 用户登录
|
||||
loginForm.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
@@ -551,6 +557,7 @@
|
||||
id: res.result.user_info.id,
|
||||
username: res.result.user_info.username,
|
||||
name: res.result.user_info.nick_name,
|
||||
avatarColor: res.result.user_info.avatar,
|
||||
loginTime: new Date().toISOString()
|
||||
}));
|
||||
sessionStorage.setItem('token', res.result.token);
|
||||
@@ -594,9 +601,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const colorIndex = Math.floor(Math.random() * AVATAR_COLORS.length);
|
||||
let avatarColor = AVATAR_COLORS[colorIndex];
|
||||
axios.post('/api/auth/register', {
|
||||
username,
|
||||
password,
|
||||
avatar: avatarColor,
|
||||
nickname: registerNickname
|
||||
}).then(response => {
|
||||
console.log(response);
|
||||
|
||||
Reference in New Issue
Block a user