animeic-cloud 1 month ago
parent
commit
9bd4ffbfab
1 changed files with 19 additions and 1 deletions
  1. 19 1
      sku3d/sku3d/test/index.html

+ 19 - 1
sku3d/sku3d/test/index.html

@@ -113,6 +113,23 @@
             previewImageUrl(this.value, 'searchPreview');
         });
 
+        // 清理URL,移除可能的重复拼接
+        function cleanImageUrl(url) {
+            try {
+                // 如果URL包含我们的API endpoint,说明可能是重复拼接的
+                const apiEndpoint = `${baseUrl}/image/fassi/list?url=`;
+                if (url.includes(apiEndpoint)) {
+                    // 提取实际的图片URL
+                    const startIndex = url.lastIndexOf(apiEndpoint) + apiEndpoint.length;
+                    url = decodeURIComponent(url.substring(startIndex));
+                }
+                return url;
+            } catch (error) {
+                console.error('URL清理错误:', error);
+                return url;
+            }
+        }
+
         function previewImageUrl(url, previewId) {
             if (!url) return;
             const previewDiv = document.getElementById(previewId);
@@ -170,7 +187,8 @@
             }
 
             try {
-                const encodedUrl = encodeURIComponent(imageUrl);
+                const cleanedUrl = cleanImageUrl(imageUrl);
+                const encodedUrl = encodeURIComponent(cleanedUrl);
                 const response = await fetch(`${baseUrl}/image/fassi/list?url=${encodedUrl}`, {
                     method: 'GET',
                     headers: {