From def8b100051efb47c47d8d7f27ee618d9a5730bd Mon Sep 17 00:00:00 2001 From: ysn <2126564605@qq.com> Date: Wed, 3 Jun 2026 14:06:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93-=E5=88=86=E4=BA=AB-?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/knowledge/index.vue | 113 +++++---- .../message/components/CreateGroupDialog.vue | 231 +++++------------- 2 files changed, 127 insertions(+), 217 deletions(-) diff --git a/src/views/knowledge/index.vue b/src/views/knowledge/index.vue index b894f94..7e4d721 100644 --- a/src/views/knowledge/index.vue +++ b/src/views/knowledge/index.vue @@ -276,7 +276,7 @@ {}); }, - handleShare(row) { this.shareItem = row; - this.shareDialogVisible = true; + this.$refs.createGroupDialogRef.show(); }, handleShareToContacts(selectedMembers) { + console.log("选中的成员:", selectedMembers, this.userInfo); if (selectedMembers && selectedMembers.length > 0) { - const { id, netConfig } = this.$store.state.user; - const currentUserId = id; - const minioEndpoint = - netConfig?.MINIO_ENDPOINT_HTTPS?.trim() || "http://47.92.6.51:9100/"; - selectedMembers.forEach((shareTarget) => { - const payloadContent = { - file_name: this.shareItem?.title || "", - file_path: this.shareItem?.file_path || "", - file_size: this.shareItem?.file_size || "", - file_time: this.shareItem?.create_time || "", - knowledge_id: this.shareItem?.id || 0, - thumbnail_path: this.shareItem?.thumbnail_path || "", - }; - const messageData = { - client_id: `utalk-client-${currentUserId}`, - message: { - at_users: [], - message_id: 0, - payload: { - content: JSON.stringify(payloadContent), - file_duration: 0, - file_ico: "", - file_name: this.shareItem?.title || "", - file_path: this.shareItem?.file_path || "", - file_size: this.shareItem?.file_size || "", - file_type: this.shareItem?.file_type || "", - }, - scene: 1, - source_id: currentUserId, - target_id: shareTarget.id, - timestamp: 0, - type: MessageType.KNOWLEDGE_SHAREs, + postMessagePushToUser({ + client_id: "utalk-client-" + this.userInfo.id, + message: { + at_users: [], + message_id: 0, + payload: { + content: JSON.stringify({ + file_name: this.shareItem.file_name, + file_path: this.shareItem.file_path, + file_size: this.shareItem.file_size, + knowledge_id: this.shareItem.id, + thumbnail_path: this.shareItem.thumbnail_path, + file_time: this.shareItem.file_time, + }), + file_duration: 0, + file_ico: "", + file_name: this.shareItem.file_name, + file_path: this.shareItem.file_path, + file_size: this.shareItem.file_size, + file_type: this.shareItem.file_type, }, - target_id: shareTarget.id, - topic: "/user/", - }; - postMessagePushToUser(messageData).then((res) => { - this.$modal.msgSuccess(`已分享给 ${shareTarget.name}`); - }); + scene: 1, + source_id: this.userInfo.id, + target_id: selectedMembers[0].id, + timestamp: 0, + type: "knowledge_share", + }, + target_id: selectedMembers[0].id, + topic: "/user/¯", + }).then((res) => { + this.$modal.msgSuccess(`已分享给 ${selectedMembers[0].name}`); }); - this.shareDialogVisible = false; this.shareItem = null; } @@ -744,7 +735,13 @@ export default { } }, // 保存知识库记录到业务数据库 - async saveKnowledgeToDB(filePath, file, thumbnailPath = "", bucket = "", recordId = null) { + async saveKnowledgeToDB( + filePath, + file, + thumbnailPath = "", + bucket = "", + recordId = null + ) { console.log("saveKnowledgeToDB:", filePath, file, thumbnailPath, bucket); // 构建完整的文件路径(bucket/object 格式) @@ -772,7 +769,9 @@ export default { console.log("知识库记录保存成功"); // 更新上传记录为成功状态,保存完整的可预览路径 if (recordId) { - const minioEndpoint = this.$store.state.user.netConfig?.MINIO_ENDPOINT_HTTPS?.trim() || "http://47.92.6.51:9100/"; + const minioEndpoint = + this.$store.state.user.netConfig?.MINIO_ENDPOINT_HTTPS?.trim() || + "http://47.92.6.51:9100/"; const fileUrl = minioEndpoint + fullFilePath; this.updateTransferRecord(recordId, true, fileUrl); } @@ -784,10 +783,11 @@ export default { // 获取现有记录 const existingData = localStorage.getItem(STORAGE_KEY); const records = existingData ? JSON.parse(existingData) : []; - + // 生成唯一记录 ID - const recordId = Date.now() + "_" + Math.random().toString(36).substr(2, 9); - + const recordId = + Date.now() + "_" + Math.random().toString(36).substr(2, 9); + // 创建新记录(transfer_type: 3 表示上传) const newRecord = { id: recordId, @@ -799,10 +799,10 @@ export default { is_uploading: true, // 正在上传中 file_url: "", }; - + // 添加到记录数组 records.unshift(newRecord); - + // 保存回 localStorage localStorage.setItem(STORAGE_KEY, JSON.stringify(records)); console.log("上传记录已创建:", newRecord); @@ -819,16 +819,18 @@ export default { // 获取现有记录 const existingData = localStorage.getItem(STORAGE_KEY); const records = existingData ? JSON.parse(existingData) : []; - + // 查找并更新记录 - const recordIndex = records.findIndex(record => record.id === recordId); + const recordIndex = records.findIndex( + (record) => record.id === recordId + ); if (recordIndex !== -1) { records[recordIndex].is_success = isSuccess; records[recordIndex].is_uploading = false; // 上传完成,不再是上传中 if (fileUrl) { records[recordIndex].file_url = fileUrl; } - + // 保存回 localStorage localStorage.setItem(STORAGE_KEY, JSON.stringify(records)); console.log("上传记录已更新:", records[recordIndex]); @@ -847,12 +849,14 @@ export default { display: flex; justify-content: space-between; align-items: center; + .left { display: flex; align-items: center; gap: 8px; } } + // 资源缩略图 .resource-thumb { width: 230px; @@ -873,6 +877,7 @@ export default { display: flex; justify-content: space-around; padding: 20px 0; + .type-item { width: 120px; height: 120px; @@ -883,11 +888,13 @@ export default { align-items: center; justify-content: center; cursor: pointer; + i { font-size: 40px; color: #409eff; margin-bottom: 10px; } + &:hover { border-color: #409eff; background: #f5f7fa; diff --git a/src/views/message/components/CreateGroupDialog.vue b/src/views/message/components/CreateGroupDialog.vue index 5663b67..e2d3eba 100644 --- a/src/views/message/components/CreateGroupDialog.vue +++ b/src/views/message/components/CreateGroupDialog.vue @@ -1,62 +1,35 @@