修复loading未正确关闭,删除菜单

This commit is contained in:
junleea 2024-07-03 11:08:10 +08:00
parent 468dc3b5b1
commit 5d111c8642
1 changed files with 21 additions and 30 deletions

View File

@ -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,7 +315,8 @@ 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 keyjson // json
if (data.type == "msg") { //
data.data = await _this.decryptAES( data.data = await _this.decryptAES(
data.data, data.data,
_this.imKey, _this.imKey,
@ -339,6 +326,7 @@ export default {
//console.log("====" + msg.data); //console.log("====" + msg.data);
// //
_this.createContent(_this.to_user_name, null, data.data); _this.createContent(_this.to_user_name, null, data.data);
}
}; };
} }
}, },
@ -350,6 +338,9 @@ 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();
setTimeout(() => this.loading=false, 3000);
//this.connectWebSocket(); //this.connectWebSocket();
}, },
// , // ,