From 4fd430ffee6446ad9c04799bd047150426f492b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=87=E5=AF=92?=
<149793500+YuHan1015@users.noreply.github.com>
Date: Sun, 29 Dec 2024 22:12:24 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=84=9A=E6=9C=AC=E7=9A=84?=
=?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/App.vue | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index efb5bfb..b278080 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -13,6 +13,14 @@
{{ repo.label }}
+
+
更新时间:{{ repoUpdateTime }}
@@ -23,7 +31,7 @@
handleTreeSelect(selectedKeys, event, category.name)"
>
@@ -149,6 +157,43 @@ const mirrorUrls = [
"https://mirror.ghproxy.com/{0}"
];
+// 添加树搜索相关的响应式变量
+const treeSearchText = ref('');
+const filteredTreeData = reactive({});
+
+// 添加树搜索处理函数
+const handleTreeSearch = () => {
+ repoData.value.forEach(category => {
+ if (showTree(category)) {
+ if (!treeSearchText.value) {
+ filteredTreeData[category.name] = getCategoryTree(category);
+ } else {
+ const searchText = treeSearchText.value.toLowerCase();
+ const originalTree = getCategoryTree(category);
+ filteredTreeData[category.name] = filterTreeNodes(originalTree, searchText);
+ }
+ }
+ });
+};
+
+// 添加树节点过滤函数
+const filterTreeNodes = (nodes, searchText) => {
+ return nodes.map(node => {
+ const newNode = { ...node };
+ if (newNode.children) {
+ newNode.children = filterTreeNodes(newNode.children, searchText);
+ }
+
+ if (
+ newNode.title.toLowerCase().includes(searchText) ||
+ (newNode.children && newNode.children.length > 0)
+ ) {
+ return newNode;
+ }
+ return null;
+ }).filter(Boolean);
+};
+
// 修改 repoOptions 的定义
const repoOptions = computed(() => {
if (mode === 'single') {
@@ -207,6 +252,7 @@ const fetchRepoData = async () => {
// 清空现有数据
repoDataRaw.value = [];
repoUpdateTime.value = '';
+ treeSearchText.value = ''; // 清空树搜索文本
Object.keys(searchConditions).forEach(key => {
searchConditions[key] = {
name: '',
@@ -571,4 +617,4 @@ onMounted(() => {
overflow: visible;
text-overflow: clip;
}
-
\ No newline at end of file
+