From ff0cce8e16a9fd66e621433d8a1db15cd4ef2837 Mon Sep 17 00:00:00 2001 From: jmal Date: Sat, 4 Jul 2020 15:20:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0websocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 1 + .env.production | 1 + .env.staging | 1 + package.json | 1 + src/components/ShowFile/ShowFile.vue | 15 +- src/components/preview/SimTextPreview.vue | 54 ++- src/layout/index.vue | 8 + src/websocket/sockJS.js | 50 +++ src/websocket/stomp-index.js | 6 + src/websocket/stomp-node.js | 108 +++++ src/websocket/stomp.js | 488 ++++++++++++++++++++++ src/websocket/websocket_config.js | 11 + 12 files changed, 727 insertions(+), 17 deletions(-) create mode 100644 src/websocket/sockJS.js create mode 100644 src/websocket/stomp-index.js create mode 100644 src/websocket/stomp-node.js create mode 100644 src/websocket/stomp.js create mode 100644 src/websocket/websocket_config.js diff --git a/.env.development b/.env.development index d7eb731..d4a7081 100644 --- a/.env.development +++ b/.env.development @@ -2,6 +2,7 @@ ENV = 'development' # base api +VUE_APP_WEBSOCKET = 'http://localhost:8088' VUE_APP_BASE_API = '/api' VUE_APP_BASE_FILE_API = '/file' VUE_APP_BASE_PRIVIEW_API = '/priview' diff --git a/.env.production b/.env.production index fe53a1d..d1d8129 100644 --- a/.env.production +++ b/.env.production @@ -2,6 +2,7 @@ ENV = 'production' # base api +VUE_APP_WEBSOCKET = 'http://www.jmal.cloud:8088' VUE_APP_BASE_API = '/api' VUE_APP_BASE_FILE_API = '/file' VUE_APP_BASE_PRIVIEW_API = '/priview' diff --git a/.env.staging b/.env.staging index 21aecf0..2e027b1 100644 --- a/.env.staging +++ b/.env.staging @@ -4,6 +4,7 @@ NODE_ENV = production ENV = 'staging' # base api +VUE_APP_WEBSOCKET = 'http://localhost:8088' VUE_APP_BASE_API = '/api' VUE_APP_BASE_FILE_API = '/file' VUE_APP_BASE_PRIVIEW_API = '/priview' diff --git a/package.json b/package.json index 1750ed4..44af237 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "scriptjs": "^2.5.9", "sortablejs": "^1.10.2", "spark-md5": "^3.0.0", + "stompjs": "^2.3.3", "v-contextmenu": "^2.9.0", "v-viewer": "^1.5.1", "vant": "2.5.0", diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 9d90dcd..5208315 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -447,8 +447,10 @@ import '@/utils/directives.js' import 'pl-table/themes/index.css'; - // import 'pl-table/themes/plTableStyle.css'; import { PlTable, PlTableColumn } from 'pl-table'; + + // import ws from '@/websocket/websocket_config'; + var rowStyleExecuting = false export default { name: 'ShowFile', @@ -762,6 +764,9 @@ // 画矩形选区 this.darwRectangle() + + // 监听websocket + this.onmessage() }, destroyed() { window.removeEventListener('popstate', this.goBack, false); @@ -799,6 +804,14 @@ } }, methods: { + onmessage(){ + // if(ws.isConnected){ + // // 订阅系统数据 + // this.stompClient = ws.stompClient.subscribe('/topic/updateData', (msg) => { + // console.log('/topic/updateData',msg) + // },ws.headers); + // } + }, load () { this.getFileList(true) }, diff --git a/src/components/preview/SimTextPreview.vue b/src/components/preview/SimTextPreview.vue index 94f7c65..12d379c 100644 --- a/src/components/preview/SimTextPreview.vue +++ b/src/components/preview/SimTextPreview.vue @@ -15,7 +15,7 @@
{{file.name}}
- 保存所有 + 保存所有