mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-28 04:40:37 +00:00
perf: 对话支持拼音搜索
This commit is contained in:
parent
5f50fc7b3b
commit
67e2ec4093
@ -136,6 +136,7 @@ class WebSocketDialog extends AbstractModel
|
||||
$this->has_file = $msgBuilder->clone()->whereMtype('file')->exists();
|
||||
$this->has_link = $msgBuilder->clone()->whereLink(1)->exists();
|
||||
}
|
||||
$this->name_py = Base::cn2pinyin($this->name);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@ -2860,8 +2860,10 @@ class Base
|
||||
return '';
|
||||
}
|
||||
if (!preg_match("/^[a-zA-Z0-9_.]+$/", $str)) {
|
||||
$pinyin = new Pinyin();
|
||||
$str = $pinyin->permalink($str, '');
|
||||
$str = Cache::rememberForever("cn2pinyin:" . md5($str), function() use ($str) {
|
||||
$pinyin = new Pinyin();
|
||||
return $pinyin->permalink($str, '');
|
||||
});
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
@ -227,20 +227,20 @@ export default {
|
||||
return false;
|
||||
}
|
||||
if (dialogKey) {
|
||||
const {name, last_msg} = dialog;
|
||||
let msgKey = "";
|
||||
const {name, name_py, last_msg} = dialog;
|
||||
let searchString = `${name} ${name_py}`
|
||||
if (last_msg) {
|
||||
switch (last_msg.type) {
|
||||
case 'text':
|
||||
msgKey = last_msg.msg.text.replace(/<[^>]+>/g,"")
|
||||
searchString += ` ${last_msg.msg.text.replace(/<[^>]+>/g,"")}`
|
||||
break
|
||||
case 'meeting':
|
||||
case 'file':
|
||||
msgKey = last_msg.msg.name
|
||||
searchString += ` ${last_msg.msg.name}`
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!$A.strExists(name, dialogKey) && !$A.strExists(msgKey, dialogKey)) {
|
||||
if (!$A.strExists(searchString, dialogKey)) {
|
||||
return false;
|
||||
}
|
||||
} else if (dialogActive) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user