修复loading未正确关闭,删除菜单
This commit is contained in:
parent
468dc3b5b1
commit
5d111c8642
|
|
@ -1,26 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<div style="padding: 10px; margin-bottom: 50px">
|
<div style="padding: 10px; margin-bottom: 50px">
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="mini"
|
|
||||||
@click.prevent="handleMenuSelect('/videoList')"
|
|
||||||
>视频列表</el-button
|
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="mini"
|
|
||||||
@click.prevent="handleMenuSelect('/device')"
|
|
||||||
>设备管理</el-button
|
|
||||||
>
|
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click.prevent="handleMenuSelect('/User')"
|
@click.prevent="handleMenuSelect('/User')"
|
||||||
>用户</el-button
|
>用户</el-button
|
||||||
>
|
>
|
||||||
<el-row
|
<el-row v-loading="loading" element-loading-text="正在连接....">
|
||||||
v-loading="loading"
|
|
||||||
element-loading-text="正在连接....">
|
|
||||||
<el-col :span="16">
|
<el-col :span="16">
|
||||||
<div
|
<div
|
||||||
style="
|
style="
|
||||||
|
|
@ -69,7 +55,7 @@ import router from "@/router/index.js";
|
||||||
import * as crypto from "crypto";
|
import * as crypto from "crypto";
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
import { ElLoading } from "element-plus";
|
import { ElLoading } from "element-plus";
|
||||||
import Cookies from 'js-cookie';
|
import Cookies from "js-cookie";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -296,9 +282,9 @@ export default {
|
||||||
// 连接WebSocket
|
// 连接WebSocket
|
||||||
let _this = this;
|
let _this = this;
|
||||||
if (typeof WebSocket == "undefined") {
|
if (typeof WebSocket == "undefined") {
|
||||||
console.log("您的浏览器不支持WebSocket");
|
console.log("浏览器不支持WebSocket");
|
||||||
} else {
|
} else {
|
||||||
console.log("您的浏览器支持WebSocket");
|
console.log("浏览器支持WebSocket");
|
||||||
let socketUrl =
|
let socketUrl =
|
||||||
"wss://gep.ljsea.top/im/ws?to_user_id=" +
|
"wss://gep.ljsea.top/im/ws?to_user_id=" +
|
||||||
this.to_user_id +
|
this.to_user_id +
|
||||||
|
|
@ -314,8 +300,8 @@ export default {
|
||||||
this.socket = new WebSocket(socketUrl);
|
this.socket = new WebSocket(socketUrl);
|
||||||
//打开事件
|
//打开事件
|
||||||
this.socket.onopen = function () {
|
this.socket.onopen = function () {
|
||||||
confirm("连接成功");
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
confirm("连接成功");
|
||||||
};
|
};
|
||||||
this.socket.onerror = (error) => {
|
this.socket.onerror = (error) => {
|
||||||
console.error("WebSocket Error:", error);
|
console.error("WebSocket Error:", error);
|
||||||
|
|
@ -329,16 +315,18 @@ export default {
|
||||||
this.socket.onmessage = async function (msg) {
|
this.socket.onmessage = async function (msg) {
|
||||||
//console.log("收到数据====" + msg.data);
|
//console.log("收到数据====" + msg.data);
|
||||||
let data = JSON.parse(msg.data); // 对收到的json数据进行解析, 类似这样的:
|
let data = JSON.parse(msg.data); // 对收到的json数据进行解析, 类似这样的:
|
||||||
// 如果服务器端发送过来的json数据 不包含 users 这个key,那么发送过来的就是聊天文本json数据
|
// 如果服务器端发送过来的json数据
|
||||||
data.data = await _this.decryptAES(
|
if (data.type == "msg") { // 如果是消息类型,解密消息内容
|
||||||
data.data,
|
data.data = await _this.decryptAES(
|
||||||
_this.imKey,
|
data.data,
|
||||||
_this.imKey
|
_this.imKey,
|
||||||
);
|
_this.imKey
|
||||||
_this.messages.push(data);
|
);
|
||||||
//console.log("收到数据====" + msg.data);
|
_this.messages.push(data);
|
||||||
// 构建消息内容
|
//console.log("收到数据====" + msg.data);
|
||||||
_this.createContent(_this.to_user_name, null, data.data);
|
// 构建消息内容
|
||||||
|
_this.createContent(_this.to_user_name, null, data.data);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -350,7 +338,10 @@ export default {
|
||||||
this.chatUser = this.to_user_name;
|
this.chatUser = this.to_user_name;
|
||||||
//console.log("to_user_id:", this.to_user_id, this.to_user_name);
|
//console.log("to_user_id:", this.to_user_id, this.to_user_name);
|
||||||
this.startInterval();
|
this.startInterval();
|
||||||
//this.connectWebSocket();
|
|
||||||
|
setTimeout(() => this.loading=false, 3000);
|
||||||
|
|
||||||
|
//this.connectWebSocket();
|
||||||
},
|
},
|
||||||
// 生命周期钩子,在组件卸载之前被调用
|
// 生命周期钩子,在组件卸载之前被调用
|
||||||
onUnmounted() {
|
onUnmounted() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue