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/views/purchasesManager/goodsStatisticsList.vue |  123 +++++++++++++++++++++++++++-------------
 1 files changed, 83 insertions(+), 40 deletions(-)

diff --git a/src/views/purchasesManager/goodsStatisticsList.vue b/src/views/purchasesManager/goodsStatisticsList.vue
index d89f627..8cd0464 100644
--- a/src/views/purchasesManager/goodsStatisticsList.vue
+++ b/src/views/purchasesManager/goodsStatisticsList.vue
@@ -1,41 +1,84 @@
-<template>
-  <div id="app">
-    <div class="box">
-      <el-input v-model="input" placeholder class="inp" />
-      <el-button type="primary" @click="showDialog">鐢熸垚 cron</el-button>
-    </div>
-    <el-dialog title="鐢熸垚 cron" :visible.sync="showCron">
-      <vcrontab :expression="expression" @hide="showCron=false" @fill="crontabFill" />
-    </el-dialog>
-  </div>
-</template>
-<script>
-import vcrontab from 'vcrontab'
+<!--<template>-->
+<!--  <div class="home">-->
+<!--    <h1>鍓嶇婕旂ずSignalR</h1>-->
+<!--    <input v-model="user" type="text">-->
+<!--    <input v-model="message" type="text">-->
+<!--    <button @click="sendAll">鍙戦�佸叏閮�</button>-->
+<!--    <button @click="sendOwn">瀵硅嚜宸卞彂閫�</button>-->
+<!--    <button @click="sendOther">瀵瑰叾浠栧彂閫�</button>-->
+<!--    <div>-->
+<!--      <ul v-for="(item, index) in messages" :key="index + 'itemMessage'">-->
+<!--        <li>{{ item.user }} says {{ item.message }}</li>-->
+<!--      </ul>-->
+<!--    </div>-->
+<!--  </div>-->
+<!--</template>-->
 
-export default {
-  components: { vcrontab },
-  data() {
-    return {
-      input: '',
-      expression: '',
-      showCron: false,
-      cronExpression: '*/1 * * * *',
-      form: {},
-      formLabelWidth: '120px'
-      // showCron: false
-    }
-  },
-  methods: {
-    crontabFill(value) {
-      // 纭畾鍚庡洖浼犵殑鍊�
-      this.input = value
-    },
-    showDialog() {
-      this.expression = this.input
-      // 浼犲叆鐨� cron 琛ㄨ揪寮忥紝鍙互鍙嶈В鏋愬埌 UI 涓�
-      this.showCron = true
-    }
-  }
-}
-</script>
-}
+<!--<script>-->
+<!--// @ is an alias to /src-->
+<!--import * as signalR from '@aspnet/signalr'-->
+<!--export default {-->
+<!--  name: 'Home',-->
+<!--  components: {},-->
+<!--  data() {-->
+<!--    return {-->
+<!--      user: 's2', // 鐢ㄦ埛-->
+<!--      message: '22222', // 娑堟伅-->
+<!--      connection: '', // signalr杩炴帴-->
+<!--      messages: [] // 杩斿洖娑堟伅-->
+<!--    }-->
+<!--  },-->
+<!--  created: function() {-->
+<!--    const thisVue = this-->
+<!--    this.connection = new signalR.HubConnectionBuilder()-->
+<!--      .withUrl('http://121.196.36.24:8019/chatHub', {-->
+<!--        // skipNegotiation: true,-->
+<!--        // transport: signalR.HttpTransportType.WebSockets-->
+<!--      })-->
+<!--      .configureLogging(signalR.LogLevel.Information)-->
+<!--      .build()-->
+
+<!--    console.log(this.connection, 1)-->
+
+<!--    this.connection.on('ReceiveMessage', function(user, message) {-->
+<!--      debugger-->
+<!--      thisVue.messages.push({ user, message })-->
+<!--      console.log({ user, message })-->
+<!--    })-->
+<!--    this.connection.on('ReceiveCaller', function(message) {-->
+<!--      debugger-->
+<!--      const user = '鑷繁' // 杩欓噷涓轰簡push涓嶆姤閿欙紝鎴戝氨寮勪簡涓�涓粯璁ゅ�笺��-->
+<!--      thisVue.messages.push({ user, message })-->
+<!--      console.log({ user, message })-->
+<!--    })-->
+<!--    this.connection.start()-->
+<!--  },-->
+<!--  methods: {-->
+<!--    // 缁欏叏閮ㄥ彂閫佹秷鎭�-->
+<!--    sendAll: function() {-->
+<!--      this.connection-->
+<!--        .invoke('SendMessage', this.user, this.message)-->
+<!--        .catch(function(err) {-->
+<!--          return console.error(err)-->
+<!--        })-->
+<!--    },-->
+<!--    // 鍙粰鑷繁鍙戦�佹秷鎭�-->
+<!--    sendOwn: function() {-->
+<!--      this.connection-->
+<!--        .invoke('SendMessageCaller', this.message)-->
+<!--        .catch(function(err) {-->
+<!--          return console.error(err)-->
+<!--        })-->
+<!--    },-->
+
+<!--    // 缁欏叾浠栦汉鍛樺彂閫佹秷鎭�-->
+<!--    sendOther: function() {-->
+<!--      this.connection-->
+<!--        .invoke('SendMessageOther', this.user, this.message)-->
+<!--        .catch(function(err) {-->
+<!--          return console.error(err)-->
+<!--        })-->
+<!--    }-->
+<!--  }-->
+<!--}-->
+<!--</script>-->

--
Gitblit v1.9.3