Explorar el Código

6.16 分享h5页面不展示 【图片】

lxr hace 9 horas
padre
commit
dd7f3451ca
Se han modificado 1 ficheros con 20 adiciones y 4 borrados
  1. 20 4
      HBuilderProjects/shareAiKfChat.html

+ 20 - 4
HBuilderProjects/shareAiKfChat.html

@@ -467,6 +467,17 @@
       var AI_KF_CS_CONVERSATION_API =
         "https://prod.ailien.shop/ai/life-manager/api/v1/udian-cs-conversation/history/conversation";
 
+      /** 仅发图时的默认提示,分享页不展示 */
+      var IMAGE_ONLY_DEFAULT_PROMPT = "请帮我看看这些图片";
+
+      function isImageOnlyPlaceholderText(text) {
+        var t = String(text || "").trim();
+        if (!t) return true;
+        if (t === IMAGE_ONLY_DEFAULT_PROMPT) return true;
+        if (t === "[图片]" || t === "【图片】" || t === "[图]" || t === "【图】") return true;
+        return false;
+      }
+
       var sharePayloadCache = null;
       var weChatJssdkConfigured = false;
       var wxConfigSignRetriedBaseUrl = false;
@@ -931,7 +942,11 @@
         for (var i = 0; i < list.length; i++) {
           var m = list[i];
           if (!m || m.role !== "user") continue;
-          if (m.isImage) return "[图片]";
+          if (m.isImage) {
+            var imgText = String(m.content || "").trim();
+            if (imgText && !isImageOnlyPlaceholderText(imgText)) return imgText;
+            continue;
+          }
           var t = String(m.content || "").trim();
           if (t) return t;
         }
@@ -984,7 +999,7 @@
                 buildUserBubbleImagesHtml(imageUrls) +
                 "</div></div>";
               var imageUserText = String(msg.content || "").trim();
-              if (imageUserText) {
+              if (imageUserText && !isImageOnlyPlaceholderText(imageUserText)) {
                 html +=
                   '<div class="row row--user"><div class="user-bubble">' +
                   escHtml(imageUserText) +
@@ -993,7 +1008,7 @@
               continue;
             }
             var userText = String(msg.content || "").trim();
-            if (!userText) continue;
+            if (!userText || isImageOnlyPlaceholderText(userText)) continue;
             html +=
               '<div class="row row--user"><div class="user-bubble">' +
               escHtml(userText) +
@@ -1052,7 +1067,8 @@
               count += 1;
               continue;
             }
-            if (String(msg.content || "").trim()) count += 1;
+            var userContent = String(msg.content || "").trim();
+            if (userContent && !isImageOnlyPlaceholderText(userContent)) count += 1;
             continue;
           }
           if (msg.role === "ai" || msg.role === "assistant") {