Blame view

antis-ncc-admin/src/layout/components/NavbarRight.vue 16.5 KB
96009bc9   hexiaodong   hxd
1
2
3
4
5
6
  <template>
    <div class="right-menu">
      <template v-if="device!=='mobile'">
        <template v-if="showSearch">
          <search id="header-search" class="right-menu-item" />
        </template>
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
7
8
9
10
11
        <el-tooltip content="企业日历" placement="bottom">
          <div class="right-menu-item hover-effect" @click="openCompanyCalendar">
            <i class="el-icon-date"></i>
          </div>
        </el-tooltip>
96009bc9   hexiaodong   hxd
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
        <!-- <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>
a8965d32   “wangming”   ```
58
59
60
61
62
      <el-tooltip content="更新日志" placement="bottom">
        <div class="right-menu-item hover-effect" @click="openChangelog">
          <i class="el-icon-notebook-2"></i>
        </div>
      </el-tooltip>
96009bc9   hexiaodong   hxd
63
64
65
66
67
68
69
70
71
      <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>
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
72
            <img :src="aboutLogoSrc" class="about-logo" />
96009bc9   hexiaodong   hxd
73
74
          </div>
          <div>
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
75
            <p class="title">{{ displaySysName }}</p>
96009bc9   hexiaodong   hxd
76
77
78
79
80
81
82
83
84
85
            <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' />
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
86
      <CompanyCalendarDialog ref="CompanyCalendarDialog" />
a8965d32   “wangming”   ```
87
88
89
90
91
92
  
      <!-- 更新日志弹窗 -->
      <el-dialog
        title="系统更新日志"
        :visible.sync="changelogVisible"
        width="600px"
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
93
94
        append-to-body
        class="NCC-dialog changelog-dialog"
a8965d32   “wangming”   ```
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
      >
        <div v-loading="changelogLoading" class="changelog-list">
          <div v-if="changelogList.length === 0" class="empty-tip">暂无更新日志</div>
          <div v-for="item in changelogList" :key="item.id" class="changelog-item">
            <div class="changelog-item-header">
              <el-tag size="small" effect="plain">v{{ item.version }}</el-tag>
              <el-tag :type="getChangelogTypeTag(item.type)" size="small">
                {{ getChangelogTypeText(item.type) }}
              </el-tag>
              <span class="changelog-time">{{ formatDate(item.publishedTime) }}</span>
            </div>
            <h4 class="changelog-title">{{ item.title }}</h4>
            <div class="changelog-content">{{ item.content }}</div>
          </div>
        </div>
        <div v-if="changelogTotal > changelogList.length" class="changelog-more">
          <el-button type="text" @click="loadMoreChangelog">加载更多</el-button>
        </div>
      </el-dialog>
96009bc9   hexiaodong   hxd
114
115
116
117
118
119
120
121
122
123
124
125
    </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'
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
126
  import CompanyCalendarDialog from '@/components/CompanyCalendarDialog'
96009bc9   hexiaodong   hxd
127
128
  import dragDialog from "@/directive/el-drag-dialog";
  import ReconnectingWebSocket from 'reconnecting-websocket'
a8965d32   “wangming”   ```
129
  import { getPublishedList } from '@/api/extend/changelog'
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
130
  import { resolveBrandUrl, getDisplaySysName } from '@/utils/sys-brand'
96009bc9   hexiaodong   hxd
131
132
133
134
135
136
137
138
139
140
  
  export default {
    directives: { dragDialog },
    components: {
      Screenfull,
      SizeSelect,
      LangSelect,
      Search,
      MessageList,
      UserList,
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
141
142
      Settings,
      CompanyCalendarDialog
96009bc9   hexiaodong   hxd
143
144
145
146
147
148
149
    },
    computed: {
      ...mapState({
        showLanguage: state => state.settings.showLanguage,
        showSearch: state => state.settings.showSearch,
        showSettings: state => state.settings.showSettings,
      }),
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
150
151
152
153
154
155
156
157
158
      ...mapGetters(['device', 'userInfo', 'sysName', 'sysLogo', 'sysLogoIcon']),
      displaySysName() {
        return getDisplaySysName(this.sysName)
      },
      aboutLogoSrc() {
        const url = this.sysLogoIcon || this.sysLogo
        if (url) return resolveBrandUrl(url)
        return require('@/assets/images/ncc.png')
      }
96009bc9   hexiaodong   hxd
159
160
161
162
163
164
    },
    data() {
      return {
        visible: false,
        isTwinkle: false,
        messageCount: 0,
a8965d32   “wangming”   ```
165
166
167
168
169
170
        userList: [],
        changelogVisible: false,
        changelogLoading: false,
        changelogList: [],
        changelogTotal: 0,
        changelogPage: 1
96009bc9   hexiaodong   hxd
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
      }
    },
    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
a8965d32   “wangming”   ```
313
314
315
316
317
318
319
      },
      openChangelog() {
        this.changelogVisible = true
        this.changelogPage = 1
        this.changelogList = []
        this.loadChangelog()
      },
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
320
321
322
      openCompanyCalendar() {
        this.$refs.CompanyCalendarDialog && this.$refs.CompanyCalendarDialog.init()
      },
a8965d32   “wangming”   ```
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
      loadChangelog() {
        this.changelogLoading = true
        getPublishedList({ currentPage: this.changelogPage, pageSize: 10 }).then(res => {
          if (res.data && res.data.list) {
            this.changelogList = [...this.changelogList, ...res.data.list]
            this.changelogTotal = res.data.pagination.total
          }
          this.changelogLoading = false
        }).catch(() => {
          this.changelogLoading = false
        })
      },
      loadMoreChangelog() {
        this.changelogPage++
        this.loadChangelog()
      },
      getChangelogTypeText(type) {
        const map = { 1: '功能更新', 2: 'Bug修复', 3: '性能优化', 4: '安全更新' }
        return map[type] || '其他'
      },
      getChangelogTypeTag(type) {
        const map = { 1: 'primary', 2: 'danger', 3: 'success', 4: 'warning' }
        return map[type] || 'info'
      },
      formatDate(dateStr) {
        if (!dateStr) return ''
        const date = new Date(dateStr)
        if (isNaN(date.getTime())) return dateStr
        const y = date.getFullYear()
        const m = String(date.getMonth() + 1).padStart(2, '0')
        const d = String(date.getDate()).padStart(2, '0')
        return `${y}-${m}-${d}`
96009bc9   hexiaodong   hxd
355
356
357
358
359
360
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
  @import "~@/styles/variables.scss";
  
  .right-menu {
    display: flex;
    align-items: center;
    float: right;
    height: 100%;
    margin-left: auto;
    padding-right: $headerRightPadding;
    box-sizing: border-box;
    &:focus {
      outline: none;
    }
  
    // el-tooltip 外层 span 也参与 flex 垂直居中
    >>> .el-tooltip {
      display: inline-flex;
      align-items: center;
96009bc9   hexiaodong   hxd
379
      height: 100%;
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
380
    }
96009bc9   hexiaodong   hxd
381
  
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
382
383
384
385
386
387
388
389
390
391
    .right-menu-item {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #666666;
      line-height: 1;
      flex-shrink: 0;
96009bc9   hexiaodong   hxd
392
  
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
393
394
395
      &.hover-effect {
        cursor: pointer;
        transition: background 0.3s;
96009bc9   hexiaodong   hxd
396
  
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
397
398
        &:hover {
          background: rgba(0, 0, 0, 0.025);
96009bc9   hexiaodong   hxd
399
        }
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
400
401
402
403
404
      }
      >>> .el-badge {
        line-height: 1;
        .el-badge__content {
          top: -4px;
96009bc9   hexiaodong   hxd
405
406
        }
      }
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
407
408
409
410
411
412
413
      >>> .icon-ym {
        font-size: 18px;
      }
      .icon-ym {
        font-size: 20px;
      }
    }
96009bc9   hexiaodong   hxd
414
  
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
415
416
417
418
419
420
    .avatar-container {
      .avatar-wrapper {
        display: inline-flex;
        align-items: center;
        height: 100%;
        max-height: $headerHeight;
96009bc9   hexiaodong   hxd
421
  
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
422
423
424
425
426
427
        .user-avatar {
          cursor: pointer;
          margin: 0 6px 0 0;
          flex-shrink: 0;
          vertical-align: middle;
        }
96009bc9   hexiaodong   hxd
428
  
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
429
430
431
432
        span {
          font-size: 14px;
          line-height: 1;
        }
96009bc9   hexiaodong   hxd
433
  
4528226f   “wangming”   feat: 管理端暗黑焕肤与阿里云...
434
435
436
        .el-icon-arrow-down {
          margin-left: 4px;
          font-size: 12px;
96009bc9   hexiaodong   hxd
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
        }
      }
    }
  }
  .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;
  }
a8965d32   “wangming”   ```
490
491
492
  
  .changelog-dialog {
    .changelog-list {
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
493
      max-height: min(60vh, 520px);
a8965d32   “wangming”   ```
494
      overflow-y: auto;
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
495
      padding-right: 4px;
a8965d32   “wangming”   ```
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
    }
  
    .empty-tip {
      text-align: center;
      color: #909399;
      padding: 40px 0;
    }
  
    .changelog-item {
      padding: 16px 0;
      border-bottom: 1px solid #f0f0f0;
  
      &:last-child {
        border-bottom: none;
      }
  
      .changelog-item-header {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
  
        .changelog-time {
          margin-left: auto;
          color: #909399;
          font-size: 12px;
        }
      }
  
      .changelog-title {
        margin: 0 0 8px 0;
        font-size: 15px;
        color: #303133;
      }
  
      .changelog-content {
        color: #606266;
        font-size: 13px;
        line-height: 1.6;
        white-space: pre-wrap;
        background: #f5f7fa;
        padding: 12px;
        border-radius: 6px;
      }
    }
  
    .changelog-more {
      text-align: center;
      padding: 12px 0 0;
    }
  }
2c37ef74   “wangming”   feat: 发布 V2.0.1(事...
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
  </style>
  
  <style lang="scss">
  /* append-to-body:须挂 body.ncc-content-dark,压过 scoped 浅色字/底 */
  body.ncc-content-dark .changelog-dialog,
  .ncc-content-dark .changelog-dialog {
    .empty-tip {
      color: rgba(255, 255, 255, 0.65) !important;
    }
  
    .changelog-item {
      border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    }
  
    .changelog-time {
      color: rgba(255, 255, 255, 0.65) !important;
    }
  
    .changelog-title {
      color: rgba(255, 255, 255, 0.85) !important;
    }
  
    .changelog-content {
      color: rgba(255, 255, 255, 0.65) !important;
      background: rgba(255, 255, 255, 0.06) !important;
    }
  }
96009bc9   hexiaodong   hxd
574
  </style>