chat文件预览报500bug

This commit is contained in:
runny committed 2026-05-30 15:26:01 +08:00
1 parent a148f76217
commit 7402621ded
3 files changed
+123 -14

No files matched your search

@@ -20,6 +20,7 @@ import '@vue-office/excel/lib/index.css';
interface PreviewFile {
name: string;
url: string;
actualExt?: string;
}
interface ExcelPreviewData {
@@ -69,6 +70,8 @@ const getExt = (raw: string) => {
};
const ext = computed(() => {
const actual = getExt(props.file?.actualExt || '');
if (actual) return actual;
// Display name extension has higher priority than URL.
const byName = getExt(props.file?.name || '');
if (byName) return byName;
@@ -385,6 +388,7 @@ const loadContent = async () => {
agent_id: String(props.agentId),
url: props.file.url,
name: props.file.name || '',
ext: ext.value || '',
});
const res = await fetch(`/api/chat/preview-text?${params.toString()}`, {
headers: props.authHeaders || {},
+6 -3
View File
@@ -1,4 +1,4 @@


<script setup lang="ts">
/**
@@ -186,6 +186,7 @@ interface SourceFileLink {
url?: string;
datasetId?: string;
remoteDocumentId?: string;
actualExt?: string;
}
// 源文件展示配置(来自 config.ts)
@@ -541,13 +542,14 @@ const shouldShowThinkingBubble = computed(() => {
});
const filePreviewVisible = ref(false);
const previewFile = ref<{ name: string; url: string } | null>(null);
const previewFile = ref<{ name: string; url: string; actualExt?: string } | null>(null);
const resolveSourceLink = async (file: SourceFileLink): Promise<{ name: string; url: string }> => {
const resolveSourceLink = async (file: SourceFileLink): Promise<{ name: string; url: string; actualExt?: string }> => {
if (file.url) {
return {
name: file.name,
url: file.url,
actualExt: file.actualExt,
};
}
if (!file.datasetId || !file.remoteDocumentId) {
@@ -576,6 +578,7 @@ const resolveSourceLink = async (file: SourceFileLink): Promise<{ name: string;
...file,
url: resolvedUrl,
name: data?.source_filename || file.name,
actualExt: String(data?.source_ext || '').trim().toLowerCase() || undefined,
};
};