Przeglądaj źródła

Update index.html

修复镜像描述中带单,引号导致字符串意外终止的问题,
rex7036 5 miesięcy temu
rodzic
commit
100b5f651f
1 zmienionych plików z 6 dodań i 4 usunięć
  1. 6 4
      hubcmdui/web/index.html

+ 6 - 4
hubcmdui/web/index.html

@@ -774,10 +774,11 @@
                 </div>
                 <p class="result-description">${description}</p>
                 <div class="result-actions">
-                    <button class="action-btn primary" onclick="useImage('${result.name || result.repo_name}')">
+                    <button class="action-btn primary" onclick="useImage('${(result.name || result.repo_name).replace(/'/g, "\\'")}')">
                         <i class="fas fa-rocket"></i> 使用此镜像
                     </button>
-                    <button class="action-btn secondary" onclick="viewImageDetails('${result.name || result.repo_name}', ${isOfficial}, '${encodeURIComponent(description)}', ${result.star_count || 0}, ${result.pull_count || 0})">
+                    <button class="action-btn secondary" onclick="viewImageDetails('${(result.name || result.repo_name).replace(/'/g, "\\'")}', ${isOfficial}, '${encodeURIComponent(description).replace(/'/g, "%2
+7")}', ${result.star_count || 0}, ${result.pull_count || 0})">
                         <i class="fas fa-tags"></i> 查看标签
                     </button>
                 </div>
@@ -884,7 +885,8 @@
                         <div class="error-message">
                             <i class="fas fa-exclamation-circle"></i>
                             <p>加载镜像详情失败: ${error.message}</p>
-                            <button onclick="viewImageDetails('${currentImageData.name}', ${currentImageData.isOfficial}, '${encodeURIComponent(currentImageData.description)}', ${currentImageData.stars}, ${currentImageData.pulls})" class="retry-btn">
+                            <button onclick="viewImageDetails('${currentImageData.name.replace(/'/g, "\\'")}', ${currentImageData.isOfficial}, '${encodeURIComponent(currentImageData.description).replace(/'/g, "%
+27")}', ${currentImageData.stars}, ${currentImageData.pulls})" class="retry-btn">
                                 <i class="fas fa-redo"></i> 重试
                             </button>
                         </div>
@@ -1788,4 +1790,4 @@
     </script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/2.0.3/marked.min.js"></script>
 </body>
-</html>
+</html>