优化文件消息组件的下载逻辑,新增群组信息获取功能,调整对话存储以支持群组信息
This commit is contained in:
parent
89f707a031
commit
db599dadb9
@ -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;
|
||||
|
BIN
src/assets/image/zu6146@2x.png
Normal file
BIN
src/assets/image/zu6146@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
@ -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>
|
||||
|
||||
|
@ -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 排序,保证消息一致性
|
||||
|
@ -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;
|
||||
};
|
@ -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%;
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -39,5 +39,5 @@
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.vue",
|
||||
"assets/**/*.jpg"
|
||||
],
|
||||
, "src/store/modules/dialogue.js" ],
|
||||
}
|
Loading…
Reference in New Issue
Block a user