From 5cf009d5ee7cd782a360848d5c2d7b71aec4d8af Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期三, 19 七月 2023 11:07:55 +0800
Subject: [PATCH] 1.接入signalR 消息推送功能

---
 src/layout/components/Navbar.vue |   49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index dc20d8c..41a17d2 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -64,6 +64,13 @@
           <el-tooltip class="item" effect="dark" content="鍏ㄥ睆" placement="bottom">
             <screenfull id="screenfull" class="right-menu-item hover-effect" />
           </el-tooltip>
+
+          <el-tooltip class="item" effect="dark" content="鎴戠殑娑堟伅" placement="bottom">
+            <el-badge :is-dot="$store.state.settings.isDot" class="item right-menu-item hover-effect">
+              <i class="el-icon-bell" @click="$message('鐐瑰嚮浜嗘垜鐨勬秷鎭紒');$store.state.settings.isDot=false" />
+            </el-badge>
+          </el-tooltip>
+
           <div style=" font-size: 18px;font-family: 'Microsoft YaHei';color:#AAAAAA;padding:0 8px;cursor: pointer">
             {{ stu_torgname }}
           </div>
@@ -98,12 +105,16 @@
             <el-dropdown-item @click.native="editPassword">
               <span style="display:block;">淇敼瀵嗙爜</span>
             </el-dropdown-item>
+            <el-dropdown-item divided @click.native="systemSetting">
+              <span style="display:block;">绯荤粺閰嶇疆</span>
+            </el-dropdown-item>
             <el-dropdown-item divided @click.native="logout">
               <span style="display:block;font-weight: bolder">閫�鍑�</span>
             </el-dropdown-item>
           </el-dropdown-menu>
         </el-dropdown>
       </div>
+
       <el-dialog
         v-el-drag-dialog
         title="淇敼瀵嗙爜"
@@ -136,6 +147,11 @@
       </el-dialog>
 
     </div>
+
+    <right-panel ref="rightPanel">
+      <settings />
+    </right-panel>
+
   </div>
 
 </template>
@@ -153,6 +169,8 @@
 import Search from '@/components/HeaderSearch'
 import Screenfull from '@/components/Screenfull'
 import variables from '@/styles/variables.scss'
+import RightPanel from '@/components/RightPanel'
+import Settings from '../components/Settings/index'
 
 export default {
   components: {
@@ -160,9 +178,12 @@
     Breadcrumb,
     Hamburger,
     Search,
-    Screenfull
+    Screenfull,
+    Settings,
+    RightPanel
   },
   directives: { elDragDialog },
+
   data() {
     const validatePassword1 = (rule, value, callback) => {
       if (!value) {
@@ -202,7 +223,8 @@
           { required: true, validator: validatePassword2, trigger: ['blur', 'change'] }
         ]
       },
-      stu_torgname: ''
+      stu_torgname: '',
+      show: false
     }
   },
   inject: [
@@ -212,6 +234,18 @@
     this.usercode = getCookie('navTabId')
     this.username = getCookie('username')
     this.stu_torgname = getCookie('stu_torgname') === '' ? '绯荤粺绠$悊鍛�' : getCookie('stu_torgname')
+  },
+  mounted() {
+    this.$signalr.off('SendAll')
+    this.$signalr.on('SendAll', (res) => {
+      this.$notify({
+        offset: 80,
+        type: 'warning',
+        title: '娑堟伅鎻愰啋',
+        message: res
+      })
+      this.$store.state.settings.isDot = true
+    })
   },
   computed: {
     ...mapGetters([
@@ -243,6 +277,10 @@
     }
   },
   methods: {
+    systemSetting() {
+      this.$refs.rightPanel.show = !this.$refs.rightPanel.show
+      this.$refs.rightPanel.addEventClick()
+    },
     pageRefreshClick() {
       this.reload()
       const tabViews = this.$store.state.tagsView.visitedViews.map(item => {
@@ -266,6 +304,7 @@
       this.$store.dispatch('app/toggleSideBar')
     },
     async logout() {
+      this.$signalr.off('SendAll')
       await this.$store.dispatch('user/logout')
       this.$message.success('閫�鍑烘垚鍔燂紒')
       this.$router.push(`/login`)
@@ -303,6 +342,12 @@
 }
 </script>
 <style lang="scss" scoped>
+::v-deep .el-badge__content {
+  position: absolute !important;
+  top: 12px !important;
+  right: 10px !important;
+}
+
 .display_btw {
   display: flex;
   justify-content: space-between;

--
Gitblit v1.9.3