Quellcode durchsuchen

fix: 修复下载链接异常的问题

zhupei@smartai.com vor 1 Jahr
Ursprung
Commit
77d31ab28e

+ 15 - 4
src/modules/conversation-dialog/format-dialog-answer-custom-markdown-str.js

@@ -93,6 +93,15 @@ export function formatRefferenceFlag(answer) {
   return cur_text;
 }
 
+export function formatFileDownloadUrl(url) {
+  let real_url = url.replace('//', '/');
+  real_url = real_url.replace('/./', '/');
+  real_url = real_url.replace('./', '/');
+  real_url = formatStaticAssetsUrl(real_url);
+
+  return real_url;
+}
+
 /**
  * 处理文件下载链接
  * @param {string} file_name
@@ -104,10 +113,12 @@ export function formatFileDownloadStr(file_name, file_url, file_id) {
     return '';
   }
 
-  let real_url = file_url.replace('//', '/');
-  real_url = file_url.replace('/./', '/');
-  real_url = file_url.replace('./', '/');
-  real_url = formatStaticAssetsUrl(real_url);
+  // let real_url = file_url.replace('//', '/');
+  // real_url = file_url.replace('/./', '/');
+  // real_url = file_url.replace('./', '/');
+  // real_url = formatStaticAssetsUrl(real_url);
+
+  const real_url = formatFileDownloadUrl(file_url);
 
   // const token = kuky_Authorization.get();
   // real_url = useAttachQueryValue(real_url, 'token', token);

+ 4 - 1
src/modules/file-preview/FileItemDocDownload.vue

@@ -23,6 +23,8 @@ import FileIcon from '../file-icon/FileIcon.vue';
 
 import { getFileSuffix } from '../../utils/file-utils';
 
+import { formatFileDownloadUrl } from '../conversation-dialog/format-dialog-answer-custom-markdown-str';
+
 const props = defineProps({
   file: Object
   // enable_remove: Boolean
@@ -82,7 +84,8 @@ const file_end_fix = computed(() => {
  */
 const handleFileDownload = () => {
   if (props.file.file_url) {
-    window.open(props.file.file_url, '_blank');
+    const url = formatFileDownloadUrl(props.file.file_url);
+    window.open(url, '_blank');
   }
 };