refactor(ai): optimize AI action initialization and user state handling
This commit is contained in:
@@ -63,15 +63,17 @@ const formComponents = {
|
||||
|
||||
// 投票通知
|
||||
const voteUrl = "https://gitee.com/activity/2025opensource?ident=I6VXEH";
|
||||
// 保存通知实例,用于在组件卸载时关闭
|
||||
let notificationInstance: ReturnType<typeof ElNotification> | null = null;
|
||||
|
||||
// 显示投票通知
|
||||
const showVoteNotification = () => {
|
||||
ElNotification({
|
||||
notificationInstance = ElNotification({
|
||||
title: "⭐ Gitee 2025 开源评选 · 诚邀您的支持! 🙏",
|
||||
message: `我正在参加 Gitee 2025 最受欢迎的开源软件投票活动,快来给我投票吧!<br/><a href="${voteUrl}" target="_blank" style="color: var(--el-color-primary); text-decoration: none; font-weight: 500;">点击投票 →</a>`,
|
||||
type: "success",
|
||||
position: "bottom-right",
|
||||
duration: 0, // 不自动关闭
|
||||
duration: 0,
|
||||
dangerouslyUseHTMLString: true,
|
||||
});
|
||||
};
|
||||
@@ -82,6 +84,14 @@ onMounted(() => {
|
||||
showVoteNotification();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
// 组件卸载时关闭通知
|
||||
onBeforeUnmount(() => {
|
||||
if (notificationInstance) {
|
||||
notificationInstance.close();
|
||||
notificationInstance = null;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user