mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
perf: 聊天消息长大超过5000转文件发送
This commit is contained in:
parent
c3abcf0469
commit
d1afd54ea1
@ -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));
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user