no message
This commit is contained in:
parent
c9bcf6ac83
commit
4a526ecefb
@ -125,8 +125,14 @@ class WebSocketService implements WebSocketHandlerInterface
|
|||||||
* 已阅消息
|
* 已阅消息
|
||||||
*/
|
*/
|
||||||
case 'readMsg':
|
case 'readMsg':
|
||||||
$dialogMsg = WebSocketDialogMsg::whereId(intval($data['id']))->first();
|
$ids = is_array($data['id']) ? $data['id'] : [$data['id']];
|
||||||
$dialogMsg && $dialogMsg->readSuccess($this->getUserid($frame->fd));
|
$userid = $this->getUserid($frame->fd);
|
||||||
|
$list = WebSocketDialogMsg::whereIn('id', $ids)->get();
|
||||||
|
if ($list->isNotEmpty()) {
|
||||||
|
foreach ($list as $item) {
|
||||||
|
$item->readSuccess($userid);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -36,7 +36,7 @@ class LineTask extends AbstractTask
|
|||||||
$fd[] = $ws->fd;
|
$fd[] = $ws->fd;
|
||||||
}
|
}
|
||||||
if ($fd) {
|
if ($fd) {
|
||||||
PushTask::pushIgnoreFail([
|
PushTask::push([
|
||||||
'fd' => $fd,
|
'fd' => $fd,
|
||||||
'msg' => [
|
'msg' => [
|
||||||
'type' => 'line',
|
'type' => 'line',
|
||||||
|
@ -69,21 +69,19 @@ class PushTask extends AbstractTask
|
|||||||
*/
|
*/
|
||||||
public static function resendTmpMsgForUserid($userid)
|
public static function resendTmpMsgForUserid($userid)
|
||||||
{
|
{
|
||||||
|
WebSocketTmpMsg::whereCreateId($userid)
|
||||||
$lists = WebSocketTmpMsg::whereCreateId($userid)
|
|
||||||
->whereSend(0)
|
->whereSend(0)
|
||||||
->where('created_at', '>', Carbon::now()->subMinute()) // 1分钟内添加的数据
|
->where('created_at', '>', Carbon::now()->subMinute()) // 1分钟内添加的数据
|
||||||
->orderBy('id')
|
->orderBy('id')
|
||||||
->get();
|
->chunk(100, function($list) use ($userid) {
|
||||||
if ($lists->isNotEmpty()) {
|
foreach ($list as $item) {
|
||||||
foreach ($lists as $item) {
|
self::push([
|
||||||
self::push([
|
'tmp_msg_id' => $item->id,
|
||||||
'tmp_msg_id' => $item->id,
|
'userid' => $userid,
|
||||||
'userid' => $userid,
|
'msg' => Base::json2array($item->msg),
|
||||||
'msg' => Base::json2array($item->msg),
|
]);
|
||||||
]);
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,7 +91,7 @@ class PushTask extends AbstractTask
|
|||||||
* @param int $delay 延迟推送时间,默认:1秒($key填写时有效)
|
* @param int $delay 延迟推送时间,默认:1秒($key填写时有效)
|
||||||
* @param bool $addFail 失败后是否保存到临时表,等上线后继续发送
|
* @param bool $addFail 失败后是否保存到临时表,等上线后继续发送
|
||||||
*/
|
*/
|
||||||
public static function push(array $lists, $key = '', $delay = 1, $addFail = true)
|
public static function push(array $lists, $key = '', $delay = 1, $addFail = false)
|
||||||
{
|
{
|
||||||
if (!is_array($lists) || empty($lists)) {
|
if (!is_array($lists) || empty($lists)) {
|
||||||
return;
|
return;
|
||||||
@ -169,11 +167,11 @@ class PushTask extends AbstractTask
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送消息(忽略错误)
|
* 推送消息(出错后保存临时表,上线后尝试重新发送)
|
||||||
* @param array $lists 消息列表
|
* @param array $lists 消息列表
|
||||||
*/
|
*/
|
||||||
public static function pushIgnoreFail(array $lists)
|
public static function pushR(array $lists)
|
||||||
{
|
{
|
||||||
self::push($lists, '', 1, false);
|
self::push($lists, '', 1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.parsingData()
|
this.parsingRead()
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
@ -96,7 +96,7 @@ export default {
|
|||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
msgData() {
|
msgData() {
|
||||||
this.parsingData()
|
this.parsingRead()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -115,14 +115,11 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
parsingData() {
|
parsingRead() {
|
||||||
const {userid, r, id} = this.msgData;
|
const {userid, r, id} = this.msgData;
|
||||||
if (userid == this.userId) return;
|
if (userid == this.userId) return;
|
||||||
if ($A.isJson(r) && r.read_at) return;
|
if ($A.isJson(r) && r.read_at) return;
|
||||||
this.$store.commit('wsSend', {
|
this.$store.commit('wsMsgRead', id);
|
||||||
type: 'readMsg',
|
|
||||||
data: {id}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
formatTime(date) {
|
formatTime(date) {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</ScrollerY>
|
</ScrollerY>
|
||||||
<div :class="['dialog-footer', msgNew > 0 ? 'newmsg' : '']">
|
<div :class="['dialog-footer', msgNew > 0 && dialogMsgList.length > 0 ? 'newmsg' : '']">
|
||||||
<div class="dialog-newmsg" @click="goNewBottom">{{$L('有' + msgNew + '条新消息')}}</div>
|
<div class="dialog-newmsg" @click="goNewBottom">{{$L('有' + msgNew + '条新消息')}}</div>
|
||||||
<DragInput class="dialog-input" v-model="msgText" type="textarea" :rows="1" :autosize="{ minRows: 1, maxRows: 3 }" :maxlength="255" @on-keydown="chatKeydown" @on-input-paste="pasteDrag" :placeholder="$L('输入消息...')" />
|
<DragInput class="dialog-input" v-model="msgText" type="textarea" :rows="1" :autosize="{ minRows: 1, maxRows: 3 }" :maxlength="255" @on-keydown="chatKeydown" @on-input-paste="pasteDrag" :placeholder="$L('输入消息...')" />
|
||||||
<DialogUpload
|
<DialogUpload
|
||||||
|
21
resources/assets/js/store/mutations.js
vendored
21
resources/assets/js/store/mutations.js
vendored
@ -1,3 +1,5 @@
|
|||||||
|
import state from "./state";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
/**
|
/**
|
||||||
* 切换Boolean变量
|
* 切换Boolean变量
|
||||||
@ -419,6 +421,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送已阅消息
|
||||||
|
* @param state
|
||||||
|
* @param msgId
|
||||||
|
*/
|
||||||
|
wsMsgRead(state, msgId) {
|
||||||
|
state.wsReadWaitList.push(msgId);
|
||||||
|
clearTimeout(state.wsReadTimeout);
|
||||||
|
state.wsReadTimeout = setTimeout(() => {
|
||||||
|
this.commit('wsSend', {
|
||||||
|
type: 'readMsg',
|
||||||
|
data: {
|
||||||
|
id: $A.cloneJSON(state.wsReadWaitList)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
state.wsReadWaitList = [];
|
||||||
|
}, 10);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听消息
|
* 监听消息
|
||||||
* @param state
|
* @param state
|
||||||
|
2
resources/assets/js/store/state.js
vendored
2
resources/assets/js/store/state.js
vendored
@ -172,6 +172,8 @@ state.wsMsg = {};
|
|||||||
state.wsCall = {};
|
state.wsCall = {};
|
||||||
state.wsTimeout = null;
|
state.wsTimeout = null;
|
||||||
state.wsListener = {};
|
state.wsListener = {};
|
||||||
|
state.wsReadTimeout = null;
|
||||||
|
state.wsReadWaitList = [];
|
||||||
|
|
||||||
// 项目信息
|
// 项目信息
|
||||||
state.projectLoad = 0;
|
state.projectLoad = 0;
|
||||||
|
4
resources/assets/sass/main.scss
vendored
4
resources/assets/sass/main.scss
vendored
@ -1119,8 +1119,8 @@ body {
|
|||||||
}
|
}
|
||||||
.dialog-num {
|
.dialog-num {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 12px;
|
top: 10px;
|
||||||
left: 38px;
|
left: 42px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
.ivu-badge-count {
|
.ivu-badge-count {
|
||||||
height: 18px;
|
height: 18px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user