no message
This commit is contained in:
parent
4a526ecefb
commit
6579a59207
@ -111,6 +111,17 @@ class DialogController extends AbstractController
|
||||
return Base::retSuccess('success', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未读消息
|
||||
*/
|
||||
public function msg__unread()
|
||||
{
|
||||
$unread = WebSocketDialogMsgRead::whereUserid(User::token2userid())->whereReadAt(null)->count();
|
||||
return Base::retSuccess('success', [
|
||||
'unread' => $unread,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
|
@ -119,6 +119,7 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
'userid' => $this->userid,
|
||||
'msg' => [
|
||||
'type' => 'dialog',
|
||||
'mode' => 'up',
|
||||
'data' => $this->toArray(),
|
||||
]
|
||||
]);
|
||||
|
@ -64,6 +64,7 @@ class WebSocketDialogMsgTask extends AbstractTask
|
||||
'userid' => $pushIds,
|
||||
'msg' => [
|
||||
'type' => 'dialog',
|
||||
'mode' => 'add',
|
||||
'data' => $this->dialogMsgArray,
|
||||
]
|
||||
]);
|
||||
|
@ -17,6 +17,7 @@
|
||||
<li @click="toggleRoute('messenger')" :class="classNameRoute('messenger')">
|
||||
<Icon type="ios-chatbubbles-outline" />
|
||||
<div class="menu-title">{{$L('消息')}}</div>
|
||||
<Badge class="menu-badge" :count="dialogMsgUnread"></Badge>
|
||||
</li>
|
||||
<li @click="toggleRoute('setting/personal')" :class="classNameRoute('setting')">
|
||||
<Icon type="ios-cog-outline" />
|
||||
@ -141,10 +142,15 @@
|
||||
margin-top: -1px;
|
||||
}
|
||||
.menu-title {
|
||||
flex: 1;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.menu-badge {
|
||||
margin-left: 12px;
|
||||
transform: scale(0.9);
|
||||
}
|
||||
&.menu-project {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -251,20 +257,39 @@ export default {
|
||||
columns: [],
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$store.commit('getUserInfo');
|
||||
},
|
||||
|
||||
deactivated() {
|
||||
this.addShow = false;
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['projectList']),
|
||||
...mapState(['wsMsg', 'dialogShow', 'dialogMsgUnread', 'projectList']),
|
||||
},
|
||||
|
||||
watch: {
|
||||
'$route' (route) {
|
||||
this.curPath = route.path;
|
||||
},
|
||||
|
||||
/**
|
||||
* 收到新消息
|
||||
* @param msg
|
||||
*/
|
||||
wsMsg(msg) {
|
||||
const {type, mode} = msg;
|
||||
if (type === "dialog" && mode === "add") {
|
||||
if (this.dialogShow) {
|
||||
return;
|
||||
}
|
||||
this.$store.state.dialogMsgUnread++;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
initLanguage() {
|
||||
this.columns = [{
|
||||
|
@ -65,6 +65,22 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$store.state.dialogShow = true;
|
||||
},
|
||||
|
||||
destroyed() {
|
||||
this.$store.state.dialogShow = false;
|
||||
},
|
||||
|
||||
activated() {
|
||||
this.$store.state.dialogShow = true;
|
||||
},
|
||||
|
||||
deactivated() {
|
||||
this.$store.state.dialogShow = false;
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['userId', 'dialogId', 'dialogDetail', 'dialogMsgLoad', 'dialogMsgList']),
|
||||
|
||||
|
@ -108,7 +108,7 @@ export default {
|
||||
methods: {
|
||||
getMsg() {
|
||||
if (this.projectChatShow && this.projectDetail.dialog_id) {
|
||||
this.$store.commit('getDialogMsg', this.projectDetail.dialog_id);
|
||||
this.$store.commit('getDialogMsgList', this.projectDetail.dialog_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['dialogId', 'wsMsg']),
|
||||
...mapState(['dialogId', 'dialogShow', 'wsMsg']),
|
||||
|
||||
dialogLists() {
|
||||
const {dialogKey} = this;
|
||||
@ -99,9 +99,9 @@ export default {
|
||||
* @param msg
|
||||
*/
|
||||
wsMsg(msg) {
|
||||
const {type, data} = msg;
|
||||
if (type === "dialog") {
|
||||
if (this.dialogId == data.dialog_id) {
|
||||
const {type, mode, data} = msg;
|
||||
if (type === "dialog" && mode === "add") {
|
||||
if (this.dialogShow && this.dialogId == data.dialog_id) {
|
||||
return;
|
||||
}
|
||||
let dialog = this.dialogList.find(({id}) => id == data.dialog_id);
|
||||
@ -120,7 +120,8 @@ export default {
|
||||
*/
|
||||
dialogId(dialog_id) {
|
||||
let dialog = this.dialogList.find(({id}) => id == dialog_id);
|
||||
if (dialog) {
|
||||
if (dialog && dialog.unread > 0) {
|
||||
this.$store.state.dialogMsgUnread-= dialog.unread;
|
||||
this.$set(dialog, 'unread', 0);
|
||||
}
|
||||
}
|
||||
@ -128,7 +129,7 @@ export default {
|
||||
|
||||
methods: {
|
||||
openDialog(dialog) {
|
||||
this.$store.commit('getDialogMsg', dialog.id);
|
||||
this.$store.commit('getDialogMsgList', dialog.id);
|
||||
},
|
||||
|
||||
getDialogLists() {
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="project">
|
||||
<PageTitle>{{ $L('项目面板') }}</PageTitle>
|
||||
<ProjectList/>
|
||||
<ProjectDialog v-show="$store.state.projectChatShow"/>
|
||||
<ProjectDialog v-if="$store.state.projectChatShow"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
25
resources/assets/js/store/mutations.js
vendored
25
resources/assets/js/store/mutations.js
vendored
@ -64,6 +64,7 @@ export default {
|
||||
state.userToken = userInfo.token;
|
||||
state.userIsAdmin = state.method.inArray('admin', userInfo.identity);
|
||||
state.method.setStorage('userInfo', state.userInfo);
|
||||
this.commit('getDialogMsgUnread');
|
||||
this.commit('getProjectList');
|
||||
this.commit('wsConnection');
|
||||
},
|
||||
@ -215,7 +216,7 @@ export default {
|
||||
* @param state
|
||||
* @param dialog_id
|
||||
*/
|
||||
getDialogMsg(state, dialog_id) {
|
||||
getDialogMsgList(state, dialog_id) {
|
||||
if (state.method.runNum(dialog_id) === 0) {
|
||||
return;
|
||||
}
|
||||
@ -273,6 +274,28 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取未读信息
|
||||
* @param state
|
||||
*/
|
||||
getDialogMsgUnread(state) {
|
||||
const unread = state.dialogMsgUnread;
|
||||
$A.apiAjax({
|
||||
url: 'dialog/msg/unread',
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
if (unread === state.dialogMsgUnread) {
|
||||
state.dialogMsgUnread = data.unread;
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.commit('getDialogMsgUnread');
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据消息ID 删除 或 替换 对话数据
|
||||
* @param state
|
||||
|
6
resources/assets/js/store/state.js
vendored
6
resources/assets/js/store/state.js
vendored
@ -144,9 +144,7 @@ const method = {
|
||||
};
|
||||
|
||||
// 方法类
|
||||
const state = {
|
||||
method
|
||||
};
|
||||
const state = { method };
|
||||
|
||||
// Boolean变量
|
||||
[
|
||||
@ -188,9 +186,11 @@ state.projectMsgUnread = 0;
|
||||
|
||||
// 会话消息
|
||||
state.dialogId = 0;
|
||||
state.dialogShow = false;
|
||||
state.dialogDetail = {};
|
||||
state.dialogMsgLoad = 0;
|
||||
state.dialogMsgList = [];
|
||||
state.dialogMsgUnread = 0;
|
||||
|
||||
// 任务优先级
|
||||
state.taskPriority = [];
|
||||
|
7
resources/assets/sass/main.scss
vendored
7
resources/assets/sass/main.scss
vendored
@ -1122,12 +1122,7 @@ body {
|
||||
top: 10px;
|
||||
left: 42px;
|
||||
font-size: 12px;
|
||||
.ivu-badge-count {
|
||||
height: 18px;
|
||||
min-width: 18px;
|
||||
line-height: 16px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
transform: scale(0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user