From c552cbab2c613c7814cf02384c3b087e1d167f47 Mon Sep 17 00:00:00 2001
From: whycq <913841844@qq.com>
Date: 星期二, 06 二月 2024 10:22:51 +0800
Subject: [PATCH] #
---
Monitor-APP/pages.json | 12 +++++
Monitor-APP/pages/webSocket.vue | 58 +++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/Monitor-APP/pages.json b/Monitor-APP/pages.json
index 54a5551..12055ed 100644
--- a/Monitor-APP/pages.json
+++ b/Monitor-APP/pages.json
@@ -1,6 +1,15 @@
{
"pages": [ //pages鏁扮粍涓涓�椤硅〃绀哄簲鐢ㄥ惎鍔ㄩ〉锛屽弬鑰冿細https://uniapp.dcloud.io/collocation/pages
{
+ "path" : "pages/webSocket",
+ "style" :
+ {
+ "navigationBarTitleText": "webSocket",
+ "enablePullDownRefresh": false
+ }
+
+ },
+ {
"path": "pages/home/home",
"style": {
"navigationStyle": "custom",
@@ -58,7 +67,8 @@
}
- ],
+
+ ],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
diff --git a/Monitor-APP/pages/webSocket.vue b/Monitor-APP/pages/webSocket.vue
new file mode 100644
index 0000000..582962c
--- /dev/null
+++ b/Monitor-APP/pages/webSocket.vue
@@ -0,0 +1,58 @@
+<template>
+ <view>
+
+ </view>
+</template>
+
+<script>
+ export default {
+ data() {
+ return {
+ ws: null,
+ }
+ },
+ onShow() {
+ this.init()
+ },
+ methods: {
+ init() {
+ this.ws = new WebSocket("ws://127.0.0.1:9090/pswcs/console/websocket")
+ this.ws.onopen = this.webSocketOnOpen
+ this.ws.onerror = this.webSocketOnError
+ this.ws.onmessage = this.webSocketOnMessage
+ this.ws.onclose = this.webSocketClose
+ // console.log(this.ws)
+
+ },
+ webSocketOnOpen(e) {
+ console.log("open");
+
+ this.sendWs(JSON.stringify({
+ url: 'getTvConfig',
+ data: '1'
+ }))
+ },
+ webSocketOnError(e) {
+ console.log(e);
+ },
+ webSocketOnMessage(e) {
+ const result = JSON.parse(e.data);
+ if (result.url == "getTvConfig") {
+ console.log(result.result)
+ }
+ },
+ webSocketClose(e) {
+ console.log("close");
+ },
+ sendWs(message) {
+ if (this.ws.readyState == WebSocket.OPEN) {
+ this.ws.send(message)
+ }
+ }
+ }
+ }
+</script>
+
+<style>
+
+</style>
--
Gitblit v1.9.1