mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 21:13:02 +08:00
加入拼音搜索
This commit is contained in:
parent
c397f5f02f
commit
40e972cbf4
@ -9,12 +9,11 @@ const {
|
|||||||
} = require('./lib/vm2')
|
} = require('./lib/vm2')
|
||||||
const path = require("path")
|
const path = require("path")
|
||||||
const util = require("util")
|
const util = require("util")
|
||||||
const PinyinMatch = require('pinyin-match');
|
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const pictureCompress = require("./lib/picture-compressor")
|
const pictureCompress = require("./lib/picture-compressor")
|
||||||
|
|
||||||
_ = require("lodash")
|
_ = require("lodash")
|
||||||
window.pinYinMatch = PinyinMatch
|
pinyinMatch = require('pinyin-match').match;
|
||||||
|
|
||||||
// axios.defaults.adapter = require('axios/lib/adapters/http')
|
// axios.defaults.adapter = require('axios/lib/adapters/http')
|
||||||
|
|
||||||
|
@ -73,22 +73,11 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
matchedItems() {
|
matchedItems() {
|
||||||
let matchedItems;
|
let matchedItems = this.searchWords
|
||||||
if (!this.searchWords) {
|
? this.items.filter((x) =>
|
||||||
matchedItems = this.items;
|
window.pinyinMatch(x.title ? x.title : x, this.searchWords)
|
||||||
} else {
|
)
|
||||||
matchedItems = this.items.filter((x) => {
|
: this.items;
|
||||||
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());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.setUtoolsHeight(this.itemHeight * matchedItems.length);
|
this.setUtoolsHeight(this.itemHeight * matchedItems.length);
|
||||||
return matchedItems;
|
return matchedItems;
|
||||||
},
|
},
|
||||||
@ -108,6 +97,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
options: Object,
|
options: Object,
|
||||||
items: Array,
|
items: Array,
|
||||||
|
pinyinMatch: Function,
|
||||||
},
|
},
|
||||||
emits: ["ok", "hide"],
|
emits: ["ok", "hide"],
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -90,7 +90,7 @@ const quickcommand = {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
showSelectList: (selects, options = {}) => new Promise((reslove, reject) => {
|
showSelectList: (selects, options = {}) => new Promise((reslove, reject) => {
|
||||||
if (!options.placeholder) options.placeholder = "输入进行筛选"
|
if (!options.placeholder) options.placeholder = "输入进行筛选,支持拼音"
|
||||||
if (!options.optionType) options.optionType = "plaintext"
|
if (!options.optionType) options.optionType = "plaintext"
|
||||||
let props = {
|
let props = {
|
||||||
items: selects,
|
items: selects,
|
||||||
|
@ -262,7 +262,7 @@ export default {
|
|||||||
commands.forEach((cmd) => {
|
commands.forEach((cmd) => {
|
||||||
// 拼音搜索
|
// 拼音搜索
|
||||||
let explain = cmd.features.explain;
|
let explain = cmd.features.explain;
|
||||||
let matchedWordPositions = window.pinYinMatch.match(
|
let matchedWordPositions = window.pinyinMatch(
|
||||||
explain,
|
explain,
|
||||||
this.commandSearchKeyword
|
this.commandSearchKeyword
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user