|
@@ -0,0 +1,64 @@
|
|
|
+<template>
|
|
|
+ <div v-show="modelValue" class="body">
|
|
|
+ <div class="item" @click="sendMessage">消息记录</div>
|
|
|
+ <el-scrollbar class="itemScrollbar">
|
|
|
+ <div class="item" v-for="item in 12"></div>
|
|
|
+ </el-scrollbar>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+const porps = defineProps({
|
|
|
+ modelValue: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+});
|
|
|
+const messages = ref([]);
|
|
|
+const ws = new WebSocket(
|
|
|
+ `ws://192.168.101.4:8079/websocket/${localStorage.getItem("token")}`
|
|
|
+);
|
|
|
+const sendMessage = () => {
|
|
|
+ if (ws.readyState === WebSocket.OPEN) {
|
|
|
+ ws.send("确认啊啊啊啊");
|
|
|
+ } else {
|
|
|
+ console.error("WebSocket is not open");
|
|
|
+ }
|
|
|
+};
|
|
|
+ws.onopen = () => {
|
|
|
+ console.log("实时已连接");
|
|
|
+};
|
|
|
+ws.onmessage = (event) => {
|
|
|
+ const receivedMessage = event.data;
|
|
|
+ console.log("Received message:", receivedMessage);
|
|
|
+ messages.value.push(receivedMessage);
|
|
|
+};
|
|
|
+ws.onclose = () => {
|
|
|
+ console.log("实时连接断开");
|
|
|
+};
|
|
|
+const emits = defineEmits(["update:modelValue"]);
|
|
|
+</script>
|
|
|
+<style scoped lang="scss">
|
|
|
+.body {
|
|
|
+ width: 260px;
|
|
|
+ height: 40vh;
|
|
|
+ position: fixed;
|
|
|
+ right: 20px;
|
|
|
+ top: 80px;
|
|
|
+ z-index: 3;
|
|
|
+ background-color: red;
|
|
|
+ border-radius: 16px;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .itemScrollbar {
|
|
|
+ height: calc(100% - 80px);
|
|
|
+ }
|
|
|
+
|
|
|
+ .item {
|
|
|
+ width: 100%;
|
|
|
+ height: 60px;
|
|
|
+ background-color: aqua;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|