diff --git a/src/pages/ShareCenterPage.vue b/src/pages/ShareCenterPage.vue
index b3bc275..d8e29ef 100644
--- a/src/pages/ShareCenterPage.vue
+++ b/src/pages/ShareCenterPage.vue
@@ -90,6 +90,20 @@
>
+
+
+
+
+
+
+
import commandTypes from "../js/options/commandTypes.js";
+import pinyinMatch from "pinyin-match";
export default {
data() {
@@ -112,7 +127,9 @@ export default {
currentPage: 1,
commands: [],
allCommands: [],
+ matchedCommands: [],
perPage: 8,
+ commandSearchKeyword: "",
releaseRepo: "fofolee/qcreleases",
shareRepo: "fofolee/qcshares",
commandTypes: commandTypes,
@@ -121,14 +138,14 @@ export default {
},
computed: {
maxPages() {
- return Math.ceil(this.allCommands.length / this.perPage) || 1;
+ return Math.ceil(this.matchedCommands.length / this.perPage) || 1;
},
loading() {
return this.commands.length === this.currentPageCounts ? false : true;
},
currentPageCounts() {
return this.currentPage === this.maxPages
- ? this.allCommands.length % this.perPage
+ ? this.matchedCommands.length % this.perPage
: this.perPage;
},
},
@@ -136,6 +153,7 @@ export default {
window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => {
console.log(res.data);
this.allCommands = res.data.data;
+ this.matchedCommands = _.cloneDeep(this.allCommands);
this.fetchCommandDetails(1);
});
},
@@ -147,7 +165,7 @@ export default {
methods: {
fetchCommandDetails(page) {
this.commands = [];
- this.allCommands
+ this.matchedCommands
.slice((page - 1) * this.perPage, page * this.perPage)
.forEach((item) => {
window
@@ -172,6 +190,14 @@ export default {
this.$utools.putDB(_.cloneDeep(pushData), this.$utools.DBPRE.QC + code);
quickcommand.showMessageBox("导入成功!可到「来自分享」标签查看");
},
+ updateSearch() {
+ if (!this.commandSearchKeyword) this.matchedCommands = this.allCommands;
+ else
+ this.matchedCommands = this.allCommands.filter((x) =>
+ pinyinMatch.match(x.title, this.commandSearchKeyword)
+ );
+ this.fetchCommandDetails(1);
+ },
},
};