From 67e2ec409391d1fa513a59a9ed49a906c30924a7 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 19 Jul 2022 16:14:44 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=AF=B9=E8=AF=9D=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=8B=BC=E9=9F=B3=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WebSocketDialog.php | 1 + app/Module/Base.php | 6 ++++-- resources/assets/js/pages/manage/messenger.vue | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Models/WebSocketDialog.php b/app/Models/WebSocketDialog.php index 73b33e4b0..f03e61cda 100644 --- a/app/Models/WebSocketDialog.php +++ b/app/Models/WebSocketDialog.php @@ -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; } diff --git a/app/Module/Base.php b/app/Module/Base.php index 84c108854..cb392d764 100755 --- a/app/Module/Base.php +++ b/app/Module/Base.php @@ -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; } diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue index e8530ca92..7082eeb14 100644 --- a/resources/assets/js/pages/manage/messenger.vue +++ b/resources/assets/js/pages/manage/messenger.vue @@ -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) {