From 43f4fd08bb99f587c387391aad727fb82b34b7c1 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期五, 11 八月 2023 13:27:47 +0800
Subject: [PATCH] 1.存货类型页面优化

---
 src/layout/components/Navbar.vue |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index e504d48..04cd585 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>
@@ -164,6 +171,7 @@
 import variables from '@/styles/variables.scss'
 import RightPanel from '@/components/RightPanel'
 import Settings from '../components/Settings/index'
+import * as signalR from '@aspnet/signalr'
 
 export default {
   components: {
@@ -217,16 +225,21 @@
         ]
       },
       stu_torgname: '',
-      show: false
+      show: false,
+      signalr: null
     }
   },
   inject: [
     'reload'
   ],
   created() {
+    // this.$signalr.start()
     this.usercode = getCookie('navTabId')
     this.username = getCookie('username')
     this.stu_torgname = getCookie('stu_torgname') === '' ? '绯荤粺绠$悊鍛�' : getCookie('stu_torgname')
+  },
+  mounted() {
+    // this.getHubConnectionBuilder()
   },
   computed: {
     ...mapGetters([
@@ -258,6 +271,40 @@
     }
   },
   methods: {
+    // 寤虹珛hub杩炴帴
+    async getHubConnectionBuilder() {
+      const url = 'http://121.196.36.24:8019/chatHub'
+      this.signalr = new signalR.HubConnectionBuilder().withUrl(url, {
+        // skipNegotiation: true,
+        // transport: signalR.HttpTransportType.WebSockets
+      }).configureLogging(signalR.LogLevel.Information).build()
+
+      await this.signalr.start().then(() => {
+        if (window.Notification) {
+          if (Notification.permission === 'granted') {
+            console.log('鍏佽閫氱煡')
+          } else if (Notification.permission !== 'denied') {
+            console.log('闇�瑕侀�氱煡鏉冮檺')
+            Notification.requestPermission((permission) => {
+              console.log('鏉冮檺閫氱煡', permission)
+            })
+          } else if (Notification.permission === 'denied') {
+            // console.log('鎷掔粷閫氱煡')
+          }
+        } else {
+          console.error('娴忚鍣ㄤ笉鏀寔Notification')
+        }
+        // console.log('杩炴帴鎴愬姛')
+      })
+
+      this.signalr.off('SendCustomUserMessage')
+      this.signalr.on('SendCustomUserMessage', (res) => {
+        this.$notify({ offset: 80, type: 'warning', title: '娑堟伅鎻愰啋', message: res })
+        this.$store.state.settings.isDot = true
+      })
+      await this.signalr.invoke('AddUser', getCookie('admin'))
+    },
+
     systemSetting() {
       this.$refs.rightPanel.show = !this.$refs.rightPanel.show
       this.$refs.rightPanel.addEventClick()
@@ -285,6 +332,8 @@
       this.$store.dispatch('app/toggleSideBar')
     },
     async logout() {
+      // await this.signalr.stop()
+      // this.signalr.off('SendCustomUserMessage')
       await this.$store.dispatch('user/logout')
       this.$message.success('閫�鍑烘垚鍔燂紒')
       this.$router.push(`/login`)
@@ -322,6 +371,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