perf: 优化编辑带有图片的消息

This commit is contained in:
kuaifan 2022-07-16 14:38:38 +08:00
parent 3fe6ab0e79
commit 10041b1a30
2 changed files with 9 additions and 3 deletions

View File

@ -582,9 +582,14 @@ class WebSocketDialogMsg extends AbstractModel
// 其他网络图片
preg_match_all("/<img[^>]*?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)) {

View File

@ -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}`,