mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-25 03:49:26 +08:00
bugfix: 修复中文搜索bug
This commit is contained in:
@@ -229,32 +229,24 @@ APP_FINDER_PATH.forEach((searchPath, index) => {
|
||||
icon: img.toDataURL(),
|
||||
desc: path.join(searchPath, appName),
|
||||
type: 'app',
|
||||
action: `open ${path.join(searchPath, appName).replace(' ', '\\ ')}`
|
||||
action: `open ${path.join(searchPath, appName).replace(' ', '\\ ')}`,
|
||||
keyWords: [appSubStr]
|
||||
};
|
||||
|
||||
if (appZhName && isZhRegex.test(appZhName)) {
|
||||
const pinyinArr = pinyin(appZhName, { style: pinyin.STYLE_NORMAL });
|
||||
// pinyinArr = [['pin'], ['yin']]
|
||||
const firstLetterArr = pinyinArr.map((str) => str[0][0]);
|
||||
fileOptions.keyWords.push(appZhName);
|
||||
fileOptions.keyWords.push(pinyinArr.join(''));
|
||||
fileOptions.keyWords.push(firstLetterArr.join(''));
|
||||
}
|
||||
|
||||
fileLists.push({
|
||||
...fileOptions,
|
||||
name: appSubStr,
|
||||
keyWord: appSubStr
|
||||
names: JSON.parse(JSON.stringify(fileOptions.keyWords)),
|
||||
});
|
||||
|
||||
if (appZhName && isZhRegex.test(appZhName)) {
|
||||
let cmds = [];
|
||||
const pinyinArr = pinyin(appZhName, { style: pinyin.STYLE_NORMAL });
|
||||
// pinyinArr = [['pin'], ['yin']]
|
||||
const firstLetterArr = pinyinArr.map((str) => str[0][0]);
|
||||
cmds.push(appZhName);
|
||||
cmds.push(pinyinArr.join(''));
|
||||
cmds.push(firstLetterArr.join(''));
|
||||
|
||||
cmds.forEach((cmd) => {
|
||||
fileLists.push({
|
||||
...fileOptions,
|
||||
name: appZhName,
|
||||
keyWord: cmd
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,16 @@ const actions = {
|
||||
.filter((plugin) => {
|
||||
if (!descMap.get(plugin)) {
|
||||
descMap.set(plugin, true);
|
||||
return plugin.keyWord.toLocaleUpperCase().indexOf(value.toLocaleUpperCase()) >= 0;
|
||||
let has = false;
|
||||
plugin.keyWords.some(keyWord => {
|
||||
if (keyWord.toLocaleUpperCase().indexOf(value.toLocaleUpperCase()) >= 0) {
|
||||
has = keyWord;
|
||||
plugin.name = keyWord;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return has;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user