diff --git a/package-lock.json b/package-lock.json
index b201f24..cfa8d50 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,6 +9,7 @@
"version": "0.0.0",
"dependencies": {
"@vueuse/core": "^11.1.0",
+ "pinyin-pro": "^3.26.0",
"vue": "^3.4.29"
},
"devDependencies": {
@@ -1100,6 +1101,11 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
+ "node_modules/pinyin-pro": {
+ "version": "3.26.0",
+ "resolved": "https://registry.npmjs.org/pinyin-pro/-/pinyin-pro-3.26.0.tgz",
+ "integrity": "sha512-HcBZZb0pvm0/JkPhZHWA5Hqp2cWHXrrW/WrV+OtaYYM+kf35ffvZppIUuGmyuQ7gDr1JDJKMkbEE+GN0wfMoGg=="
+ },
"node_modules/postcss": {
"version": "8.4.47",
"resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.47.tgz",
diff --git a/package.json b/package.json
index ab74b77..394d6d6 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,8 @@
},
"dependencies": {
"@vueuse/core": "^11.1.0",
- "vue": "^3.4.29"
+ "vue": "^3.4.29",
+ "pinyin-pro": "^3.26.0"
},
"devDependencies": {
"@arco-design/web-vue": "^2.56.2",
diff --git a/src/App.vue b/src/App.vue
index fb9e7b1..ba63845 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -60,12 +60,12 @@
-
+
{{ tag }}
-
+
-
- {{ tag }}
+
+ {{ tag }}
@@ -141,6 +144,7 @@
import { ref, onMounted, reactive, computed, h } from 'vue';
import { Message, Popover, Typography } from '@arco-design/web-vue';
import { useClipboard } from '@vueuse/core';
+import { match } from 'pinyin-pro';
// 添加环境变量的引用
const mode = import.meta.env.VITE_MODE;
@@ -158,6 +162,18 @@ const mirrorUrls = [
"https://mirror.ghproxy.com/{0}"
];
+const isPinyinMatch = (text, search) => {
+ const searchLower = search.toLowerCase();
+ const textLower = text.toLowerCase();
+
+ if (textLower.includes(searchLower)) {
+ return true;
+ }
+
+ const pinyinMatch = match(textLower, searchLower);
+ return !!pinyinMatch
+};
+
// 添加树搜索相关的响应式变量
const treeSearchText = ref('');
const filteredTreeData = reactive({});
@@ -186,7 +202,7 @@ const filterTreeNodes = (nodes, searchText) => {
}
if (
- newNode.title.toLowerCase().includes(searchText) ||
+ isPinyinMatch(newNode.title, searchText) ||
(newNode.children && newNode.children.length > 0)
) {
return newNode;
@@ -225,10 +241,16 @@ const loading = ref(false);
// 添加新的响应式量
const repoUpdateTime = ref('');
+const pageSize = ref(20);
+
+const handlePageSizeChange = (newPageSize) => {
+ pageSize.value = newPageSize;
+};
+
const columns = [
- {
- title: '名称',
- dataIndex: 'name',
+ {
+ title: '名称',
+ dataIndex: 'name',
slotName: 'name',
ellipsis: true,
tooltip: false // 关闭默认的 tooltip
@@ -366,7 +388,7 @@ const filterData = (categoryName) => {
const filtered = [];
traverseCategory(category, (item) => {
- const nameMatch = !condition.name || item.name.toLowerCase().includes(condition.name.toLowerCase());
+ const nameMatch = !condition.name || isPinyinMatch(item.name, condition.name);
const authorMatch = !condition.author || item.author === condition.author;
// 修改标签匹配逻辑
const tagMatch = condition.tags.length === 0 || (Array.isArray(item.tags) && condition.tags.every(tag => item.tags.includes(tag)));
@@ -517,6 +539,19 @@ const handleTagSelect = (categoryName) => {
filterData(categoryName);
};
+const handleTagClick = (tag, categoryName) => {
+ if (!searchConditions[categoryName].tags.includes(tag)) {
+ searchConditions[categoryName].tags.push(tag);
+ } else {
+ searchConditions[categoryName].tags = searchConditions[categoryName].tags.filter(t => t !== tag);
+ }
+ filterData(categoryName);
+}
+
+const handleTagFilter = (value, option) => {
+ return isPinyinMatch(option.value, value);
+};
+
// 添加类别名称映射
const categoryNameMap = {
'pathing': '地图追踪',
@@ -548,7 +583,7 @@ const formatDate = (timeString) => {
const hours = timeString.slice(8, 10);
const minutes = timeString.slice(10, 12);
const seconds = timeString.slice(12, 14);
-
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};