Zt 2 years ago
parent
commit
ce78a3f339
2 changed files with 8 additions and 0 deletions
  1. 6 0
      chuanyi_client2/src/App.vue
  2. 2 0
      chuanyi_client2/src/views/login.vue

+ 6 - 0
chuanyi_client2/src/App.vue

@@ -11,6 +11,11 @@ import {showAlertWin} from "@/utils/cqcy";
 
 export default {
   name: 'App',
+  provide(){
+      return {
+        WebSocket:this
+      }
+  },
   metaInfo() {
     return {
       title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
@@ -31,6 +36,7 @@ export default {
   },
   methods: {
     initWebSocket() {
+      console.log('webSocket');
       let _this = this
       if (typeof (WebSocket) === 'undefined') {
         showAlertWin(_this, '您使用的环境暂不支持socket服务!')

+ 2 - 0
chuanyi_client2/src/views/login.vue

@@ -74,6 +74,7 @@ import {showAlertWin, showLoading, testHost} from '@/utils/cqcy'
 
 export default {
   name: "Login",
+  inject:['WebSocket'],
   data() {
     /** 表单验证判断:空格 */
     let testKeyBySpace = (rule, value, callback) => {
@@ -134,6 +135,7 @@ export default {
     }
   },
   created() {
+    this.WebSocket.initWebSocket()
     this.getCode();
     this.getCookie();
     this.applicationName = process.env.VUE_APP_SOFTWARENAME