Browse Source

fleat: update mp4

igb 13 hours ago
parent
commit
cb7a8ae4b9
2 changed files with 41 additions and 3 deletions
  1. 40 2
      usr/themes/beardocs/archive.php
  2. 1 1
      usr/themes/beardocs/header.php

+ 40 - 2
usr/themes/beardocs/archive.php

@@ -126,11 +126,24 @@ $thisChild["name"] ?></a></li> <?php }  ?>
               var icon = document.getElementById('icon-' + index);
 
               if (answerDiv.style.display === 'none') {
+           
                   answerDiv.style.display = 'block';
                   //icon.innerHTML = '▲'; // 展开时显示向上箭头
+                  
+                  // 找到当前答案中的视频并自动播放
+                  var video = answerDiv.querySelector('video');
+                  if (video) {
+                      video.play();
+                  }
               } else {
                   answerDiv.style.display = 'none';
-                 // icon.innerHTML = '▼'; // 收起时显示向下箭头
+                  //icon.innerHTML = '▼'; // 收起时显示向下箭头
+                  
+                  // 如果答案被隐藏,暂停视频播放
+                  var video = answerDiv.querySelector('video');
+                  if (video) {
+                      video.pause();
+                  }
               }
           }
 
@@ -166,6 +179,22 @@ $thisChild["name"] ?></a></li> <?php }  ?>
               padding-left: 20px; /* 答案缩进 */
 
           }
+          
+          /* 在手机设备上将卡片padding设为0 */
+          @media (max-width: 768px) {
+              .uk-card-category.uk-card-body {
+                  padding: 0;
+              }
+              
+              .question h4 {
+                  padding: 15px;
+                  margin: 0;
+              }
+              
+              .answer {
+                  padding: 15px;
+              }
+          }
       </style>
     <div class="uk-margin-medium-top">
 
@@ -277,7 +306,16 @@ if (!empty($keyword)&&(strpos($PathInfo, '/search') === 0))
             if (!empty($answer) && preg_match('/(https?:\/\/[^\s]+\.mp4)/', $answer, $mp4matches)) {
                 $mp4url = $mp4matches[1]; // 提取MP4链接
                 // 将MP4链接替换为视频播放器
-                $videoPlayer = '<div class="adress"><video src="' . $mp4url . "\" title=\"{$question}\" controls=\"controls\" width=\"100%\"></video> </div>";
+
+                if($index==1)
+                {
+                    $videoPlayer = '<div class="adress"><video src="' . $mp4url . "\" title=\"{$question}\" controls=\"controls\" width=\"100%\" autoplay muted></video> </div>";
+                }
+                else
+                {
+                    $videoPlayer = '<div class="adress"><video src="' . $mp4url . "\" title=\"{$question}\" controls=\"controls\" width=\"100%\"></video> </div>";
+                }
+
                 // 将原来的MP4链接替换为视频播放器
                 $answer = str_replace($mp4url, $videoPlayer, $answer);
             }

+ 1 - 1
usr/themes/beardocs/header.php

@@ -147,7 +147,7 @@ $currentUrl = $_SERVER['REQUEST_URI'];
                             <span data-uk-search-icon="ratio: 1.2"></span>
                             <input id="searchComplete" spellcheck=false autocorrect="off" autocomplete="off"
                                    autocapitalize="off" maxlength="2048" tabindex="1" class="uk-search-input uk-form-medium uk-border-rounded" type="search"
-                                   placeholder="Keywords, Enter to search" autocomplete="off" data-minchars="1" data-maxitems="30" style="width: 100%;">
+                                   placeholder="Input Keywords" autocomplete="off" data-minchars="1" data-maxitems="30" style="width: 100%;">
                         </div>
                         <button class="uk-button uk-button-primary uk-border-rounded" type="submit" aria-label="Search">
                             <span data-uk-icon="icon: search"></span>