2023-12-01版本

This commit is contained in:
Cool 2023-12-01 20:58:56 +08:00
parent 2afcad01e6
commit 51bde198f1
6 changed files with 59 additions and 30 deletions

View File

@ -41,11 +41,11 @@ const routes = [
} }
}, },
{ {
path:"/chat", path: "/chat",
name:"Chat", name: "Chat",
component:()=>import("../views/main/Chat.vue"), component: () => import("../views/main/Chat.vue"),
meta:{ meta: {
isLogin:true isLogin: true
} }
} }
] ]

View File

@ -17,7 +17,6 @@ export default new Vuex.Store({
delToken(state) { delToken(state) {
state.token = '' state.token = ''
localStorage.removeItem("token")//删除token localStorage.removeItem("token")//删除token
} }
}, },
actions: { actions: {

View File

@ -4,7 +4,7 @@ import { Message } from "element-ui";
//创建axios实例 //创建axios实例
const axiosInstance = axios.create({ const axiosInstance = axios.create({
baseURL: 'http://localhost:8080', // 设置默认发送地址为后端端口 baseURL: 'http://localhost:8887', // 设置默认发送地址为后端端口
}); });
//添加拦截器在每次ajax之前都会执行这个操作 //添加拦截器在每次ajax之前都会执行这个操作

View File

@ -215,7 +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); localStorage.setItem("account", that.loginForm.account);
that.$router.push({ path: "/home" }); that.$router.push({ path: "/home" });
} else { } else {
that.$message.error('账号或密码错误'); that.$message.error('账号或密码错误');

View File

@ -13,7 +13,7 @@
<p>{{ message.nickname }} {{ message.sendTime }}</p> <p>{{ message.nickname }} {{ message.sendTime }}</p>
</div> </div>
<div class="info"> <div class="info">
<el-avatar :src="message.pic" class="head"></el-avatar> <el-avatar :src=message.pic class="head"></el-avatar>
<div class="message"> <div class="message">
<div class="detail"> <div class="detail">
{{ message.message }} {{ message.message }}
@ -31,7 +31,7 @@
</div> </div>
<div class="info"> <div class="info">
<el-avatar :src="message.pic" class="head"></el-avatar> <el-avatar :src=message.pic class="head"></el-avatar>
<div class="message"> <div class="message">
<div class="detail"> <div class="detail">
@ -59,6 +59,8 @@
</template> </template>
<script> <script>
import axiosInstance from '@/store/request';
let socket; let socket;
export default { export default {
@ -78,12 +80,12 @@ export default {
this.myName = localStorage.getItem("nickname"); this.myName = localStorage.getItem("nickname");
}, },
methods: { methods: {
getDate(){ getDate() {
var date = new Date(); var date = new Date();
var year = date.getFullYear(); var year = date.getFullYear();
var month = (date.getMonth() + 1).toString().padStart(2, '0'); var month = (date.getMonth() + 1).toString().padStart(2, '0');
var day = date.getDate().toString().padStart(2, '0'); var day = date.getDate().toString().padStart(2, '0');
var hour =date.getHours().toString().padStart(2, '0'); var hour = date.getHours().toString().padStart(2, '0');
var minute = date.getMinutes().toString().padStart(2, '0'); var minute = date.getMinutes().toString().padStart(2, '0');
var second = date.getSeconds().toString().padStart(2, '0'); var second = date.getSeconds().toString().padStart(2, '0');
this.dateNow = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second; this.dateNow = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second;
@ -93,6 +95,7 @@ export default {
if (!this.textarea) { if (!this.textarea) {
this.$message({ type: 'warning', message: "请输入内容" }) this.$message({ type: 'warning', message: "请输入内容" })
} else { } else {
axiosInstance.get("/interceptor")
this.getDate() this.getDate()
let SendMessage = { let SendMessage = {
nickname: this.myName, nickname: this.myName,
@ -114,11 +117,12 @@ export default {
init() { init() {
const that = this const that = this
axiosInstance.get("/interceptor")
if (typeof (WebSocket) === undefined) { if (typeof (WebSocket) === undefined) {
console.log("您的浏览器不支持WebSocket"); console.log("您的浏览器不支持WebSocket");
} else { } else {
console.log("您的浏览器支持WebSocket"); console.log("您的浏览器支持WebSocket");
let socketUrl = "ws://localhost:8080/chat/get"; let socketUrl = "ws://localhost:8887/chat/get";
if (socket != null) { if (socket != null) {
socket.close(); socket.close();
socket = null; socket = null;

View File

@ -32,14 +32,14 @@
<div class="left"> <div class="left">
<h2 class="versionText">ChatABC Windows版 1.1.1</h2> <h2 class="versionText">ChatABC Windows版 1.1.1</h2>
<p class="time">发布时间: 2023年11月17号</p> <p class="time">发布时间: 2023年11月17号</p>
<img src="../../assets/img/cool.jpg" class="img"> <img :src=headPic class="img">
<br> <br>
<el-button type="primary" round class="button" @click="download">立即下载</el-button> <el-button type="primary" round class="button" @click="download">立即下载</el-button>
</div> </div>
<div class="right"> <div class="right">
<h2 class="versionText">ChatABC Linux版 1.1.1</h2> <h2 class="versionText">ChatABC Linux版 1.1.1</h2>
<p class="time">发布时间: 2023年11月17号</p> <p class="time">发布时间: 2023年11月17号</p>
<img src="../../assets/img/cool.jpg" class="img"> <img :src=headPic class="img">
<el-button type="primary" class="button" @click="download" round>立即下载</el-button> <el-button type="primary" class="button" @click="download" round>立即下载</el-button>
</div> </div>
</div> </div>
@ -47,18 +47,41 @@
</template> </template>
<script> <script>
import axiosInstance from "@/store/request";
export default { export default {
data() { data() {
return { return {
myName: "", myName: "",
headPic: require("@/assets/img/cool.jpg"), headPic: "",
}; };
}, },
mounted() { mounted() {
this.myName = localStorage.getItem("nickname"); this.myName = localStorage.getItem("nickname");
this.headPic = localStorage.getItem("headPic");
console.log(this.headPic);
this.init()
}, },
methods: { methods: {
init() {
const that=this
axiosInstance.post("/getHead", {
account: localStorage.getItem("account"),
}).then(function (response) {
that.headPic = response.data.pic;
that.myName = response.data.username;
localStorage.setItem("nickname", response.data.username);
});
},
download() { download() {
// //
var blob = new Blob(['Hello, this is the content of the file!'], { type: 'text/plain' }); var blob = new Blob(['Hello, this is the content of the file!'], { type: 'text/plain' });
var link = document.createElement('a'); var link = document.createElement('a');
@ -103,6 +126,7 @@ export default {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 100%; height: 100%;
} }
.dropdownMenu { .dropdownMenu {
@ -121,18 +145,8 @@ export default {
} }
.el-popper[x-placement^=bottom] .popper__arrow {
display: none;
}
.el-icon-arrow-down {
font-size: 12px;
}
.headerNav { .headerNav {
background-color: rgb(35, 40, 52) ; background-color: rgb(35, 40, 52);
// position: relative; // position: relative;
// right: 0; // right: 0;
// top: 0; // top: 0;
@ -250,6 +264,7 @@ export default {
height: 300px; height: 300px;
} }
.button { .button {
margin-top: 50px; margin-top: 50px;
margin-left: 190px; margin-left: 190px;
@ -260,4 +275,15 @@ export default {
} }
} }
} }
}</style> }
</style>
<style lang="scss">
//stylescope
.el-popper[x-placement^=bottom] .popper__arrow {
display: none;
}
.el-icon-arrow-down {
font-size: 12px;
}
</style>