2023-11-26版本
This commit is contained in:
parent
cd0091292e
commit
2afcad01e6
|
@ -215,6 +215,7 @@ export default {
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
if (response.data.responseStr !== "No") {
|
if (response.data.responseStr !== "No") {
|
||||||
that.$store.commit("setToken", response.data.responseStr);
|
that.$store.commit("setToken", response.data.responseStr);
|
||||||
|
localStorage.setItem("nickname", that.loginForm.account);
|
||||||
that.$router.push({ path: "/home" });
|
that.$router.push({ path: "/home" });
|
||||||
} else {
|
} else {
|
||||||
that.$message.error('账号或密码错误');
|
that.$message.error('账号或密码错误');
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<div v-for="(message, index) in messageList" :key="index">
|
<div v-for="(message, index) in messageList" :key="index">
|
||||||
|
|
||||||
|
|
||||||
<div class="word" v-if="!(message.nickname == 'COOL')">
|
<div class="word" v-if="!(message.nickname == myName)">
|
||||||
<div class="information">
|
<div class="information">
|
||||||
<p>{{ message.nickname }} {{ message.sendTime }}</p>
|
<p>{{ message.nickname }} {{ message.sendTime }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -68,26 +68,45 @@ export default {
|
||||||
textarea: "",
|
textarea: "",
|
||||||
myName: '',
|
myName: '',
|
||||||
myPic: '',
|
myPic: '',
|
||||||
|
dateNow: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
var container = document.getElementById('chat');
|
var container = document.getElementById('chat');
|
||||||
container.scrollTop = container.scrollHeight;
|
container.scrollTop = container.scrollHeight;
|
||||||
this.init()
|
this.init();
|
||||||
|
this.myName = localStorage.getItem("nickname");
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getDate(){
|
||||||
|
var date = new Date();
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||||
|
var day = date.getDate().toString().padStart(2, '0');
|
||||||
|
var hour =date.getHours().toString().padStart(2, '0');
|
||||||
|
var minute = date.getMinutes().toString().padStart(2, '0');
|
||||||
|
var second = date.getSeconds().toString().padStart(2, '0');
|
||||||
|
this.dateNow = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second;
|
||||||
|
},
|
||||||
|
|
||||||
send() {
|
send() {
|
||||||
if (!this.textarea) {
|
if (!this.textarea) {
|
||||||
this.$message({ type: 'warning', message: "请输入内容" })
|
this.$message({ type: 'warning', message: "请输入内容" })
|
||||||
} else {
|
} else {
|
||||||
|
this.getDate()
|
||||||
let SendMessage = {
|
let SendMessage = {
|
||||||
nickname: 'COOL',
|
nickname: this.myName,
|
||||||
pic: "1",
|
pic: "1",
|
||||||
sendTime: '2023/11/20 18:23:18',
|
sendTime: this.dateNow,
|
||||||
message: this.textarea,
|
message: this.textarea,
|
||||||
}
|
}
|
||||||
|
this.messageList.push(SendMessage)
|
||||||
|
this.$nextTick(function () {
|
||||||
|
var container = document.getElementById('chat');
|
||||||
|
container.scrollTop = container.scrollHeight;
|
||||||
|
});
|
||||||
socket.send(JSON.stringify(SendMessage));
|
socket.send(JSON.stringify(SendMessage));
|
||||||
|
|
||||||
this.textarea = "";
|
this.textarea = "";
|
||||||
console.log(this.messageList, "这是send")
|
console.log(this.messageList, "这是send")
|
||||||
}
|
}
|
||||||
|
@ -114,7 +133,10 @@ export default {
|
||||||
that.messageList = data
|
that.messageList = data
|
||||||
console.log(that.messageList[1].message, "nickname")
|
console.log(that.messageList[1].message, "nickname")
|
||||||
console.log(that.messageList, 2)
|
console.log(that.messageList, 2)
|
||||||
|
that.$nextTick(function () {
|
||||||
|
var container = document.getElementById('chat');
|
||||||
|
container.scrollTop = container.scrollHeight;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.onerror = function () {
|
socket.onerror = function () {
|
||||||
|
@ -126,11 +148,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
SendMessage(textarea) {
|
|
||||||
//发送消息
|
|
||||||
console.log(textarea);
|
|
||||||
},
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -223,7 +240,6 @@ export default {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.outer {
|
.outer {
|
||||||
|
|
||||||
.information {
|
.information {
|
||||||
|
@ -297,7 +313,6 @@ export default {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
color: rgb(32, 179, 86);
|
color: rgb(32, 179, 86);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<i class="el-icon-caret-bottom" style="font-size: 20px;color:aliceblue;"></i>
|
<i class="el-icon-caret-bottom" style="font-size: 20px;color:aliceblue;"></i>
|
||||||
</div>
|
</div>
|
||||||
<el-dropdown-menu slot="dropdown" class="dropdownMenu">
|
<el-dropdown-menu slot="dropdown" class="dropdownMenu">
|
||||||
<p style="color: aliceblue; font-size: 14px;text-align: center;">已登录用户Cool</p>
|
<p style="color: aliceblue; font-size: 14px;text-align: center;">已登录用户{{ myName }}</p>
|
||||||
<hr style="border:none;height:1px;background-color: rgb(82, 87, 103);">
|
<hr style="border:none;height:1px;background-color: rgb(82, 87, 103);">
|
||||||
<el-dropdown-item icon="el-icon-user-solid" command="a" class="item">个人信息</el-dropdown-item>
|
<el-dropdown-item icon="el-icon-user-solid" command="a" class="item">个人信息</el-dropdown-item>
|
||||||
<el-dropdown-item icon="el-icon-chat-dot-round" command="b" class="item">消息通知</el-dropdown-item>
|
<el-dropdown-item icon="el-icon-chat-dot-round" command="b" class="item">消息通知</el-dropdown-item>
|
||||||
|
@ -50,9 +50,13 @@
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
myName: "",
|
||||||
headPic: require("@/assets/img/cool.jpg"),
|
headPic: require("@/assets/img/cool.jpg"),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.myName = localStorage.getItem("nickname");
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
download() {
|
download() {
|
||||||
//下载文件
|
//下载文件
|
||||||
|
|
Loading…
Reference in New Issue