Browse Source

Merge branch 'magicwu_webSocket' into leng_dev

# Conflicts:
#	package.json
冷冷 6 năm trước cách đây
mục cha
commit
e5e0bc45f5
4 tập tin đã thay đổi với 75 bổ sung7 xóa
  1. 21 3
      package.json
  2. 1 1
      src/config/env.js
  3. 52 2
      src/page/index/index.vue
  4. 1 1
      src/views/admin/menu/index.vue

+ 21 - 3
package.json

@@ -1,33 +1,51 @@
 {
   "name": "pigx-ui",
-  "version": "2.1.0",
+  "version": "1.8.0",
   "private": true,
   "scripts": {
     "pre": "yarn --registry https://registry.npm.taobao.org || npm install --registry https://registry.npm.taobao.org ",
     "dev": "vue-cli-service serve",
     "build": "vue-cli-service build",
-    "lint": "vue-cli-service lint"
+    "lint": "vue-cli-service lint",
+    "test:unit": "vue-cli-service test:unit"
   },
   "dependencies": {
     "@smallwei/avue": "^1.5.0",
+    "avue-plugin-transfer": "^0.0.2",
+    "avue-plugin-ueditor": "^0.0.1",
     "axios": "^0.18.0",
+    "babel-loader": "^8.0.2",
+    "babel-plugin-transform-runtime": "^6.23.0",
     "babel-polyfill": "^6.26.0",
     "classlist-polyfill": "^1.2.0",
+    "driver.js": "^0.6.2",
     "element-ui": "^2.4.11",
+    "file-saver": "^1.3.8",
+    "html2canvas": "^1.0.0-alpha.12",
     "js-cookie": "^2.2.0",
+    "moment": "^2.22.2",
+    "net": "^1.0.2",
     "nprogress": "^0.2.0",
     "script-loader": "^0.7.2",
+    "sockjs-client": "^1.3.0",
+    "stompjs": "^2.3.3",
     "vue": "^2.5.16",
     "vue-axios": "^2.1.2",
+    "vue-clipboard2": "^0.2.1",
     "vue-json-editor": "^1.2.3",
     "vue-json-tree-view": "^2.1.4",
+    "vue-quill-editor": "^3.0.6",
     "vue-router": "^3.0.2",
-    "vuex": "^3.0.1"
+    "vuedraggable": "^2.17.0",
+    "vuex": "^3.0.1",
+    "xlsx": "^0.13.3"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "^3.1.1",
     "@vue/cli-plugin-eslint": "^3.1.5",
+    "@vue/cli-plugin-unit-mocha": "^3.1.1",
     "@vue/cli-service": "^3.1.4",
+    "@vue/test-utils": "^1.0.0-beta.26",
     "chai": "^4.1.2",
     "node-sass": "^4.9.0",
     "sass-loader": "^7.0.1",

+ 1 - 1
src/config/env.js

@@ -3,7 +3,7 @@
 const env = process.env
 let baseUrl = ''
 // 图表库为avue和pig2套地址
-let iconfontVersion = ['667895_4y8d30c1og', '567566_qo5lxgtishg']
+let iconfontVersion = ['667895_4y8d30c1og', '667895_vf6hgm08ubf']
 let iconfontUrl = `//at.alicdn.com/t/font_$key.css`
 let codeUrl = `/code`
 let actUrl = `${window.location.origin}/act/modeler.html?modelId=`

+ 52 - 2
src/page/index/index.vue

@@ -40,6 +40,9 @@
   import {validatenull} from '@/util/validate';
   import {calcDate} from '@/util/date.js';
   import {getStore} from '@/util/store.js';
+  import SockJS from 'sockjs-client';
+  import Stomp from 'stompjs';
+  import store from "@/store";
 
   export default {
     components: {
@@ -64,11 +67,13 @@
       console.log("销毁")
       console.log(this.refreshTime)
       clearInterval(this.refreshTime)
+      this.disconnect()
     },
     mounted() {
       this.init()
+      this.initWebSocket()
     },
-    computed: mapGetters(['isLock', 'isCollapse', 'website', 'expires_in']),
+    computed: mapGetters(['userInfo', 'isLock', 'isCollapse', 'website', 'expires_in']),
     props: [],
     methods: {
       showCollapse() {
@@ -104,9 +109,54 @@
               });
             this.refreshLock = false
           }
-          this.$store.commit("SET_EXPIRES_IN",this.expires_in - 10);
+          this.$store.commit("SET_EXPIRES_IN", this.expires_in - 10);
         }, 10000);
       },
+      initWebSocket() {
+        this.connection();
+        let self = this;
+        //断开重连机制,尝试发送消息,捕获异常发生时重连
+        this.timer = setInterval(() => {
+          try {
+            self.stompClient.send("test");
+          } catch (err) {
+            console.log("断线了: " + err);
+            self.connection();
+          }
+        }, 5000);
+      },
+      connection() {
+        let token = store.getters.access_token
+        let TENANT_ID = getStore({name: 'tenantId'})
+        let headers = {
+          'Authorization': 'Bearer ' + token
+        }
+        // 建立连接对象
+        this.socket = new SockJS('/act/ws');//连接服务端提供的通信接口,连接以后才可以订阅广播消息和个人消息
+        // 获取STOMP子协议的客户端对象
+        this.stompClient = Stomp.over(this.socket);
+
+        // 向服务器发起websocket连接
+        this.stompClient.connect(headers, () => {
+          this.stompClient.subscribe('/task/' + this.userInfo.username + "-" + TENANT_ID + '/remind', (msg) => { // 订阅服务端提供的某个topic;
+            this.$notify({
+              title: "协同提醒",
+              type: 'warning',
+              dangerouslyUseHTMLString: true,
+              message: msg.body + '任务,请及时处理',
+              offset: 60
+            });
+          });
+        }, (err) => {
+
+        });
+      },
+      disconnect() {
+        if (this.stompClient != null) {
+          this.stompClient.disconnect();
+          console.log("Disconnected");
+        }
+      }
     }
   }
 </script>

+ 1 - 1
src/views/admin/menu/index.vue

@@ -69,7 +69,7 @@
               <el-form-item label="节点ID"
                             prop="menuId">
                 <el-input v-model="form.menuId"
-                          :disabled="formEdit"
+                          :disabled="formEdit || form.menuId"
                           placeholder="请输入节点ID"></el-input>
               </el-form-item>
               <el-form-item label="标题"