优化代码
This commit is contained in:
@@ -397,12 +397,32 @@ const chatList = ref({
|
||||
//监听会话消息
|
||||
function onConversationsUpdated(conversations) {
|
||||
chatList.value = conversations;
|
||||
if (chatList.value.unreadTotal != 0) {
|
||||
initNotification();
|
||||
}
|
||||
}
|
||||
//谷歌通知提醒
|
||||
function initNotification() {
|
||||
if (Notification.permission !== "granted") {
|
||||
Notification.requestPermission().then(showNotification);
|
||||
} else {
|
||||
showNotification();
|
||||
}
|
||||
}
|
||||
|
||||
function showNotification() {
|
||||
new Notification("新消息到达", {
|
||||
body: "您有 "+ chatList.value.unreadTotal +" 封未读消息",
|
||||
lang: "zh-CN", // 语言
|
||||
// onClick: () => window.location.href = "/nav/Message",
|
||||
});
|
||||
}
|
||||
|
||||
//获取会话列表
|
||||
function getChatList() {
|
||||
goEasyGetConversations().then((res) => {
|
||||
chatList.value = res.content;
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
//重发邮箱验证
|
||||
@@ -416,7 +436,7 @@ function ResendEmail() {
|
||||
}).then(res => {
|
||||
isResendEmail.value = 1;
|
||||
setInterval(startCountdown, 1000);
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
//修改新邮箱
|
||||
@@ -442,7 +462,7 @@ function changeEmail() {
|
||||
ElMessage.success("修改成功,请至新邮箱中验证邮箱");
|
||||
emailVisible.value = false;
|
||||
UserInfo();
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
//获取验证码
|
||||
@@ -456,7 +476,7 @@ function sendEmail() {
|
||||
}).then(res => {
|
||||
isSendEmail.value = 1;
|
||||
setInterval(startCountdown, 1000);
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
function startCountdown() {
|
||||
@@ -516,7 +536,7 @@ function changePassword() {
|
||||
}).then(res => {
|
||||
passwordVisible.value = false;
|
||||
ElMessage.success("修改成功");
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
//修改昵称
|
||||
function handleNickNameChange() {
|
||||
@@ -527,7 +547,7 @@ function handleNickNameChange() {
|
||||
setStorage("user", res);
|
||||
ElMessage.success("修改成功");
|
||||
UserInfo();
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
// 上传头像
|
||||
const headers = {
|
||||
@@ -545,7 +565,7 @@ const handleAvatarSuccess = (
|
||||
setStorage("user", res);
|
||||
ElMessage.success("修改成功");
|
||||
UserInfo();
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
const beforeAvatarUpload = (rawFile) => {
|
||||
@@ -671,7 +691,7 @@ function getAnchorLibrary() {
|
||||
}
|
||||
).then(res => {
|
||||
anchorLibrary.value = res;
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
//侧边导航
|
||||
@@ -716,8 +736,8 @@ function popoverClick(id) {
|
||||
clearStorage("user")
|
||||
clearStorage("token")
|
||||
clearStorage("activeId")
|
||||
})
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -727,7 +747,7 @@ function setsignIn() {
|
||||
userId: info.value.id,
|
||||
}).then(res => {
|
||||
ElMessage.success("签到成功");
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
//获取用户数据
|
||||
@@ -743,7 +763,7 @@ function UserInfo() {
|
||||
if (info.value.mailVerification == 1) {
|
||||
ElMessage.error("邮箱未验证,请至设置验证邮箱,如果已经验证请刷新页面");
|
||||
}
|
||||
});
|
||||
}).catch((err) => {});
|
||||
}
|
||||
|
||||
const refname = ref('');
|
||||
@@ -754,13 +774,13 @@ watch(refname, async (newQuestion, oldQuestion) => {
|
||||
onMounted(() => {
|
||||
getPromiseStorage('activeId').then(res => {
|
||||
activeId.value = res || 1;
|
||||
});
|
||||
}).catch((err) => {});
|
||||
getPromiseStorage('user').then(res => {
|
||||
info.value = res;
|
||||
avatar.value = info.value.headerIcon;
|
||||
getAnchorLibrary()
|
||||
UserInfo();
|
||||
});
|
||||
}).catch((err) => {});
|
||||
|
||||
setTimeout(() => {
|
||||
getChatList();
|
||||
|
||||
Reference in New Issue
Block a user