mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
perf: 优化回复、转发消息数据结构
This commit is contained in:
parent
b04647e65a
commit
f5ff9a3648
@ -33,13 +33,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property int|null $reply_id 回复ID
|
* @property int|null $reply_id 回复ID
|
||||||
* @property int|null $forward_id 转发ID
|
* @property int|null $forward_id 转发ID
|
||||||
* @property int|null $forward_num 被转发多少次
|
* @property int|null $forward_num 被转发多少次
|
||||||
* @property int|null $forward_show 是否显示转发的来源
|
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||||
* @property-read \App\Models\WebSocketDialogMsg|null $forward_data
|
|
||||||
* @property-read int|mixed $percentage
|
* @property-read int|mixed $percentage
|
||||||
* @property-read \App\Models\WebSocketDialogMsg|null $reply_data
|
|
||||||
* @property-read \App\Models\WebSocketDialog|null $webSocketDialog
|
* @property-read \App\Models\WebSocketDialog|null $webSocketDialog
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg newQuery()
|
||||||
@ -52,7 +49,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereEmoji($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereEmoji($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereForwardId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereForwardId($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereForwardNum($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereForwardNum($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereForwardShow($value)
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereId($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereKey($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereKey($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereLink($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereLink($value)
|
||||||
@ -78,8 +74,6 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
|
|
||||||
protected $appends = [
|
protected $appends = [
|
||||||
'percentage',
|
'percentage',
|
||||||
'reply_data',
|
|
||||||
'forward_data',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
@ -107,36 +101,6 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
return $this->appendattrs['percentage'];
|
return $this->appendattrs['percentage'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 回复消息详情
|
|
||||||
* @return WebSocketDialogMsg|null
|
|
||||||
*/
|
|
||||||
public function getReplyDataAttribute()
|
|
||||||
{
|
|
||||||
if (!isset($this->appendattrs['reply_data'])) {
|
|
||||||
$this->appendattrs['reply_data'] = null;
|
|
||||||
if ($this->reply_id > 0) {
|
|
||||||
$this->appendattrs['reply_data'] = self::find($this->reply_id, ['id', 'userid', 'type', 'msg'])?->cancelAppend() ?: null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->appendattrs['reply_data'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 转发消息详情
|
|
||||||
* @return WebSocketDialogMsg|null
|
|
||||||
*/
|
|
||||||
public function getForwardDataAttribute()
|
|
||||||
{
|
|
||||||
if (!isset($this->appendattrs['forward_data'])) {
|
|
||||||
$this->appendattrs['forward_data'] = null;
|
|
||||||
if ($this->forward_id > 0) {
|
|
||||||
$this->appendattrs['forward_data'] = self::find($this->forward_id, ['id', 'userid', 'type', 'msg'])?->cancelAppend() ?: null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->appendattrs['forward_data'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息格式化
|
* 消息格式化
|
||||||
* @param $value
|
* @param $value
|
||||||
@ -147,13 +111,9 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
$value = Base::json2array($value);
|
$value = $this->formatDataMsg($this->type, $value);
|
||||||
if ($this->type === 'file') {
|
if (isset($value['reply_data'])) {
|
||||||
$value['type'] = in_array($value['ext'], ['jpg', 'jpeg', 'webp', 'png', 'gif']) ? 'img' : 'file';
|
$value['reply_data']['msg'] = $this->formatDataMsg($value['reply_data']['type'], $value['reply_data']['msg']);
|
||||||
$value['path'] = Base::fillUrl($value['path']);
|
|
||||||
$value['thumb'] = Base::fillUrl($value['thumb'] ?: Base::extIcon($value['ext']));
|
|
||||||
} else if ($this->type === 'record') {
|
|
||||||
$value['path'] = Base::fillUrl($value['path']);
|
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
@ -171,6 +131,27 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
return Base::json2array($value);
|
return Base::json2array($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理消息数据
|
||||||
|
* @param $type
|
||||||
|
* @param $msg
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
private function formatDataMsg($type, $msg)
|
||||||
|
{
|
||||||
|
if (!is_array($msg)) {
|
||||||
|
$msg = Base::json2array($msg);
|
||||||
|
}
|
||||||
|
if ($type === 'file') {
|
||||||
|
$msg['type'] = in_array($msg['ext'], ['jpg', 'jpeg', 'webp', 'png', 'gif']) ? 'img' : 'file';
|
||||||
|
$msg['path'] = Base::fillUrl($msg['path']);
|
||||||
|
$msg['thumb'] = Base::fillUrl($msg['thumb'] ?: Base::extIcon($msg['ext']));
|
||||||
|
} else if ($type === 'record') {
|
||||||
|
$msg['path'] = Base::fillUrl($msg['path']);
|
||||||
|
}
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取占比
|
* 获取占比
|
||||||
* @param bool|int $increment 是否新增阅读数
|
* @param bool|int $increment 是否新增阅读数
|
||||||
@ -399,7 +380,17 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
public function forwardMsg($dialogids, $userids, $user, $showSource = 1, $leaveMessage = '')
|
public function forwardMsg($dialogids, $userids, $user, $showSource = 1, $leaveMessage = '')
|
||||||
{
|
{
|
||||||
return AbstractModel::transaction(function () use ($dialogids, $user, $userids, $showSource, $leaveMessage) {
|
return AbstractModel::transaction(function () use ($dialogids, $user, $userids, $showSource, $leaveMessage) {
|
||||||
$originalMsg = Base::json2array($this->getRawOriginal('msg'));
|
$msgData = Base::json2array($this->getRawOriginal('msg'));
|
||||||
|
$forwardData = is_array($msgData['forward_data']) ? $msgData['forward_data'] : [];
|
||||||
|
$forwardId = $forwardData['id'] ?: $this->id;
|
||||||
|
$forwardUserid = $forwardData['userid'] ?: $this->userid;
|
||||||
|
$msgData['forward_data'] = [
|
||||||
|
'id' => $forwardId, // 转发的消息ID(原始)
|
||||||
|
'userid' => $forwardUserid, // 转发的消息会员ID(原始)
|
||||||
|
'parent_id' => $this->id, // 转发的消息ID
|
||||||
|
'parent_userid' => $this->userid, // 转发的消息会员ID
|
||||||
|
'show' => $showSource, // 是否显示原发送者信息
|
||||||
|
];
|
||||||
$msgs = [];
|
$msgs = [];
|
||||||
$already = [];
|
$already = [];
|
||||||
if ($dialogids) {
|
if ($dialogids) {
|
||||||
@ -407,7 +398,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
$dialogids = [$dialogids];
|
$dialogids = [$dialogids];
|
||||||
}
|
}
|
||||||
foreach ($dialogids as $dialogid) {
|
foreach ($dialogids as $dialogid) {
|
||||||
$res = self::sendMsg('forward-'.( $showSource ? 1 : 0).'-'.($this->forward_id ?: $this->id), $dialogid, $this->type, $originalMsg, $user->userid);
|
$res = self::sendMsg('forward-' . $forwardId, $dialogid, $this->type, $msgData, $user->userid);
|
||||||
if (Base::isSuccess($res)) {
|
if (Base::isSuccess($res)) {
|
||||||
$msgs[] = $res['data'];
|
$msgs[] = $res['data'];
|
||||||
$already[] = $dialogid;
|
$already[] = $dialogid;
|
||||||
@ -427,7 +418,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
}
|
}
|
||||||
$dialog = WebSocketDialog::checkUserDialog($user, $userid);
|
$dialog = WebSocketDialog::checkUserDialog($user, $userid);
|
||||||
if ($dialog && !in_array($dialog->id, $already)) {
|
if ($dialog && !in_array($dialog->id, $already)) {
|
||||||
$res = self::sendMsg('forward-'.( $showSource ? 1 : 0).'-'.($this->forward_id ?: $this->id), $dialog->id, $this->type, $originalMsg, $user->userid);
|
$res = self::sendMsg('forward-' . $forwardId, $dialog->id, $this->type, $msgData, $user->userid);
|
||||||
if (Base::isSuccess($res)) {
|
if (Base::isSuccess($res)) {
|
||||||
$msgs[] = $res['data'];
|
$msgs[] = $res['data'];
|
||||||
}
|
}
|
||||||
@ -437,6 +428,9 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (count($msgs) > 0) {
|
||||||
|
$this->increment('forward_num', count($msgs));
|
||||||
|
}
|
||||||
return Base::retSuccess('转发成功', [
|
return Base::retSuccess('转发成功', [
|
||||||
'msgs' => $msgs
|
'msgs' => $msgs
|
||||||
]);
|
]);
|
||||||
@ -848,7 +842,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
$update_id = intval(preg_match("/^update-(\d+)$/", $action, $match) ? $match[1] : 0);
|
$update_id = intval(preg_match("/^update-(\d+)$/", $action, $match) ? $match[1] : 0);
|
||||||
$change_id = intval(preg_match("/^change-(\d+)$/", $action, $match) ? $match[1] : 0);
|
$change_id = intval(preg_match("/^change-(\d+)$/", $action, $match) ? $match[1] : 0);
|
||||||
$reply_id = intval(preg_match("/^reply-(\d+)$/", $action, $match) ? $match[1] : 0);
|
$reply_id = intval(preg_match("/^reply-(\d+)$/", $action, $match) ? $match[1] : 0);
|
||||||
$forward_id = intval(preg_match("/^forward-(\d+)-(\d+)$/", $action, $match) ? $match[2] : 0);
|
$forward_id = intval(preg_match("/^forward-(\d+)$/", $action, $match) ? $match[1] : 0);
|
||||||
$sender = $sender === null ? User::userid() : $sender;
|
$sender = $sender === null ? User::userid() : $sender;
|
||||||
//
|
//
|
||||||
$dialog = WebSocketDialog::find($dialog_id);
|
$dialog = WebSocketDialog::find($dialog_id);
|
||||||
@ -901,26 +895,34 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
return Base::retSuccess('修改成功', $dialogMsg);
|
return Base::retSuccess('修改成功', $dialogMsg);
|
||||||
} else {
|
} else {
|
||||||
// 发送
|
// 发送
|
||||||
if ($reply_id && !self::whereId($reply_id)->increment('reply_num')) {
|
if ($reply_id) {
|
||||||
|
// 回复
|
||||||
|
$replyRow = self::whereId($reply_id)->whereDialogId($dialog_id)->first();
|
||||||
|
if (empty($replyRow)) {
|
||||||
throw new ApiException('回复的消息不存在');
|
throw new ApiException('回复的消息不存在');
|
||||||
}
|
}
|
||||||
// 转发
|
$replyMsg = Base::json2array($replyRow->getRawOriginal('msg'));
|
||||||
if ($forward_id && !self::whereId($forward_id)->increment('forward_num')) {
|
unset($replyMsg['reply_data']);
|
||||||
throw new ApiException('转发的消息不存在');
|
$msg['reply_data'] = [
|
||||||
|
'id' => $replyRow->id,
|
||||||
|
'userid' => $replyRow->userid,
|
||||||
|
'type' => $replyRow->type,
|
||||||
|
'msg' => $replyMsg,
|
||||||
|
];
|
||||||
|
$replyRow->increment('reply_num');
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
$dialogMsg = self::createInstance([
|
$dialogMsg = self::createInstance([
|
||||||
'dialog_id' => $dialog_id,
|
'dialog_id' => $dialog_id,
|
||||||
'dialog_type' => $dialog->type,
|
'dialog_type' => $dialog->type,
|
||||||
'reply_id' => $reply_id,
|
'reply_id' => $reply_id,
|
||||||
|
'forward_id' => $forward_id,
|
||||||
'userid' => $sender,
|
'userid' => $sender,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'mtype' => $mtype,
|
'mtype' => $mtype,
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
'read' => 0,
|
'read' => 0,
|
||||||
'forward_id' => $forward_id,
|
|
||||||
'forward_show' => $forward_id ? $match[1] : 1,
|
|
||||||
]);
|
]);
|
||||||
AbstractModel::transaction(function () use ($dialogMsg) {
|
AbstractModel::transaction(function () use ($dialogMsg) {
|
||||||
$dialogMsg->send = 1;
|
$dialogMsg->send = 1;
|
||||||
|
|||||||
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Module\Base;
|
||||||
|
use App\Models\WebSocketDialogMsg;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class ChangeForwardData extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('web_socket_dialog_msgs', function (Blueprint $table) {
|
||||||
|
if (Schema::hasColumn('web_socket_dialog_msgs', 'forward_show')) {
|
||||||
|
WebSocketDialogMsg::where("forward_id", ">", 0)->chunk(100, function ($items) {
|
||||||
|
/** @var WebSocketDialogMsg $item */
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$msg = Base::json2array($item->getRawOriginal('msg'));
|
||||||
|
$msg['forward_data'] = [
|
||||||
|
'id' => $item->forward_id,
|
||||||
|
'userid' => 0,
|
||||||
|
'parent_id' => $item->forward_id,
|
||||||
|
'parent_userid' => 0,
|
||||||
|
'show' => 0,
|
||||||
|
];
|
||||||
|
$original = WebSocketDialogMsg::select(['id', 'userid', 'forward_show'])->whereId($item->forward_id)->withTrashed()->first();
|
||||||
|
if ($original) {
|
||||||
|
$msg['forward_data']['userid'] = $original->userid;
|
||||||
|
$msg['forward_data']['parent_userid'] = $original->userid;
|
||||||
|
$msg['forward_data']['show'] = $original->forward_show;
|
||||||
|
}
|
||||||
|
$item->msg = Base::array2json($msg);
|
||||||
|
$item->save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$table->dropColumn("forward_show");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// 回滚数据 - 无法回滚
|
||||||
|
}
|
||||||
|
}
|
||||||
49
database/migrations/2024_03_18_153504_change_reply_data.php
Normal file
49
database/migrations/2024_03_18_153504_change_reply_data.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Module\Base;
|
||||||
|
use App\Models\WebSocketDialogMsg;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class ChangeReplyData extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
WebSocketDialogMsg::where("reply_id", ">", 0)->chunk(100, function ($items) {
|
||||||
|
/** @var WebSocketDialogMsg $item */
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$msg = Base::json2array($item->getRawOriginal('msg'));
|
||||||
|
$msg['reply_data'] = [
|
||||||
|
'id' => $item->reply_id,
|
||||||
|
'userid' => 0,
|
||||||
|
'type' => '',
|
||||||
|
'msg' => [],
|
||||||
|
];
|
||||||
|
$original = WebSocketDialogMsg::whereId($item->reply_id)->withTrashed()->first();
|
||||||
|
if ($original) {
|
||||||
|
$replyMsg = Base::json2array($original->getRawOriginal('msg'));
|
||||||
|
unset($replyMsg['reply_data']);
|
||||||
|
$msg['reply_data']['userid'] = $original->userid;
|
||||||
|
$msg['reply_data']['type'] = $original->type;
|
||||||
|
$msg['reply_data']['msg'] = $replyMsg;
|
||||||
|
}
|
||||||
|
$item->msg = Base::array2json($msg);
|
||||||
|
$item->save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// 回滚数据 - 无法回滚
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,7 +12,7 @@ default_storage_engine = InnoDB
|
|||||||
performance_schema_max_table_instances = 400
|
performance_schema_max_table_instances = 400
|
||||||
table_definition_cache = 400
|
table_definition_cache = 400
|
||||||
key_buffer_size = 1024M
|
key_buffer_size = 1024M
|
||||||
max_allowed_packet = 10G
|
max_allowed_packet = 4096M
|
||||||
table_open_cache = 2048
|
table_open_cache = 2048
|
||||||
sort_buffer_size = 4096K
|
sort_buffer_size = 4096K
|
||||||
net_buffer_length = 4K
|
net_buffer_length = 4K
|
||||||
@ -47,7 +47,7 @@ innodb_write_io_threads = 2
|
|||||||
|
|
||||||
[mysqldump]
|
[mysqldump]
|
||||||
quick
|
quick
|
||||||
max_allowed_packet = 500M
|
max_allowed_packet = 4096M
|
||||||
|
|
||||||
[mysql]
|
[mysql]
|
||||||
no-auto-rehash
|
no-auto-rehash
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
:dialog-type="dialogData.type"
|
:dialog-type="dialogData.type"
|
||||||
:hide-percentage="hidePercentage"
|
:hide-percentage="hidePercentage"
|
||||||
:hide-reply="hideReply"
|
:hide-reply="hideReply"
|
||||||
|
:hide-forward="hideForward"
|
||||||
:operate-visible="operateVisible"
|
:operate-visible="operateVisible"
|
||||||
:operate-action="operateVisible && source.id === operateItem.id"
|
:operate-action="operateVisible && source.id === operateItem.id"
|
||||||
:is-right-msg="isRightMsg"
|
:is-right-msg="isRightMsg"
|
||||||
@ -142,6 +143,10 @@ export default {
|
|||||||
return this.simpleView || this.msgId > 0
|
return this.simpleView || this.msgId > 0
|
||||||
},
|
},
|
||||||
|
|
||||||
|
hideForward() {
|
||||||
|
return this.simpleView || this.msgId > 0
|
||||||
|
},
|
||||||
|
|
||||||
classArray() {
|
classArray() {
|
||||||
return {
|
return {
|
||||||
'dialog-item': true,
|
'dialog-item': true,
|
||||||
|
|||||||
@ -10,16 +10,16 @@
|
|||||||
:class="headClass"
|
:class="headClass"
|
||||||
v-longpress="{callback: handleLongpress, delay: 300}">
|
v-longpress="{callback: handleLongpress, delay: 300}">
|
||||||
<!--回复-->
|
<!--回复-->
|
||||||
<div v-if="!hideReply && msgData.reply_data" class="dialog-reply no-dark-content" @click="viewReply">
|
<div v-if="!hideReply && msgData.reply_id && showReplyData(msgData.msg.reply_data)" class="dialog-reply no-dark-content" @click="viewReply">
|
||||||
<div class="reply-avatar">
|
<div class="reply-avatar">
|
||||||
<UserAvatar :userid="msgData.reply_data.userid" :show-icon="false" :show-name="true"/>
|
<UserAvatar :userid="msgData.msg.reply_data.userid" :show-icon="false" :show-name="true"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="reply-desc" v-html="$A.getMsgSimpleDesc(msgData.reply_data, 'image-preview')"></div>
|
<div class="reply-desc" v-html="$A.getMsgSimpleDesc(msgData.msg.reply_data, 'image-preview')"></div>
|
||||||
</div>
|
</div>
|
||||||
<!--转发-->
|
<!--转发-->
|
||||||
<div v-if="msgData.forward_show && msgData.forward_data && msgData.forward_data.userid" class="dialog-reply no-dark-content" @click="openDialog(msgData.forward_data.userid)">
|
<div v-if="!hideForward && msgData.forward_id && showForwardData(msgData.msg.forward_data)" class="dialog-reply no-dark-content" @click="openDialog(msgData.msg.forward_data.userid)">
|
||||||
<div class="reply-avatar">
|
<div class="reply-avatar">
|
||||||
<UserAvatar :userid="msgData.forward_data.userid" :show-icon="false" :show-name="true"/>
|
<UserAvatar :userid="msgData.msg.forward_data.userid" :show-icon="false" :show-name="true"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--详情-->
|
<!--详情-->
|
||||||
@ -292,6 +292,10 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
hideForward: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
operateVisible: {
|
operateVisible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
@ -353,9 +357,6 @@ export default {
|
|||||||
if (msgData.type) {
|
if (msgData.type) {
|
||||||
array.push(msgData.type)
|
array.push(msgData.type)
|
||||||
}
|
}
|
||||||
if (msgData.reply_data) {
|
|
||||||
array.push('reply-view')
|
|
||||||
}
|
|
||||||
if (operateAction) {
|
if (operateAction) {
|
||||||
array.push('operate-action')
|
array.push('operate-action')
|
||||||
if (operateEnter) {
|
if (operateEnter) {
|
||||||
@ -574,6 +575,20 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showReplyData(data) {
|
||||||
|
if (!$A.isJson(data)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return data.userid
|
||||||
|
},
|
||||||
|
|
||||||
|
showForwardData(data) {
|
||||||
|
if (!$A.isJson(data)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return data.show && data.userid
|
||||||
|
},
|
||||||
|
|
||||||
viewReply() {
|
viewReply() {
|
||||||
this.$emit("on-view-reply", {
|
this.$emit("on-view-reply", {
|
||||||
msg_id: this.msgData.id,
|
msg_id: this.msgData.id,
|
||||||
|
|||||||
@ -1478,12 +1478,12 @@ export default {
|
|||||||
id: this.getTempId(),
|
id: this.getTempId(),
|
||||||
dialog_id: this.dialogData.id,
|
dialog_id: this.dialogData.id,
|
||||||
reply_id: this.quoteId,
|
reply_id: this.quoteId,
|
||||||
reply_data: this.quoteData,
|
|
||||||
type: typeLoad ? 'loading' : 'text',
|
type: typeLoad ? 'loading' : 'text',
|
||||||
userid: this.userId,
|
userid: this.userId,
|
||||||
msg: {
|
msg: {
|
||||||
text: typeLoad ? '' : textBody,
|
|
||||||
type: textType,
|
type: textType,
|
||||||
|
text: typeLoad ? '' : textBody,
|
||||||
|
reply_data: this.quoteData,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
this.tempMsgs.push(tempMsg)
|
this.tempMsgs.push(tempMsg)
|
||||||
@ -1523,10 +1523,11 @@ export default {
|
|||||||
id: this.getTempId(),
|
id: this.getTempId(),
|
||||||
dialog_id: this.dialogData.id,
|
dialog_id: this.dialogData.id,
|
||||||
reply_id: this.quoteId,
|
reply_id: this.quoteId,
|
||||||
reply_data: this.quoteData,
|
|
||||||
type: 'record',
|
type: 'record',
|
||||||
userid: this.userId,
|
userid: this.userId,
|
||||||
msg,
|
msg: Object.assign(msg, {
|
||||||
|
reply_data: this.quoteData,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
this.tempMsgs.push(tempMsg)
|
this.tempMsgs.push(tempMsg)
|
||||||
this.msgType = ''
|
this.msgType = ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user