From 36bf0cd8b3617433be17edae192ce1044e2d0903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=9C=E6=96=B9=E6=98=9F=E7=97=95?= Date: Fri, 9 Oct 2020 21:37:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=AD=A3=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- previewer/src/views/Home.vue | 47 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/previewer/src/views/Home.vue b/previewer/src/views/Home.vue index b329c78..a1394cf 100644 --- a/previewer/src/views/Home.vue +++ b/previewer/src/views/Home.vue @@ -2,7 +2,12 @@
- + {{ icons.mdiMenu }}
@@ -45,23 +50,46 @@ export default { snackbar: false, // show tips tips: null, // tips message screen: null, // screen + point: { + x: 0, + y: 0 + }, + isMouseDown: false, icons: { // icons mdiMenu } } }, methods: { + mouseDown: function () { + this.isMouseDown = true + this.ws.send(JSON.stringify({ + version: '1.0.0', + name: 'previewer', + command: 'MousePress' + })) + }, move: function (e) { - console.log(`(${e.layerX}, ${e.layerY})`) + if (!this.isMouseDown) { + return + } + this.point = { + x: e.layerX, + y: e.layerY + } + this.ws.send(JSON.stringify({ + version: '1.0.0', + name: 'previewer', + command: 'MouseMove', + args: this.point + })) }, - click: function (e) { + mouseUp: function () { + this.isMouseDown = false this.ws.send(JSON.stringify({ + version: '1.0.0', name: 'previewer', - command: 'click', - args: { - x: e.layerX, - y: e.layerY - } + command: 'MouseRelease' })) }, showTips: function (msg) { @@ -107,6 +135,7 @@ export default { }, updateProperties: function (values) { this.ws.send(JSON.stringify({ + version: '1.0.0', name: 'previewer', command: 'updateProperties', args: values @@ -139,7 +168,7 @@ export default { } uri += '//' + loc.host this.url = uri - // this.url = 'ws://localhost:4096' + this.url = 'ws://localhost:4096/' }, mounted () { // connect websocket -- Gitee