4aba9b59
wwk
1
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
|
<template>
<div class="right-menu">
<template v-if="device!=='mobile'">
<template v-if="showSearch">
<search id="header-search" class="right-menu-item" />
</template>
<!-- <screenfull id="screenfull" class="right-menu-item hover-effect" /> -->
<!-- <el-tooltip :content="$t('navbar.chat')" placement="bottom">
<i class="icon-ym icon-ym-header-IM right-menu-item hover-effect" @click="openUserList()"
:class="{'twinkle':isTwinkle}"></i>
</el-tooltip>
<el-tooltip :content="$t('navbar.notice')" placement="bottom">
<div class="right-menu-item hover-effect" @click="$refs.MessageList.init()">
<el-badge :value="messageCount" :hidden="!messageCount" :max="99">
<i class="icon-ym icon-ym-header-message"></i>
</el-badge>
</div>
</el-tooltip> -->
<template v-if="showLanguage">
<lang-select class="right-menu-item hover-effect" />
</template>
</template>
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="hover">
<div class="avatar-wrapper">
<el-avatar :size="26" :src="define.comUrl + userInfo.headIcon" class="user-avatar"
v-if="userInfo.headIcon" />
<span>{{userInfo.userName}}</span>
<i class="el-icon-arrow-down"></i>
</div>
<el-dropdown-menu slot="dropdown">
<router-link to="/profile">
<el-dropdown-item>
<i class="icon-ym icon-ym-header-userInfo"></i>{{ $t('navbar.profile') }}
</el-dropdown-item>
</router-link>
<!-- <a href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=dA0dGhkVHQcbEgA0BQVaFxsZ"
target="_blank">
<el-dropdown-item>
<i class="icon-ym icon-ym-header-feedBack"></i>{{ $t('navbar.feedback') }}
</el-dropdown-item>
</a>
<el-dropdown-item @click.native="visible = true">
<i class="icon-ym icon-ym-header-about"></i>{{ $t('navbar.about') }}
</el-dropdown-item>
<el-dropdown-item @click.native="lock">
<i class="icon-ym icon-ym-header-lockScreen"></i>{{ $t('navbar.lockScreen') }}
</el-dropdown-item> -->
<el-dropdown-item divided @click.native="handleLogout">
<i class="icon-ym icon-ym-header-loginOut"></i>{{ $t('navbar.logOut') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-tooltip :content="$t('navbar.setting')" placement="bottom">
<div class="right-menu-item hover-effect" @click="$refs.Settings.init()" v-if="showSettings">
<i class="icon-ym icon-ym-header-pannel"></i>
</div>
</el-tooltip>
<el-dialog title="关于平台" :close-on-click-modal="false" :visible.sync="visible"
class="NCC-dialog NCC-dialog_center about-dialog" lock-scroll width="400px">
<div class="about-dialog-main">
<div>
<img src="@/assets/images/ncc.png" class="about-logo" />
</div>
<div>
<p class="title"><a href="http://www.qhzysoft.com" target="_blank">安第斯管理系统</a></p>
<p>版本:3.2</p>
<p>作者:泰怡萱软件</p>
<p>泰怡萱软件</p>
</div>
</div>
<p class="about-dialog-main-tip">实现无纸化协同办公,构建企业数字化生态!</p>
</el-dialog>
<MessageList ref="MessageList" @read='read' />
<Settings ref="Settings" />
<UserList ref="UserList" @changeTwinkle='changeTwinkle' />
</div>
</template>
<script>
import { mapGetters, mapState } from 'vuex'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import LangSelect from '@/components/LangSelect'
import Search from '@/components/HeaderSearch'
import MessageList from './MessageList'
import Settings from './settings'
import UserList from './userList/UserList'
import dragDialog from "@/directive/el-drag-dialog";
import ReconnectingWebSocket from 'reconnecting-websocket'
export default {
directives: { dragDialog },
components: {
Screenfull,
SizeSelect,
LangSelect,
Search,
MessageList,
UserList,
Settings
},
computed: {
...mapState({
showLanguage: state => state.settings.showLanguage,
showSearch: state => state.settings.showSearch,
showSettings: state => state.settings.showSettings,
}),
...mapGetters(['device', 'userInfo']),
},
data() {
return {
visible: false,
isTwinkle: false,
messageCount: 0,
userList: []
}
},
created() {
this.initWebSocket()
},
destroyed() {
if (this.socket) {
//离开路由之后断开websocket连接
this.socket.close()
this.socket = null
this.$store.commit('user/SET_SOCKET', this.socket)
}
},
methods: {
initWebSocket() {
this.socket = this.$store.getters.socket || null
if ('WebSocket' in window) {
if (!this.socket) {
this.socket = new ReconnectingWebSocket(this.define.WebSocketUrl)
this.$store.commit('user/SET_SOCKET', this.socket)
}
//添加事件监听
let socket = this.socket
socket.onopen = () => {
var onConnection = {
"method": "OnConnection", "token": this.$store.getters.token, "mobileDevice": false
}
socket.send(JSON.stringify(onConnection))
}
socket.onmessage = (event) => {
let data = JSON.parse(event.data)
if (data.method == 'initMessage') {
this.messageCount = data.unreadMessageCount + data.unreadNoticeCount
this.isTwinkle = !!data.unreadNums.length
}
//用户在线
if (data.method == 'Online') {
}
//用户离线
if (data.method == 'Offline') {
}
//消息推送(消息公告用的)
if (data.method == 'messagePush') {
this.messageCount += data.unreadNoticeCount
if (this.$refs.MessageList.visible) this.$refs.MessageList.init()
}
//用户过期
if (data.method == 'logout') {
this.$message({
message: data.msg || '登录过期,请重新登录',
type: 'error',
duration: 1000,
onClose: () => {
this.$store.dispatch('user/resetToken').then(() => {
location.reload()
})
}
})
}
//接收对方发送的消息
if (data.method == 'receiveMessage') {
//判断是否打开窗口
if (this.$refs.UserList && this.$refs.UserList.$refs.NCCIm && this.$refs.UserList.$refs.NCCIm.visible) {
if (this.$refs.UserList.$refs.NCCIm.info.id === data.formUserId) {
let messIitem = {
userId: data.formUserId,
messageType: data.messageType,
message: data.formMessage,
dateTime: this.ncc.toDate(data.dateTime)
}
this.$refs.UserList.$refs.NCCIm.addItem(messIitem)
//更新已读
let updateReadMessage = {
method: "UpdateReadMessage",
formUserId: data.formUserId,
token: this.$store.getters.token
}
socket.send(JSON.stringify(updateReadMessage))
this.$refs.UserList.updateReply(data)
} else {
this.$refs.UserList.updateReply(data, 1)
this.isTwinkle = true
}
} else {
this.$refs.UserList.updateReply(data, 1)
this.isTwinkle = true
}
}
//显示自己发送的消息
if (data.method == 'sendMessage') {
if (this.$refs.UserList.$refs.NCCIm.info.id !== data.toUserId) return
//添加到客户端
let messIitem = {
userId: data.UserId,
messageType: data.messageType,
message: data.toMessage,
dateTime: this.ncc.toDate(data.dateTime)
}
this.$refs.UserList.updateLatestMessage(data)
this.$refs.UserList.$refs.NCCIm.addItem(messIitem)
}
//消息列表
if (data.method == 'messageList') {
this.$refs.UserList.$refs.NCCIm.getList(data)
}
}
}
},
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},
handleLogout() {
this.$confirm('您确定要退出应用程序吗?', '提示', {
type: 'warning'
}).then(() => {
this.logout();
}).catch(() => { });
},
async logout() {
await this.$store.dispatch('user/logout')
// this.$router.push(`/login?redirect=${this.$route.fullPath}`)
this.$router.push(`/login`)
},
lock() {
this.$store.dispatch('user/setLock')
this.$nextTick(() => {
this.$router.push('/lockScreen')
})
},
read(isAll) {
if (isAll) {
this.messageCount = 0
} else {
this.messageCount -= 1
this.messageCount = this.messageCount >= 0 ? this.messageCount : 0
}
},
openUserList() {
this.$refs.UserList.init()
},
changeTwinkle(boo) {
this.isTwinkle = boo
}
}
}
</script>
<style lang="scss" scoped>
.navbar {
.right-menu {
float: right;
height: 100%;
&:focus {
outline: none;
}
.right-menu-item {
display: inline-block;
padding: 0 8px;
height: 100%;
font-size: 18px;
color: #666666;
vertical-align: text-bottom;
line-height: 60px;
&.hover-effect {
cursor: pointer;
transition: background 0.3s;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
>>> .el-badge {
line-height: 1;
.el-badge__content {
top: -4px;
}
}
>>> .icon-ym {
font-size: 18px;
}
.icon-ym {
font-size: 20px;
}
}
.avatar-container {
// margin-right: 30px;
.avatar-wrapper {
position: relative;
.user-avatar {
cursor: pointer;
vertical-align: top;
margin-top: 18px;
margin-right: 2px;
}
.el-icon-caret-bottom {
cursor: pointer;
position: absolute;
right: -20px;
top: 24px;
font-size: 18px;
}
span {
font-size: 14px;
line-height: 60px;
}
}
}
}
}
.about-dialog {
&.NCC-dialog.NCC-dialog_center >>> .el-dialog .el-dialog__body {
padding: 0 0 40px 0;
}
.about-dialog-main {
display: flex;
align-items: center;
height: 150px;
padding: 0 30px;
.about-logo {
display: inline-block;
width: 95px;
height: auto;
line-height: 95px;
text-align: center;
border-radius: 10px;
color: #fff;
margin-right: 30px;
}
line-height: 24px;
}
.about-dialog-main-tip {
font-size: 12px;
padding-left: 30px;
margin: 0;
}
.title {
font-size: 16px;
font-weight: 600;
}
}
/* 定义keyframe动画,命名为blink */
@keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 1;
}
50.01% {
opacity: 0;
}
100% {
opacity: 0;
}
}
.twinkle {
animation: blink 0.5s linear infinite;
}
</style>
|