加入拼音搜索

This commit is contained in:
fofolee
2022-04-11 18:37:49 +08:00
parent c397f5f02f
commit 40e972cbf4
4 changed files with 9 additions and 20 deletions

View File

@@ -73,22 +73,11 @@ export default {
},
computed: {
matchedItems() {
let matchedItems;
if (!this.searchWords) {
matchedItems = this.items;
} else {
matchedItems = this.items.filter((x) => {
if (this.isJson) {
return (
x.title.toLowerCase().includes(this.searchWords.toLowerCase()) ||
x.description
.toLowerCase()
.includes(this.searchWords.toLowerCase())
);
}
return x.toLowerCase().includes(this.searchWords.toLowerCase());
});
}
let matchedItems = this.searchWords
? this.items.filter((x) =>
window.pinyinMatch(x.title ? x.title : x, this.searchWords)
)
: this.items;
this.setUtoolsHeight(this.itemHeight * matchedItems.length);
return matchedItems;
},
@@ -108,6 +97,7 @@ export default {
props: {
options: Object,
items: Array,
pinyinMatch: Function,
},
emits: ["ok", "hide"],
methods: {

View File

@@ -90,7 +90,7 @@ const quickcommand = {
}),
showSelectList: (selects, options = {}) => new Promise((reslove, reject) => {
if (!options.placeholder) options.placeholder = "输入进行筛选"
if (!options.placeholder) options.placeholder = "输入进行筛选,支持拼音"
if (!options.optionType) options.optionType = "plaintext"
let props = {
items: selects,

View File

@@ -262,7 +262,7 @@ export default {
commands.forEach((cmd) => {
// 拼音搜索
let explain = cmd.features.explain;
let matchedWordPositions = window.pinYinMatch.match(
let matchedWordPositions = window.pinyinMatch(
explain,
this.commandSearchKeyword
);