优化文件消息组件的下载逻辑,新增群组信息获取功能,调整对话存储以支持群组信息

This commit is contained in:
Phoenix 2025-05-22 15:07:27 +08:00
parent 89f707a031
commit db599dadb9
10 changed files with 62 additions and 61 deletions

View File

@ -4,6 +4,9 @@
color: #fff!important;
}
.n-checkbox-box-wrapper .n-checkbox-box{
border-radius: 50%;
}
/*表格头多选框颜色调整避免和表头颜色冲突*/
.n-data-table-thead .n-data-table-tr .n-checkbox-box{
background: #fff;

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -87,61 +87,28 @@ const strokeDashoffset = computed(() =>
//
const handleClick = () => {
console.log('handleClick')
window.open(
`${window.location.origin}/office?url=${props.extra.path}`,
'_blank',
'width=1200,height=900,left=200,top=200,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no'
);
}
/**
* 触发浏览器下载文件通常会显示下载进度
* @param {string} resourceUrl 文件的URL地址
* @param {string} [filename] 可选参数指定下载文件的名称如果未提供浏览器会尝试从URL或响应头中推断
*/
function downloadFileWithProgress(resourceUrl, filename) {
// 1. <a>
const link = document.createElement('a');
// 2. href URL
link.href = resourceUrl;
// 3. download
// filename使
// download
if (filename) {
link.download = filename;
} else {
// download resourceUrl
// : link.download = resourceUrl.substring(resourceUrl.lastIndexOf('/') + 1);
// Content-Disposition
link.download = ''; //
}
// 4. <a>
document.body.appendChild(link);
// 5.
link.click();
// 6. <a>
document.body.removeChild(link);
console.log(`已为 "${resourceUrl}" 发起下载请求。`);
const iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = resourceUrl;
document.body.appendChild(iframe);
setTimeout(() => {
document.body.removeChild(iframe);
}, 60000);
}
//
const handleDownload = () => {
downloadFileWithProgress(props.extra.path,props.extra.name)
// const url = props.extra.path;
// if (!url) return;
// const a = document.createElement('a');
// a.href = url;
// a.download = url.split('/').pop() || 'download';
// document.body.appendChild(a);
// a.click();
// document.body.removeChild(a);
console.log('data',props.data)
}
</script>

View File

@ -5,9 +5,8 @@ import {
ServePublishMessage,
ServeCollectEmoticon
} from '@/api/chat'
import { ServeGetGroupMembers } from '@/api/group'
import { ServeGetGroupMembers,ServeGroupDetail } from '@/api/group.js'
import { useEditorStore } from './editor'
// 键盘消息事件定时器
let keyboardTimeout = null
@ -46,7 +45,7 @@ export const useDialogueStore = defineStore('dialogue', {
// 是否显示会话列表
isShowSessionList: true,
groupInfo: {} ,
// 群成员列表
members: [],
@ -75,8 +74,6 @@ export const useDialogueStore = defineStore('dialogue', {
// 更新对话信息
setDialogue(data = {}) {
console.log('data',data)
this.online = data.is_online == 1
this.talk = {
username: data.remark || data.name,
@ -94,6 +91,8 @@ export const useDialogueStore = defineStore('dialogue', {
this.members = []
if (data.talk_type == 2) {
this.updateGroupMembers()
this.getGroupInfo()
}
},
@ -126,7 +125,14 @@ export const useDialogueStore = defineStore('dialogue', {
unshiftDialogueRecord(records) {
this.records.unshift(...records)
},
async getGroupInfo(){
const { code, data } = await ServeGroupDetail({
group_id: this.talk.receiver_id
})
if(code == 200){
this.groupInfo = data
}
},
// 推送对话记录
addDialogueRecord(record) {
// TOOD 需要通过 sequence 排序,保证消息一致性

View File

@ -130,3 +130,22 @@ export interface ITalkRecordExtraImage {
width: number
height: number
}
export interface GroupInfo {
avatar: string;
created_at: string;
deptInfos: any[]; // 如果有具体结构可以进一步细化
group_id: number;
group_name: string;
group_num: number;
group_type: number;
is_disturb: number;
is_last_manager: boolean;
is_manager: boolean;
is_mute: number;
is_overt: number;
latest_notice_content: string;
latest_notice_title: string;
positionInfos: any[]; // 如果有具体结构可以进一步细化
profile: string;
visit_card: string;
};

View File

@ -1,8 +1,8 @@
<template>
<div class="amicable flex-center">
<div class="content">
<img src="@/assets/image/welcome.svg" alt="" />
<p>IM 欢迎您 (*^__^*)</p>
<img class="w-181px h-149px" src="@/assets/image/zu6146@2x.png" alt="" />
<p class="text-#999999 text-14px">开启你的聊天之旅</p>
</div>
</div>
</template>
@ -13,8 +13,8 @@
width: 100%;
-webkit-app-region: drag;
.content {
width: 400px;
height: 300px;
width: 181px;
height: 149px;
text-align: center;
color: #ccc;
margin-top: -10%;

View File

@ -227,6 +227,7 @@ const onClickNickname = (data: ITalkRecord) => {
//
const onContextMenu = (e: any, item: ITalkRecord) => {
console.log('item',item)
if (!dialogueStore.isShowEditor || dialogueStore.isOpenMultiSelect) {
return e.preventDefault()
}

View File

@ -1,4 +1,5 @@
import { reactive } from 'vue'
import { useDialogueStore } from '@/store/modules/dialogue.js'
interface IDropdown {
options: any[]
@ -19,7 +20,7 @@ const isRevoke = (uid: any, item: any): boolean => {
return Math.floor(time / 1000 / 60) <= 2
}
const dialogueStore = useDialogueStore()
export function useMenu() {
const dropdown: IDropdown = reactive({
options: [],
@ -47,20 +48,20 @@ export function useMenu() {
dropdown.options.push({ label: '多选', key: 'multiSelect' })
dropdown.options.push({ label: '引用', key: 'quote' })
if (isRevoke(uid, item)) {
if (isRevoke(uid, item)|| (dialogueStore.groupInfo as any).is_manager) {
dropdown.options.push({ label: `撤回`, key: 'revoke' })
}
dropdown.options.push({ label: '删除', key: 'delete' })
if ([3, 4, 5].includes(item.msg_type)) {
dropdown.options.push({ label: '下载', key: 'download' })
}
// if ([3, 4, 5].includes(item.msg_type)) {
// dropdown.options.push({ label: '下载', key: 'download' })
// }
if ([3].includes(item.msg_type)) {
dropdown.options.push({ label: '收藏', key: 'collect' })
}
// if ([3].includes(item.msg_type)) {
// dropdown.options.push({ label: '收藏', key: 'collect' })
// }
dropdown.x = e.clientX

View File

@ -57,6 +57,7 @@ const config = {
},
documentType,
editorConfig: {
mode: 'view',
lang: 'zh-CN',
user: {
@ -64,6 +65,9 @@ const config = {
name: '访客用户'
},
customization: {
hideRightMenu: true, //
about: false, //
help: false, //
chat: false,
commentAuthorOnly: false,
compactToolbar: true,

View File

@ -39,5 +39,5 @@
"src/**/*.tsx",
"src/**/*.vue",
"assets/**/*.jpg"
],
, "src/store/modules/dialogue.js" ],
}