Commit dac8cc05 by liyuhang19990520

即时通讯

parent ca6bc4f9
/*
* @Author: your name
* @Date: 2021-08-20 16:31:17
* @LastEditTime: 2021-08-27 15:34:23
* @LastEditTime: 2021-09-01 10:22:31
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \V-IM-PC\src\views\im\conf\index.js
......@@ -27,64 +27,65 @@ export default {
chatGroupDelUser_url: '/api/chatGroupUser/delete',
export_url: '/api/message/export',
ws_protocol: "ws",
getHostUrl: function() {
getHostUrl: function () {
return (
this.http_protocol +
"://" +
localStorage.getItem("host") +
":" +
this.http_port
// this.http_protocol +
// "://" +
// localStorage.getItem("host") +
// ":" +
// this.http_port
"http://110.1.6.3:8084"
);
},
getTokenUrl: function() {
getTokenUrl: function () {
return this.getHostUrl() + this.token_path;
},
getInitUrl: function() {
getInitUrl: function () {
return this.getHostUrl() + this.init;
},
getChatUsersUrl: function() {
getChatUsersUrl: function () {
return this.getHostUrl() + this.chat_users_url;
},
getHisUrl: function() {
getHisUrl: function () {
return this.getHostUrl() + this.his_url;
},
getRegisterUrl: function() {
getRegisterUrl: function () {
return this.getHostUrl() + this.addFriend_url;
},
getaddFriendUrl: function() {
getaddFriendUrl: function () {
return this.getHostUrl() + this.register_url;
},
getaddGroupUrl: function() {
getaddGroupUrl: function () {
return this.getHostUrl() + this.addGroup_url;
},
getRemoveGroupUrl: function() {
getRemoveGroupUrl: function () {
return this.getHostUrl() + this.removeGroup_url;
},
getGroupListUrl: function() {
getGroupListUrl: function () {
return this.getHostUrl() + this.groupList_url;
},
getFriendListUrl: function() {
getFriendListUrl: function () {
return this.getHostUrl() + this.friendList_url;
},
getChatGroupUserUrl: function() {
getChatGroupUserUrl: function () {
return this.getHostUrl() + this.chatGroupUser_url;
},
getChatGroupDelUserUrl: function() {
getChatGroupDelUserUrl: function () {
return this.getHostUrl() + this.chatGroupDelUser_url;
},
getChatGroupDelUserUrl: function() {
getChatGroupDelUserUrl: function () {
return this.getHostUrl() + this.chatGroupDelUser_url;
},
getChatGroupUserDshUrl: function() {
getChatGroupUserDshUrl: function () {
return this.getHostUrl() + this.chatGroupUserDsh_url;
},
getChatGroupUserAgreeUrl: function() {
getChatGroupUserAgreeUrl: function () {
return this.getHostUrl() + this.chatGroupUserAgree_url;
},
getExportUrl: function() {
getExportUrl: function () {
return this.getHostUrl() + this.export_url;
},
getWsUrl: function() {
getWsUrl: function () {
return (
this.ws_protocol +
"://" +
......
......@@ -26,7 +26,7 @@
class="item-input"
/>
</div>
<div class="item">
<!-- <div class="item">
<label>服务:</label>
<Input
prefix="ios-settings-outline"
......@@ -34,7 +34,7 @@
placeholder="服务"
class="item-input"
/>
</div>
</div> -->
<div class="btn item">
<Button type="primary" @click="login()" icon="md-contact">登录</Button>
</div>
......@@ -84,7 +84,7 @@ import conf from "./im/conf";
import RequestUtils from "../utils/RequestUtils";
import StoreUtils from "../utils/StoreUtils";
import { ErrorType } from "../utils/ChatUtils";
const CryptoJS = require("crypto-js"); //引用AES源码js
export default {
name: "login",
data() {
......@@ -99,8 +99,8 @@ export default {
showErr: false,
showSetting: false,
showRegister: false,
host: "192.168.0.106",
routeQuery: '',
host: "110.1.6.3:8084",
uap: "",
};
},
components: {
......@@ -146,7 +146,6 @@ export default {
},
login: function () {
let self = this;
localStorage.setItem("host", self.host);
let requestApi = RequestUtils;
requestApi
.login(self.username.trim(), self.password.trim(), self)
......@@ -189,32 +188,58 @@ export default {
}
});
},
//解密方法
Decrypt(word) {
const key = CryptoJS.enc.Utf8.parse("0000000671595991"); //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse("tdrdadq59tbss5n7"); //十六位十六进制数作为密钥偏移量
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
},
//加密方法
Encrypt(word) {
const key = CryptoJS.enc.Utf8.parse("0000000671595991"); //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse("tdrdadq59tbss5n7"); //十六位十六进制数作为密钥偏移量
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
},
},
created: function () {
this.routeQuery = this.$route.query;
this.uap = this.$route.query.uap;
let self = this;
let host = localStorage.getItem("host");
if (host) {
self.host = host;
} else {
localStorage.setItem("host", self.host);
}
localStorage.setItem("host", self.host);
},
mounted() {
if(this.routeQuery.username && this.routeQuery.password){
this.username = this.routeQuery.username;
this.password = this.routeQuery.password;
if (this.uap) {
let data = this.Decrypt(this.uap);
console.log(data);
let arr = data.split("&");
arr.forEach((i, index) => {
arr[index] = i.split("=");
});
arr.forEach((i, s) => {
i.forEach((j, index) => {
if (j == "username") {
this.username = arr[s][index + 1];
} else if (j == "password") {
this.password = arr[s][index + 1];
}
});
});
console.log(this.username, this.password);
this.login();
}
// 密码加密
// var decrypt = this.$cryptoJs.AES.decrypt(
// encrypt,//解密后的文字
// this.$cryptoJs.enc.Utf8.parse(aseKey),//key
// {
// mode: this.$cryptoJs.mode.ECB,
// padding: this.$cryptoJs.pad.Pkcs7,
// }
// ).toString(this.$cryptoJs.enc.Utf8);
}
},
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment