fix(editor): 修复@提及列表显示逻辑和全体成员选项

修复@提及列表中全体成员选项的显示逻辑,不再需要管理员权限即可显示。同时优化点击事件处理,当点击非@提及列表区域时自动隐藏列表。

feat(message): 增加文件预览类型检查和样式优化

添加文件类型预览支持检查,仅允许预览PDF、Excel、Word和PPT文件。优化文件消息的悬停样式,提升用户体验。
This commit is contained in:
Phoenix 2025-06-20 10:09:54 +08:00
parent b28c288665
commit db8621ec5c
2 changed files with 39 additions and 15 deletions

View File

@ -286,14 +286,9 @@ const showMentionList = () => {
// //
const query = currentMentionQuery.value.toLowerCase() const query = currentMentionQuery.value.toLowerCase()
// //
mentionList.value = props.members.filter(member => { mentionList.value = [{ id: 0, nickname: '全体成员', avatar: defAvatar, value: '全体成员' },...props.members].filter(member => {
return member.value.toLowerCase().startsWith(query) && member.id !== userStore.uid return member.value.toLowerCase().startsWith(query) && member.id !== userStore.uid
}) })
console.log('userStore',userStore.uid)
// ""
if(dialogueStore.groupInfo.is_manager){
mentionList.value.unshift({ id: 0, nickname: '全体成员', avatar: defAvatar, value: '全体成员' })
}
// //
showMention.value = mentionList.value.length > 0 showMention.value = mentionList.value.length > 0
// //
@ -2155,7 +2150,7 @@ const onVoteSubmit = (data) => {
/** /**
* 处理编辑器点击事件 * 处理编辑器点击事件
* 主要用于处理引用元素的关闭按钮点击 * 用于处理引用元素的关闭按钮点击和隐藏@提及列表
* *
* @param {Event} event - 点击事件对象 * @param {Event} event - 点击事件对象
*/ */
@ -2181,6 +2176,14 @@ const handleEditorClick = (event) => {
event.stopPropagation(); event.stopPropagation();
} }
} }
// @
const isMentionListClick = event.target.closest('.mention-list');
// @@@
if (showMention.value && !isMentionListClick) {
hideMentionList();
}
}; };
</script> </script>

View File

@ -62,6 +62,15 @@ const fileInfo = computed(() => {
return fileTypes[extension] || fileTypes.DEFAULT return fileTypes[extension] || fileTypes.DEFAULT
}) })
//
const canPreview = computed(() => {
const extension = getFileExtension(props.extra.path)
return extension === 'PDF' ||
EXCEL_EXTENSIONS.includes(extension) ||
WORD_EXTENSIONS.includes(extension) ||
PPT_EXTENSIONS.includes(extension)
})
// //
function getFileExtension(filepath) { function getFileExtension(filepath) {
const parts = filepath?.split('.') const parts = filepath?.split('.')
@ -86,15 +95,20 @@ const strokeDashoffset = computed(() =>
// //
const handleClick = () => { const handleClick = () => {
//
if(!props.extra.is_uploading) { if(!props.extra.is_uploading) {
if(canPreview.value){
window.open( window.open(
`${import.meta.env.VITE_PAGE_URL}/office?url=${props.extra.path}`, `${import.meta.env.VITE_PAGE_URL}/office?url=${props.extra.path}`,
'_blank', '_blank',
'width=1200,height=900,left=200,top=200,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no' 'width=1200,height=900,left=200,top=200,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no'
); );
}else{
window['$message'].warning('暂不支持在线预览该类型文件')
} }
} }
}
function downloadFileWithProgress(resourceUrl, filename) { function downloadFileWithProgress(resourceUrl, filename) {
const iframe = document.createElement('iframe'); const iframe = document.createElement('iframe');
@ -114,7 +128,7 @@ const handleDownload = () => {
</script> </script>
<template> <template>
<div class="file-message flex flex-col" @click="handleClick"> <div class="file-message flex flex-col can-preview" @click="handleClick">
<!-- 文件头部信息 --> <!-- 文件头部信息 -->
<div class="file-header"> <div class="file-header">
<!-- 文件名 --> <!-- 文件名 -->
@ -184,7 +198,14 @@ const handleDownload = () => {
border-radius: 8px; border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
padding: 0 14px; padding: 0 14px;
}
.can-preview {
cursor: pointer; cursor: pointer;
&:hover {
background-color: #f9f9f9;
}
} }
.file-header { .file-header {