From 10041b1a30037665dfb163b48ae20e35910db2a3 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 16 Jul 2022 14:38:38 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=B8=A6=E6=9C=89=E5=9B=BE=E7=89=87=E7=9A=84=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WebSocketDialogMsg.php | 11 ++++++++--- .../js/pages/manage/components/DialogWrapper.vue | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index 132d65f50..54617d4ef 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -582,9 +582,14 @@ class WebSocketDialogMsg extends AbstractModel // 其他网络图片 preg_match_all("/]*?src=([\"'])(.*?\.(png|jpg|jpeg|gif))\\1[^>]*?>/is", $text, $matchs); foreach ($matchs[2] as $key => $str) { - $tmpPath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/"; - Base::makeDir(public_path($tmpPath)); - $tmpPath .= md5s($str) . "." . $matchs[3][$key]; + if (str_starts_with($str, "{{RemoteURL}}")) { + $tmpPath = Base::leftDelete($str, "{{RemoteURL}}"); + $tmpPath = Base::rightDelete($tmpPath, "_thumb.jpg"); + } else { + $tmpPath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/"; + Base::makeDir(public_path($tmpPath)); + $tmpPath .= md5s($str) . "." . $matchs[3][$key]; + } if (file_exists(public_path($tmpPath))) { $imagesize = getimagesize(public_path($tmpPath)); if (Base::imgThumb(public_path($tmpPath), public_path($tmpPath) . "_thumb.jpg", 320, 0)) { diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 31d6faa61..67b6056f8 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -896,6 +896,7 @@ export default { // if (this.replyActiveUpdate) { // 修改 + msgText = msgText.replace(new RegExp(`src=(["'])${$A.apiUrl('../')}`, "g"), "src=$1{{RemoteURL}}") const update_id = this.replyId this.$store.dispatch("setLoad", { key: `msg-${update_id}`,