Explorar el Código

fleat:update 20250119

igb hace 2 meses
padre
commit
969e78214e

BIN
static/images/category-2.png


BIN
static/images/category-3.png


BIN
static/images/category-5.png


BIN
static/images/category-6.png


+ 48 - 0
static/images/logo.svg

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 27.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 462 179" style="enable-background:new 0 0 462 179;" xml:space="preserve">
+<style type="text/css">
+	.st0{fill:#DE5511;}
+	.st1{fill:#040000;}
+</style>
+<g>
+	<path class="st0" d="M36.04,73.69c0,0,37.96-42.33,102.98-41.45s98.62,41.45,101.24,41.45c-5.67-1.31-39.27-32.29-102.11-32.29
+		S42.58,72.82,36.04,73.69z"/>
+	<rect x="132.69" y="49.69" class="st0" width="10.91" height="98.62"/>
+	<rect x="357.09" y="68.34" class="st1" width="10.91" height="78.44"/>
+	<rect x="372.47" y="135.76" class="st0" width="10.91" height="10.91"/>
+	<g>
+		<g>
+			<path class="st1" d="M384.64,53.77c0-6.39,2.18-11.78,6.55-16.16c4.37-4.38,9.67-6.57,15.91-6.57c6.22,0,11.51,2.19,15.88,6.57
+				c4.37,4.38,6.55,9.77,6.55,16.16c0,6.41-2.19,11.82-6.56,16.22c-4.38,4.4-9.67,6.6-15.87,6.6c-6.24,0-11.55-2.2-15.91-6.6
+				C386.82,65.58,384.64,60.18,384.64,53.77z M388.47,53.77c0,5.4,1.81,9.94,5.43,13.62c3.62,3.68,8.02,5.52,13.21,5.52
+				c5.15,0,9.53-1.85,13.16-5.54c3.63-3.69,5.44-8.23,5.44-13.6c0-5.36-1.81-9.86-5.43-13.53c-3.62-3.66-8.01-5.49-13.18-5.49
+				c-5.19,0-9.59,1.83-13.21,5.49C390.28,43.9,388.47,48.41,388.47,53.77z M402.51,56.05v10.28h-4.71V40.47h8.86
+				c3.21,0,5.72,0.67,7.54,1.99c1.82,1.33,2.74,3.27,2.74,5.83c0,1.26-0.35,2.36-1.04,3.32c-0.7,0.95-1.71,1.75-3.04,2.37
+				c1.39,0.53,2.4,1.33,3.02,2.4c0.62,1.08,0.93,2.37,0.93,3.9v1.7c0,0.83,0.04,1.58,0.11,2.24c0.07,0.66,0.22,1.2,0.43,1.63v0.49
+				h-4.84c-0.19-0.43-0.31-1.05-0.35-1.87c-0.04-0.82-0.06-1.66-0.06-2.51v-1.64c0-1.46-0.35-2.54-1.06-3.23
+				c-0.71-0.69-1.87-1.03-3.5-1.03H402.51z M402.51,52.09h4.81c1.37-0.02,2.54-0.35,3.5-0.99s1.44-1.53,1.44-2.66
+				c0-1.48-0.42-2.52-1.25-3.12c-0.83-0.6-2.28-0.9-4.35-0.9h-4.14V52.09z"/>
+		</g>
+	</g>
+	<g>
+		<path class="st1" d="M208.62,115.49c0,2.51,0.18,2.61-0.2,4.92l-49.32,0.41c1.17,6.18,5.54,11.73,8.95,13.53
+			c4.15,2.18,7.53,3.38,12.87,2.84c5.15-0.53,10.58-3.27,14.18-9.82h12.22c-4.15,11.13-16.03,20.95-26.39,20.95
+			c-9.47,0-17.18-2.88-23.14-8.67c-5.96-5.78-8.94-13.2-8.94-22.26c0-8.97,2.91-16.27,8.72-21.91c5.82-5.64,13.27-8.46,22.34-8.46
+			c8.69,0,14.34,3.63,19.56,8.78C204.69,100.94,208.62,106.82,208.62,115.49z M178.75,97.91c-7.22,0-10.6,3.17-13.44,5.24
+			c-2.84,2.07-4.73,4.9-5.71,8.46h37.35c-0.77-3.67-3.47-7.75-6-9.77C188.39,99.81,183.85,97.91,178.75,97.91z"/>
+	</g>
+	<path class="st1" d="M277.4,88.91h-0.03v32.99c0,4.78,0.28,6.49-2.55,9.52c-2.84,3.03-9.52,5.11-13.95,5.11
+		c-4.3,0-6.84-0.31-10.69-2.84c-3.46-2.26-2.81-6.98-2.81-11.69V97.91v-9h-10.94h-12.76V68.34h-10.91v78.44h10.91V97.91h12.76v23.7
+		c0,7.8,1.42,14.06,6.22,19.06s9.54,6.85,17.01,6.85c7.09,0,12.99-2.11,17.73-6.33v5.58h10.91V122V88.91H277.4z"/>
+	<path class="st1" d="M323.2,87.46c-7.81,0-14.92,2.98-20.26,7.86V65.84h-10.32v80.95h10.32v-7.04c5.35,4.88,12.46,7.86,20.26,7.86
+		c16.61,0,30.07-13.46,30.07-30.07S339.81,87.46,323.2,87.46z M322.97,137.32c-11.06,0-20.02-8.97-20.02-20.03
+		s8.97-20.02,20.02-20.02c11.06,0,20.03,8.97,20.03,20.02S334.03,137.32,322.97,137.32z"/>
+	<path class="st1" d="M122.95,96.49c-4.98-5.48-12.08-7.3-19.3-7.3c-9.02,0-16.23,4.42-21.21,11.66
+		c-4.98-7.25-12.2-11.66-21.21-11.66c-7.22,0-14.31,1.82-19.3,7.3c-5.08,5.58-5.41,12.26-5.14,19.49v31.93h10.96v-31.93
+		c0-4.16-0.29-10.5,1.64-12.87c5.57-6.83,20.82-3.35,25.81,2.49c0.01,0.02,0.03,0.03,0.04,0.05c2.09,2.48,1.72,6.45,1.72,10.32
+		v31.93h5.47h5.47v-31.93c0-3.87-0.36-7.85,1.72-10.32c0.01-0.02,0.03-0.03,0.04-0.05c4.99-5.85,20.24-9.32,25.81-2.49
+		c1.93,2.37,1.64,8.71,1.64,12.87v31.93h10.96v-31.93C128.36,108.75,128.03,102.07,122.95,96.49z"/>
+</g>
+</svg>

+ 209 - 8
usr/themes/beardocs/archive.php

@@ -1,11 +1,108 @@
-<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
+<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit;
+
+
+?>
 <?php $this->need('header.php'); ?>
 
+<?php
+
+
+// 定义函数,接收 token, datasets, 和 keyword 作为参数
+function retrieveDatasetData($token, $datasets, $keyword)
+{
+    // 设置接口URL
+    $url = "http://8.217.82.148/v1/datasets/{$datasets}/retrieve";
+
+    // 请求体的内容 (JSON 数据)
+    $requestBody = [
+        'query' => $keyword,  // 用户传入的查询关键字
+        'retrieval_model' => [
+            'reranking_enable' => false,
+            'reranking_mode' => null,
+            'reranking_model' => [
+                'reranking_provider_name' => '',
+                'reranking_model_name' => ''
+            ],
+            'weights' => null,
+            'top_k' => 3,
+            'score_threshold_enabled' => false,
+            'score_threshold' => null
+        ]
+    ];
+
+    // 初始化CURL会话
+    $ch = curl_init();
+
+    // 设置CURL选项
+    curl_setopt($ch, CURLOPT_URL, $url);
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  // 设置返回的内容为字符串
+    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);  // 如果需要自动跟随重定向
+
+    // 设置请求头部,包含Authorization字段和Content-Type
+    curl_setopt($ch, CURLOPT_HTTPHEADER, [
+        'Authorization: Bearer ' . $token,
+        'Content-Type: application/json',  // 设置Content-Type为JSON
+    ]);
+
+    // 设置POST请求方法并将请求体内容(JSON)作为POST数据发送
+    curl_setopt($ch, CURLOPT_POST, true);
+    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));  // 将请求体数据编码为JSON格式
+
+    // 执行请求并获取响应
+    $response = curl_exec($ch);
+
+    // 检查是否发生错误
+    if (curl_errno($ch)) {
+        echo 'cURL Error: ' . curl_error($ch);
+        return null;  // 如果发生错误,返回 null
+    } else {
+        // 成功,处理返回的JSON数据
+        $data = json_decode($response, true);
+
+        // 关闭CURL会话
+        curl_close($ch);
+
+        // 返回响应数据
+        return $data;
+    }
+}
+
+// 示例调用
+$token = 'dataset-Emh5R5hCGorTuqG0dkQe7tMf';  // 传入实际的 token
+$datasets = 'c08ae7fa-c4e7-4fae-8138-2097ff19e1a6';  // 传入实际的 datasets ID
+$keyword = 'how to cute';  // 传入实际的查询关键字
+
+
+if(!empty($_GET['category'])) {
+
+
+    $category_id = $_GET['category'] * 1;
+
+    switch ($category_id) {
+        case 3:
+            $datasets = '4b8ced28-d8eb-4b13-9dea-2eba799d3e79';
+            break;
+        case 5:
+            $datasets = '910fcc90-d370-44b1-9bd5-33248c277526';
+            break;
+        case 6:
+            $datasets = '4d48eda8-6cd9-449d-b3c6-7a19d2f9aafc';
+            break;
+    }
+
+
+}
+?>
+
+
+
 
 <div class="uk-section uk-section-muted">
   <div class="uk-container">
        <?php if($this->is('category')): ?>
        <?php
+
+
 $childrens =
 $this->widget('Widget_Metas_Category_List')->getAllChildren(General::getCategoryId($this->getArchiveSlug()));?>
 <?php if($childrens):?>
@@ -26,13 +123,19 @@ $thisChild["name"] ?></a></li> <?php }  ?>
 <?php endif;?>
 
 
-
 <div class="uk-background-muted uk-padding uk-panel" style="text-align:center">
  <div class="uk-width-auto uk-text-secondary">
 
-        <span uk-icon="icon: <?php if($this->is('category')): ?><?php if(General::getCategoryIcon(General::getCategoryId($this->getArchiveSlug()),$this->getDescription()) == 'cog'):?><?php echo General::getCategoryDescriptionData($this->getDescription())["icon"];?><?php else:?><?php echo General::getCategoryIcon(General::getCategoryId($this->getArchiveSlug()),$this->getDescription());?><?php endif;?><?php elseif($this->is('tag')):?>tag<?php elseif($this->is('author')):?>user<?php else:?>search<?php endif;?>; ratio: 4"></span>
+<!--        <span uk-icon="icon: --><?php //if($this->is('category')): ?><!----><?php //if(General::getCategoryIcon(General::getCategoryId($this->getArchiveSlug()),$this->getDescription()) == 'cog'):?><!----><?php //echo General::getCategoryDescriptionData($this->getDescription())["icon"];?><!----><?php //else:?><!----><?php //echo General::getCategoryIcon(General::getCategoryId($this->getArchiveSlug()),$this->getDescription());?><!----><?php //endif;?><!----><?php //elseif($this->is('tag')):?><!--tag--><?php //elseif($this->is('author')):?><!--user--><?php //else:?><!--search--><?php //endif;?><!--; ratio: 4"></span>-->
+
+     <?php
+     $category_id=General::getCategoryId($this->getArchiveSlug());
+     if($category_id)
+     {
+     ?>
 
-       <div><image src="/static/images/category-<?php General::getCategoryId($this->getArchiveSlug());?>.jpg"/></div>
+       <div><image src="/static/images/category-<?php  echo $category_id?>.png"/></div>
+    <?php } ?>
       </div>
     <h2 style="word-break:break-all"><?php $this->archiveTitle(array(
             'category'  =>  _t('%s'),
@@ -40,19 +143,117 @@ $thisChild["name"] ?></a></li> <?php }  ?>
             'tag'       =>  _t('%s'),
             'author'    =>  _t('%s')
         ), '', ''); ?></h2>
-    <p style="word-break:break-all"><?php if($this->is('category')): ?><?php echo General::getCategoryDescriptionData($this->getDescription())['desc']; ?><?php else:?>以下为 <?php $this->archiveTitle(array(
+    <p style="word-break:break-all"><?php if($this->is('category')): ?><?php echo General::getCategoryDescriptionData($this->getDescription())['desc']; ?><?php else:?> <?php $this->archiveTitle(array(
             'category'  =>  _t('%s'),
             'search'    =>  _t('%s'),
             'tag'       =>  _t('%s'),
             'author'    =>  _t('%s')
-        ), '', ''); ?> 的相关结果<?php endif;?></p>
+        ), '', ''); ?> results <?php endif;?></p>
 </div>
 
 
     <div class="uk-margin-medium-top">
-        
 
-        <?php if ($this->have()): ?>
+        <?php
+
+$search=false;
+        // 获取Typecho请求对象
+        $PathInfo = Typecho_Widget::widget('Widget_Options')->request->getPathInfo();;
+
+    // 检查请求路径是否以 '/search' 开头
+if (strpos($PathInfo, '/search') === 0)
+    // 设置CURL请求参数
+    {
+        // 提取 '/search' 后面的部分
+        $pathAfterSearch = substr($PathInfo, strlen('/search')); // 获取 '/search' 后面的部分
+
+        // 使用正则表达式提取 '/search' 后面到下一个 '/' 之间的部分作为 keyword
+        if (preg_match('/^\/([^\/]+)/', $pathAfterSearch, $matches)) {
+            $keyword = $matches[1];  // 获取 keyword
+
+            // 设置为 true,表示这是一个搜索请求
+            $search = true;
+
+            // 输出提取的关键字
+           // echo "Keyword: $keyword\n";
+
+            // 调用函数
+            $data = retrieveDatasetData($token, $datasets, $keyword);
+
+            // 你可以在这里继续处理 $data 或返回结果
+        } else {
+            // 如果无法提取 keyword,给出提示
+           // echo "No keyword found in the path.\n";
+        }
+
+// 遍历记录并提取内容和数字
+    foreach ($data['records'] as $record) {
+        $content = $record['segment']['content'];
+
+        // 使用正则表达式提取开头的数字
+        preg_match('/^\[(\d+)\]/', $content, $matches);
+        $number = isset($matches[1]) ? $matches[1] : null;
+
+        // 输出提取到的数字
+      //  echo "Number: $number\n";
+
+        // 去掉 content 开头的数字部分(去掉方括号及其中的数字)
+        $contentWithoutNumber = preg_replace('/^\[\d+\]\s*/', '', $content);
+
+
+        // 提取英文单词
+        preg_match_all('/\b\w+\b/', $contentWithoutNumber, $words);
+
+        // 计算字符数并截取单词,确保不超过 200 个字符
+        $truncatedContent = '';
+        $charCount = 0;
+        $maxLength = 300;
+
+        foreach ($words[0] as $word) {
+            $wordLength = strlen($word);
+
+            // 判断添加当前单词后是否超出最大字符数
+            if ($charCount + $wordLength <= $maxLength) {
+                $truncatedContent .= ' ' . $word;
+                $charCount += $wordLength + 1; // 加1是为了添加空格
+            } else {
+                break;
+            }
+        }
+
+        // 如果截取的字符长度超过 200,则加上 "..."
+        if (strlen($truncatedContent) > $maxLength) {
+            $truncatedContent = substr($truncatedContent, 0, $maxLength) . '...';
+        }
+
+
+        // 输出去除数字后的 content
+      // echo "Content: $contentWithoutNumber\n\n";
+
+        ?>
+
+        <div class="uk-card uk-card-category uk-card-default uk-card-hover uk-card-body uk-inline uk-border-rounded uk-width-1-1">
+            <a class="uk-position-cover" target=_blank href="https://support.hydrogelmachine.com/archives/<?php echo $number; ?>.html"></a>
+            <p class="uk-margin-small-top"><?php echo $truncatedContent;?></p>
+
+        </div>
+
+
+        <?php
+
+    }
+
+
+    exit();
+
+    }
+    else
+{
+
+        }
+    ?>
+
+        <?php if ($search&&$this->have()): ?>
         <?php while($this->next()): ?>
       <div class="uk-card uk-card-category uk-card-default uk-card-hover uk-card-body uk-inline uk-border-rounded uk-width-1-1">
         <a class="uk-position-cover" href="<?php $this->permalink() ?>"></a>

+ 42 - 42
usr/themes/beardocs/assets/js/beardocs.js

@@ -24,48 +24,48 @@ function searchEngine(query,record){
     return record;
 }
 
-const BearDocsSearch = new autoComplete({
-  selector: "#searchComplete",
-  data: {
-    src: async query => {
-       const result = await fetch(`${searchApi}?keyword=${query}`);
-       const data = result.json();
-        document.getElementById("searchComplete").setAttribute("placeholder", BearDocsSearch.placeHolder);
-        return data;
-    },
-    keys: ['article'],
-  },
-  searchEngine:searchEngine,
-  placeHolder: "Enter a keyword to search",
-  resultsList: {
-    element: (list, data) => {
-      //预留方法
-    },
-    noResults: true,
-    maxResults: 100,
-    tabSelect: true,
-  },
-  resultItem: {
-    element: (item, data) => {
-        //预留方法
-    },
-    highlight: true,
-  },
-  events: {
-    input: {
-      focus() {
-        if (BearDocsSearch.input.value.length) BearDocsSearch.start();
-      },
-      selection(event) {
-        const searchResult = event.detail;
-        BearDocsSearch.input.blur();
-        const selection = searchResult.selection.value;
-        window.location.href = selection.url;
-        BearDocsSearch.input.value = selection.article;
-      },
-    },
-  },
-});
+// const BearDocsSearch = new autoComplete({
+//   selector: "#searchComplete",
+//   data: {
+//     src: async query => {
+//        const result = await fetch(`${searchApi}?keyword=${query}`);
+//        const data = result.json();
+//         document.getElementById("searchComplete").setAttribute("placeholder", BearDocsSearch.placeHolder);
+//         return data;
+//     },
+//     keys: ['article'],
+//   },
+//   searchEngine:searchEngine,
+//   placeHolder: "Enter a keyword to search",
+//   resultsList: {
+//     element: (list, data) => {
+//       //预留方法
+//     },
+//     noResults: true,
+//     maxResults: 100,
+//     tabSelect: true,
+//   },
+//   resultItem: {
+//     element: (item, data) => {
+//         //预留方法
+//     },
+//     highlight: true,
+//   },
+//   events: {
+//     input: {
+//       focus() {
+//         if (BearDocsSearch.input.value.length) BearDocsSearch.start();
+//       },
+//       selection(event) {
+//         const searchResult = event.detail;
+//         BearDocsSearch.input.blur();
+//         const selection = searchResult.selection.value;
+//         window.location.href = selection.url;
+//         BearDocsSearch.input.value = selection.article;
+//       },
+//     },
+//   },
+// });
 
 //灯箱
           

+ 18 - 2
usr/themes/beardocs/header.php

@@ -141,11 +141,27 @@
 						<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-large uk-border-rounded" type="search"
-							placeholder="Enter a keyword to search" autocomplete="off" data-minchars="1" data-maxitems="30">
+							placeholder="Input keywords and  Enter to search" autocomplete="off" data-minchars="1" data-maxitems="30">
 					</form>
 				</div>
 			</div>
 		</div>
 	</div>
 
-</header>
+</header>
+
+<script>
+    $(document).ready(function() {
+        $('#searchComplete').on('keypress', function(e) {
+            // 判断是否按下回车键
+            if (e.which === 13) {
+                // 获取搜索框中的输入值
+                var searchQuery = $(this).val();
+                // 构建目标URL
+                var targetUrl = '/index.php/search/' + encodeURIComponent(searchQuery)+'/?category=<?php echo General::getCategoryId($this->getArchiveSlug());?>';
+                // 跳转到目标URL
+                window.location.href = targetUrl;
+            }
+        });
+    });
+</script>

+ 5 - 3
usr/themes/beardocs/index.php

@@ -21,10 +21,12 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit;
 			<div>
 				<div class="uk-card uk-card uk-card-default uk-card-hover uk-card-body uk-inline uk-border-rounded">
 					<a class="uk-position-cover" href="<?php $categorys->permalink(); ?>"></a>
+                    <div class="uk-width-auto uk-text-secondary uk-flex uk-flex-middle">
+                        <image src="/static/images/category-<?php  echo $categorys->mid?>.png"/>
+                    </div>
+
 					<div class="uk-grid-medium" data-uk-grid>
-						<div class="uk-width-auto uk-text-secondary uk-flex uk-flex-middle">
-						    <span data-uk-icon="icon: <?php echo General::getCategoryDescriptionData($categorys->description)['icon']; ?>; ratio: 2.6"></span>
-						</div>
+
 						<div class="uk-width-expand">
 							<h3 class="uk-card-title uk-margin-remove uk-text-secondary uk-category-name"><?php $categorys->name(); ?></h3>
 							<p class="uk-text-muted uk-margin-remove uk-category-desc"><?php echo General::getCategoryDescriptionData($categorys->description)['desc']; ?></p>

+ 2 - 1
var/Widget/Archive.php

@@ -1406,6 +1406,7 @@ class Archive extends Contents
             }
         }
 
+
         /** 文件不存在 */
         if (!$validated) {
             throw new WidgetException(_t('文件不存在'), 500);
@@ -1634,7 +1635,7 @@ class Archive extends Contents
         $target = parse_url($requestUrl);
 
         if ($src['host'] != $target['host'] || urldecode($src['path']) != urldecode($target['path'])) {
-            $this->response->redirect($permalink, true);
+            //$this->response->redirect($permalink, true);
         }
     }