Commit dac8cc05 by liyuhang19990520

即时通讯

parent ca6bc4f9
/* /*
* @Author: your name * @Author: your name
* @Date: 2021-08-20 16:31:17 * @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 * @LastEditors: Please set LastEditors
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: \V-IM-PC\src\views\im\conf\index.js * @FilePath: \V-IM-PC\src\views\im\conf\index.js
...@@ -27,64 +27,65 @@ export default { ...@@ -27,64 +27,65 @@ export default {
chatGroupDelUser_url: '/api/chatGroupUser/delete', chatGroupDelUser_url: '/api/chatGroupUser/delete',
export_url: '/api/message/export', export_url: '/api/message/export',
ws_protocol: "ws", ws_protocol: "ws",
getHostUrl: function() { getHostUrl: function () {
return ( return (
this.http_protocol + // this.http_protocol +
"://" + // "://" +
localStorage.getItem("host") + // localStorage.getItem("host") +
":" + // ":" +
this.http_port // this.http_port
"http://110.1.6.3:8084"
); );
}, },
getTokenUrl: function() { getTokenUrl: function () {
return this.getHostUrl() + this.token_path; return this.getHostUrl() + this.token_path;
}, },
getInitUrl: function() { getInitUrl: function () {
return this.getHostUrl() + this.init; return this.getHostUrl() + this.init;
}, },
getChatUsersUrl: function() { getChatUsersUrl: function () {
return this.getHostUrl() + this.chat_users_url; return this.getHostUrl() + this.chat_users_url;
}, },
getHisUrl: function() { getHisUrl: function () {
return this.getHostUrl() + this.his_url; return this.getHostUrl() + this.his_url;
}, },
getRegisterUrl: function() { getRegisterUrl: function () {
return this.getHostUrl() + this.addFriend_url; return this.getHostUrl() + this.addFriend_url;
}, },
getaddFriendUrl: function() { getaddFriendUrl: function () {
return this.getHostUrl() + this.register_url; return this.getHostUrl() + this.register_url;
}, },
getaddGroupUrl: function() { getaddGroupUrl: function () {
return this.getHostUrl() + this.addGroup_url; return this.getHostUrl() + this.addGroup_url;
}, },
getRemoveGroupUrl: function() { getRemoveGroupUrl: function () {
return this.getHostUrl() + this.removeGroup_url; return this.getHostUrl() + this.removeGroup_url;
}, },
getGroupListUrl: function() { getGroupListUrl: function () {
return this.getHostUrl() + this.groupList_url; return this.getHostUrl() + this.groupList_url;
}, },
getFriendListUrl: function() { getFriendListUrl: function () {
return this.getHostUrl() + this.friendList_url; return this.getHostUrl() + this.friendList_url;
}, },
getChatGroupUserUrl: function() { getChatGroupUserUrl: function () {
return this.getHostUrl() + this.chatGroupUser_url; return this.getHostUrl() + this.chatGroupUser_url;
}, },
getChatGroupDelUserUrl: function() { getChatGroupDelUserUrl: function () {
return this.getHostUrl() + this.chatGroupDelUser_url; return this.getHostUrl() + this.chatGroupDelUser_url;
}, },
getChatGroupDelUserUrl: function() { getChatGroupDelUserUrl: function () {
return this.getHostUrl() + this.chatGroupDelUser_url; return this.getHostUrl() + this.chatGroupDelUser_url;
}, },
getChatGroupUserDshUrl: function() { getChatGroupUserDshUrl: function () {
return this.getHostUrl() + this.chatGroupUserDsh_url; return this.getHostUrl() + this.chatGroupUserDsh_url;
}, },
getChatGroupUserAgreeUrl: function() { getChatGroupUserAgreeUrl: function () {
return this.getHostUrl() + this.chatGroupUserAgree_url; return this.getHostUrl() + this.chatGroupUserAgree_url;
}, },
getExportUrl: function() { getExportUrl: function () {
return this.getHostUrl() + this.export_url; return this.getHostUrl() + this.export_url;
}, },
getWsUrl: function() { getWsUrl: function () {
return ( return (
this.ws_protocol + this.ws_protocol +
"://" + "://" +
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
class="item-input" class="item-input"
/> />
</div> </div>
<div class="item"> <!-- <div class="item">
<label>服务:</label> <label>服务:</label>
<Input <Input
prefix="ios-settings-outline" prefix="ios-settings-outline"
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
placeholder="服务" placeholder="服务"
class="item-input" class="item-input"
/> />
</div> </div> -->
<div class="btn item"> <div class="btn item">
<Button type="primary" @click="login()" icon="md-contact">登录</Button> <Button type="primary" @click="login()" icon="md-contact">登录</Button>
</div> </div>
...@@ -84,7 +84,7 @@ import conf from "./im/conf"; ...@@ -84,7 +84,7 @@ import conf from "./im/conf";
import RequestUtils from "../utils/RequestUtils"; import RequestUtils from "../utils/RequestUtils";
import StoreUtils from "../utils/StoreUtils"; import StoreUtils from "../utils/StoreUtils";
import { ErrorType } from "../utils/ChatUtils"; import { ErrorType } from "../utils/ChatUtils";
const CryptoJS = require("crypto-js"); //引用AES源码js
export default { export default {
name: "login", name: "login",
data() { data() {
...@@ -99,8 +99,8 @@ export default { ...@@ -99,8 +99,8 @@ export default {
showErr: false, showErr: false,
showSetting: false, showSetting: false,
showRegister: false, showRegister: false,
host: "192.168.0.106", host: "110.1.6.3:8084",
routeQuery: '', uap: "",
}; };
}, },
components: { components: {
...@@ -146,7 +146,6 @@ export default { ...@@ -146,7 +146,6 @@ export default {
}, },
login: function () { login: function () {
let self = this; let self = this;
localStorage.setItem("host", self.host);
let requestApi = RequestUtils; let requestApi = RequestUtils;
requestApi requestApi
.login(self.username.trim(), self.password.trim(), self) .login(self.username.trim(), self.password.trim(), self)
...@@ -189,32 +188,58 @@ export default { ...@@ -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 () { created: function () {
this.routeQuery = this.$route.query; this.uap = this.$route.query.uap;
let self = this; let self = this;
let host = localStorage.getItem("host"); localStorage.setItem("host", self.host);
if (host) {
self.host = host;
} else {
localStorage.setItem("host", self.host);
}
}, },
mounted() { mounted() {
if(this.routeQuery.username && this.routeQuery.password){ if (this.uap) {
this.username = this.routeQuery.username; let data = this.Decrypt(this.uap);
this.password = this.routeQuery.password; 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(); 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> </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