From c144c39d9f3f86e1b52ae4247f8322f6396a4320 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期二, 11 三月 2025 13:39:25 +0800
Subject: [PATCH] 查看文件内容

---
 src/components/chat/user/index.vue |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/components/chat/user/index.vue b/src/components/chat/user/index.vue
index 766545f..87d7a4b 100644
--- a/src/components/chat/user/index.vue
+++ b/src/components/chat/user/index.vue
@@ -10,9 +10,8 @@
 							<div
 								v-for="(item, index) in msg.attachList"
 								:key="index"
-								class="flex items-center gap-2 bg-[#e9e9e9] px-2 py-3 rounded-lg w-[220px] relative group"
+								class="flex items-center gap-2 bg-[#e9e9e9] px-2 py-3 rounded-lg w-[220px] relative group cursor-pointer"
 								@click="openAttachPreview(item)"
-								:class="{ 'cursor-pointer': item.type === 'table' }"
 							>
 								<template v-if="item.type === 'file'">
 									<el-image
@@ -183,8 +182,9 @@
 const attachPreviewIsShow = ref(false);
 const attachPreviewData = ref<Attach>();
 const openAttachPreview = (item: Attach) => {
-	if (item.type === 'file') return;
-	if (item.type === 'table') {
+	if (item.type === 'file') {
+		openFileContent(item);
+	} else if (item.type === 'table') {
 		attachPreviewIsShow.value = true;
 		attachPreviewData.value = item;
 	} else if (item.type === 'metric') {
@@ -200,6 +200,15 @@
 };
 //#endregion
 
+//#region ====================== 鏌ョ湅鏂囦欢鏂囨湰鍐呭 ======================
+const openFileContent = (item: Attach) => {
+	emitter.emit('setFileContent', {
+		title: item.title,
+		content: item.model?.file_content ?? '',
+	});
+};
+//#endregion
+
 //#region ====================== 闄勪欢涓嬭浇 ======================
 const downloadAttach = async (item: Attach) => {
 	const fileId = item.model?.file_id;

--
Gitblit v1.9.3