perf: 聊天消息长大超过5000转文件发送

This commit is contained in:
kuaifan 2023-01-19 12:00:40 +08:00
parent c3abcf0469
commit d1afd54ea1
2 changed files with 5 additions and 3 deletions

View File

@ -625,12 +625,14 @@ class DialogController extends AbstractController
// //
$text = WebSocketDialogMsg::formatMsg($text, $dialog_id); $text = WebSocketDialogMsg::formatMsg($text, $dialog_id);
$strlen = mb_strlen($text); $strlen = mb_strlen($text);
$noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text));
if ($strlen < 1) { if ($strlen < 1) {
return Base::retError('消息内容不能为空'); return Base::retError('消息内容不能为空');
} elseif ($strlen > 200000) { }
if ($noimglen > 200000) {
return Base::retError('消息内容最大不能超过200000字'); return Base::retError('消息内容最大不能超过200000字');
} }
if ($strlen > 2000) { if ($noimglen > 5000) {
// 内容过长转成文件发送 // 内容过长转成文件发送
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/"; $path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
Base::makeDir(public_path($path)); Base::makeDir(public_path($path));

View File

@ -929,7 +929,7 @@ export default {
} else { } else {
// //
const tempId = $A.randNum(1000000000, 9999999999) const tempId = $A.randNum(1000000000, 9999999999)
const typeLoad = $A.stringLength(msgText.replace(/<img[^>]*?>/g, '')) > 2000 const typeLoad = $A.stringLength(msgText.replace(/<img[^>]*?>/g, '')) > 5000
const tempMsg = { const tempMsg = {
id: tempId, id: tempId,
dialog_id: this.dialogData.id, dialog_id: this.dialogData.id,