Commit
·
290da9f
1
Parent(s):
57a2f48
Fix image path in LLM answers
Browse files- frontend/main.js +8 -1
frontend/main.js
CHANGED
|
@@ -266,7 +266,14 @@ class MultimodalAssistant {
|
|
| 266 |
// Pattern: 
|
| 267 |
formattedContent = formattedContent.replace(
|
| 268 |
/!\[(.*?)\]\((.*?)\)/g,
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
);
|
| 271 |
|
| 272 |
if (answerContent) answerContent.innerHTML = formattedContent;
|
|
|
|
| 266 |
// Pattern: 
|
| 267 |
formattedContent = formattedContent.replace(
|
| 268 |
/!\[(.*?)\]\((.*?)\)/g,
|
| 269 |
+
(match, alt, url) => {
|
| 270 |
+
// 如果是 images/ 开头的路径,转换为 /product_images/
|
| 271 |
+
let correctedUrl = url;
|
| 272 |
+
if (url.startsWith('images/')) {
|
| 273 |
+
correctedUrl = url.replace('images/', '/product_images/');
|
| 274 |
+
}
|
| 275 |
+
return `<br><img src="${correctedUrl}" alt="${alt}" class="max-w-md rounded-lg shadow-md my-4" onerror="this.src='https://via.placeholder.com/300?text=Image+Not+Found'" /><br>`;
|
| 276 |
+
}
|
| 277 |
);
|
| 278 |
|
| 279 |
if (answerContent) answerContent.innerHTML = formattedContent;
|