mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-18 03:33:24 +00:00
消息新增链接类型筛选
This commit is contained in:
parent
49f8e23aae
commit
27441eb82e
@ -286,6 +286,7 @@ class DialogController extends AbstractController
|
|||||||
* - position_id、prev_id、next_id 只有一个有效,优先循序为:position_id > prev_id > next_id
|
* - position_id、prev_id、next_id 只有一个有效,优先循序为:position_id > prev_id > next_id
|
||||||
* @apiParam {String} [mtype] 消息类型
|
* @apiParam {String} [mtype] 消息类型
|
||||||
* - tag: 标记
|
* - tag: 标记
|
||||||
|
* - link: 链接
|
||||||
* - text: 文本
|
* - text: 文本
|
||||||
* - image: 图片
|
* - image: 图片
|
||||||
* - file: 文件
|
* - file: 文件
|
||||||
@ -327,6 +328,8 @@ class DialogController extends AbstractController
|
|||||||
//
|
//
|
||||||
if ($mtype === 'tag') {
|
if ($mtype === 'tag') {
|
||||||
$builder->where('tag', '>', 0);
|
$builder->where('tag', '>', 0);
|
||||||
|
} elseif ($mtype === 'link') {
|
||||||
|
$builder->whereLink(1);
|
||||||
} elseif (in_array($mtype, ['text', 'image', 'file', 'record', 'meeting'])) {
|
} elseif (in_array($mtype, ['text', 'image', 'file', 'record', 'meeting'])) {
|
||||||
$builder->whereMtype($mtype);
|
$builder->whereMtype($mtype);
|
||||||
}
|
}
|
||||||
@ -382,7 +385,7 @@ class DialogController extends AbstractController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
if ($reDialog) {
|
if ($reDialog) {
|
||||||
$data['dialog'] = $dialog->formatData($user->userid);
|
$data['dialog'] = $dialog->formatData($user->userid, true);
|
||||||
}
|
}
|
||||||
return Base::retSuccess('success', $data);
|
return Base::retSuccess('success', $data);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,9 +54,10 @@ class WebSocketDialog extends AbstractModel
|
|||||||
/**
|
/**
|
||||||
* 格式化对话
|
* 格式化对话
|
||||||
* @param int $userid 会员ID
|
* @param int $userid 会员ID
|
||||||
|
* @param bool $hasData
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function formatData($userid)
|
public function formatData($userid, $hasData = false)
|
||||||
{
|
{
|
||||||
if (isset($this->search_msg_id)) {
|
if (isset($this->search_msg_id)) {
|
||||||
// 最后消息 (搜索预览消息)
|
// 最后消息 (搜索预览消息)
|
||||||
@ -118,6 +119,13 @@ class WebSocketDialog extends AbstractModel
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if ($hasData === true) {
|
||||||
|
$msgBuilder = WebSocketDialogMsg::whereDialogId($this->id);
|
||||||
|
$this->has_tag = $msgBuilder->clone()->where('tag', '>', 0)->exists();
|
||||||
|
$this->has_image = $msgBuilder->clone()->whereMtype('image')->exists();
|
||||||
|
$this->has_file = $msgBuilder->clone()->whereMtype('file')->exists();
|
||||||
|
$this->has_link = $msgBuilder->clone()->whereLink(1)->exists();
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property int|null $read 已阅数量
|
* @property int|null $read 已阅数量
|
||||||
* @property int|null $send 发送数量
|
* @property int|null $send 发送数量
|
||||||
* @property int|null $tag 标注会员ID
|
* @property int|null $tag 标注会员ID
|
||||||
|
* @property int|null $link 是否存在链接
|
||||||
* @property int|null $reply_num 有多少条回复
|
* @property int|null $reply_num 有多少条回复
|
||||||
* @property int|null $reply_id 回复ID
|
* @property int|null $reply_id 回复ID
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
@ -44,6 +45,7 @@ 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 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 whereMsg($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMsg($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMtype($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMtype($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereRead($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereRead($value)
|
||||||
@ -521,12 +523,19 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
*/
|
*/
|
||||||
public static function sendMsg($dialog_id, $reply_id, $type, $msg, $sender = 0)
|
public static function sendMsg($dialog_id, $reply_id, $type, $msg, $sender = 0)
|
||||||
{
|
{
|
||||||
|
$link = 0;
|
||||||
$mtype = $type;
|
$mtype = $type;
|
||||||
if ($type === 'text' && str_contains($msg['text'], '<img ')) {
|
if ($type === 'text') {
|
||||||
$mtype = 'image';
|
if (str_contains($msg['text'], '<a ') || preg_match("/https*:\/\//", $msg['text'])) {
|
||||||
}
|
$link = 1;
|
||||||
if ($type === 'file' && in_array($msg['ext'], ['jpg', 'jpeg', 'png', 'gif'])) {
|
}
|
||||||
$mtype = 'image';
|
if (str_contains($msg['text'], '<img ')) {
|
||||||
|
$mtype = 'image';
|
||||||
|
}
|
||||||
|
} elseif ($type === 'file') {
|
||||||
|
if (in_array($msg['ext'], ['jpg', 'jpeg', 'png', 'gif'])) {
|
||||||
|
$mtype = 'image';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
$dialogMsg = self::createInstance([
|
$dialogMsg = self::createInstance([
|
||||||
@ -535,6 +544,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
'userid' => $sender ?: User::userid(),
|
'userid' => $sender ?: User::userid(),
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'mtype' => $mtype,
|
'mtype' => $mtype,
|
||||||
|
'link' => $link,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
'read' => 0,
|
'read' => 0,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddWebSocketDialogMsgsLink extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$isAdd = false;
|
||||||
|
Schema::table('web_socket_dialog_msgs', function (Blueprint $table) use (&$isAdd) {
|
||||||
|
if (!Schema::hasColumn('web_socket_dialog_msgs', 'link')) {
|
||||||
|
$isAdd = true;
|
||||||
|
$table->boolean('link')->default(0)->after('tag')->nullable()->comment('是否存在链接');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if ($isAdd) {
|
||||||
|
DB::table('web_socket_dialog_msgs')->where('type', 'text')->where('msg', 'LIKE', '%<a %')->update([
|
||||||
|
'link' => 1
|
||||||
|
]);
|
||||||
|
DB::table('web_socket_dialog_msgs')->where('type', 'text')->where('msg', 'LIKE', '%http:%')->update([
|
||||||
|
'link' => 1
|
||||||
|
]);
|
||||||
|
DB::table('web_socket_dialog_msgs')->where('type', 'text')->where('msg', 'LIKE', '%https:%')->update([
|
||||||
|
'link' => 1
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('web_socket_dialog_msgs', function (Blueprint $table) {
|
||||||
|
$table->dropColumn("link");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -64,16 +64,18 @@
|
|||||||
<i class="taskfont dialog-create" @click="openCreateGroup"></i>
|
<i class="taskfont dialog-create" @click="openCreateGroup"></i>
|
||||||
</ETooltip>
|
</ETooltip>
|
||||||
</div>
|
</div>
|
||||||
<ul class="nav-tags">
|
<transition name="fade">
|
||||||
<li
|
<ul v-if="dialogMsgList.length > 10 && msgTags.length > 1 && windowScrollY === 0" class="nav-tags">
|
||||||
v-for="item in msgTags"
|
<li
|
||||||
:key="item.type"
|
v-for="item in msgTags"
|
||||||
:class="{active: msgType === item.type}"
|
:key="item.type"
|
||||||
@click="msgType=item.type">
|
:class="{active: msgType === item.type}"
|
||||||
<i class="taskfont" v-html="item.icon"></i>
|
@click="msgType=item.type">
|
||||||
<span>{{$L(item.label)}}</span>
|
<i class="taskfont" v-html="item.icon"></i>
|
||||||
</li>
|
<span>{{$L(item.label)}}</span>
|
||||||
</ul>
|
</li>
|
||||||
|
</ul>
|
||||||
|
</transition>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -81,6 +83,7 @@
|
|||||||
<VirtualList
|
<VirtualList
|
||||||
ref="scroller"
|
ref="scroller"
|
||||||
class="dialog-scroller scrollbar-overlay"
|
class="dialog-scroller scrollbar-overlay"
|
||||||
|
:class="scrollerClass"
|
||||||
:data-key="'id'"
|
:data-key="'id'"
|
||||||
:data-sources="allMsgs"
|
:data-sources="allMsgs"
|
||||||
:data-component="msgItem"
|
:data-component="msgItem"
|
||||||
@ -340,14 +343,7 @@ export default {
|
|||||||
msgItem: DialogItem,
|
msgItem: DialogItem,
|
||||||
msgText: '',
|
msgText: '',
|
||||||
msgNew: 0,
|
msgNew: 0,
|
||||||
|
|
||||||
msgType: '',
|
msgType: '',
|
||||||
msgTags: [
|
|
||||||
{icon: '', type: '', label: '消息'},
|
|
||||||
{icon: '', type: 'tag', label: '标注'},
|
|
||||||
{icon: '', type: 'image', label: '图片'},
|
|
||||||
{icon: '', type: 'file', label: '文件'},
|
|
||||||
],
|
|
||||||
|
|
||||||
allMsgs: [],
|
allMsgs: [],
|
||||||
tempMsgs: [],
|
tempMsgs: [],
|
||||||
@ -427,20 +423,21 @@ export default {
|
|||||||
if (!this.isReady) {
|
if (!this.isReady) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return this.dialogMsgs.filter(item => this.msgFilter(item)).sort((a, b) => {
|
return this.dialogMsgs.filter(item => item.dialog_id == this.dialogId);
|
||||||
return a.id - b.id;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
tempMsgList() {
|
tempMsgList() {
|
||||||
if (!this.isReady) {
|
if (!this.isReady) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return this.tempMsgs.filter(item => this.msgFilter(item));
|
return this.tempMsgs.filter(item => item.dialog_id == this.dialogId);
|
||||||
},
|
},
|
||||||
|
|
||||||
allMsgList() {
|
allMsgList() {
|
||||||
const {dialogMsgList, tempMsgList} = this;
|
const dialogMsgList = this.dialogMsgList.filter(item => this.msgFilter(item)).sort((a, b) => {
|
||||||
|
return a.id - b.id;
|
||||||
|
})
|
||||||
|
const tempMsgList = this.tempMsgList.filter(item => this.msgFilter(item))
|
||||||
if (tempMsgList.length > 0) {
|
if (tempMsgList.length > 0) {
|
||||||
const array = [];
|
const array = [];
|
||||||
array.push(...dialogMsgList);
|
array.push(...dialogMsgList);
|
||||||
@ -477,6 +474,25 @@ export default {
|
|||||||
return '发送文件'
|
return '发送文件'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
msgTags() {
|
||||||
|
const array = [
|
||||||
|
{icon: '', type: '', label: '消息'},
|
||||||
|
];
|
||||||
|
if (this.dialogData.has_tag) {
|
||||||
|
array.push({icon: '', type: 'tag', label: '标注'})
|
||||||
|
}
|
||||||
|
if (this.dialogData.has_image) {
|
||||||
|
array.push({icon: '', type: 'image', label: '图片'})
|
||||||
|
}
|
||||||
|
if (this.dialogData.has_file) {
|
||||||
|
array.push({icon: '', type: 'file', label: '文件'})
|
||||||
|
}
|
||||||
|
if (this.dialogData.has_link) {
|
||||||
|
array.push({icon: '', type: 'link', label: '链接'})
|
||||||
|
}
|
||||||
|
return array
|
||||||
|
},
|
||||||
|
|
||||||
wrapperClass() {
|
wrapperClass() {
|
||||||
if (['ready', 'ing'].includes(this.recordState)) {
|
if (['ready', 'ing'].includes(this.recordState)) {
|
||||||
return ['record-ready']
|
return ['record-ready']
|
||||||
@ -484,6 +500,10 @@ export default {
|
|||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
|
|
||||||
|
scrollerClass() {
|
||||||
|
return !this.$slots.head && this.msgTags.length > 1 && this.windowScrollY === 0 ? 'default-header' : null
|
||||||
|
},
|
||||||
|
|
||||||
pasteWrapperClass() {
|
pasteWrapperClass() {
|
||||||
if (this.pasteItem.find(({type}) => type !== 'image')) {
|
if (this.pasteItem.find(({type}) => type !== 'image')) {
|
||||||
return ['multiple'];
|
return ['multiple'];
|
||||||
@ -567,6 +587,7 @@ export default {
|
|||||||
|
|
||||||
msgType(type) {
|
msgType(type) {
|
||||||
if (!type) return
|
if (!type) return
|
||||||
|
this.onToBottom()
|
||||||
this.$store.dispatch("getDialogMsgs", {
|
this.$store.dispatch("getDialogMsgs", {
|
||||||
dialog_id: this.dialogId,
|
dialog_id: this.dialogId,
|
||||||
msg_id: this.msgId,
|
msg_id: this.msgId,
|
||||||
@ -780,6 +801,10 @@ export default {
|
|||||||
if (!item.tag) {
|
if (!item.tag) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
} else if (this.msgType === 'link') {
|
||||||
|
if (!item.link) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
} else if (this.msgType !== item.mtype) {
|
} else if (this.msgType !== item.mtype) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -789,7 +814,7 @@ export default {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return item.dialog_id == this.dialogId;
|
return true
|
||||||
},
|
},
|
||||||
|
|
||||||
onSearchMsgId() {
|
onSearchMsgId() {
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dialog-scroller {
|
.dialog-scroller {
|
||||||
padding: 16px 16px 0;
|
padding-right: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@
|
|||||||
list-style: none;
|
list-style: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 0 8px;
|
margin: 0 7px;
|
||||||
padding: 3px 8px;
|
padding: 3px 8px;
|
||||||
background-color: #c0c4cc;
|
background-color: #c0c4cc;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
@ -232,7 +232,6 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: 0 1px 6px rgba(255, 255, 255, 0.2);
|
box-shadow: 0 1px 6px rgba(255, 255, 255, 0.2);
|
||||||
|
|
||||||
|
|
||||||
.taskfont {
|
.taskfont {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
padding-right: 6px;
|
padding-right: 6px;
|
||||||
@ -254,7 +253,11 @@
|
|||||||
.dialog-scroller {
|
.dialog-scroller {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 48px 32px 0;
|
padding: 16px 32px 0;
|
||||||
|
|
||||||
|
&.default-header {
|
||||||
|
padding-top: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
.dialog-shake {
|
.dialog-shake {
|
||||||
animation: ani-dialog-shake 600ms ease-in-out;
|
animation: ani-dialog-shake 600ms ease-in-out;
|
||||||
@ -1276,6 +1279,10 @@
|
|||||||
}
|
}
|
||||||
.nav-tags {
|
.nav-tags {
|
||||||
top: 60px;
|
top: 60px;
|
||||||
|
|
||||||
|
> li {
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.dialog-scroller {
|
.dialog-scroller {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user