gaoshp
2024-06-23 fbee7228e2f6e43b417d4c3f03020704831261cd
src/utils/tool.js
@@ -1,8 +1,8 @@
/*
 * @Descripttion: 工具集
 * @version: 1.2
 * @LastEditors: sakuya
 * @LastEditTime: 2022年5月24日00:28:56
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-06-17 18:21:44
 */
import CryptoJS from 'crypto-js';
@@ -10,6 +10,16 @@
const tool = {}
var currentLocation = window.location.href; // 获取完整的URL
var protocol = window.location.protocol; // 获取协议(如http:或https:)
var hostname = window.location.hostname; // 获取主机名
var port = window.location.port; // 获取端口号
var pathname = window.location.pathname; // 获取路径名
if (process.env.NODE_ENV=='development') {
   var path = "120.46.212.231:84";
} else {
   var path = hostname+":"+port;
}
/* localStorage */
tool.data = {
   set(key, data, datetime = 0) {
@@ -116,7 +126,7 @@
/* socket */
tool.socket = {
   url:'ws://116.63.155.153:83/ws/info',
   url:'ws://'+path+'/ws/info',
   websocket: null,
   connectToWebSocket(token) {  //建立链接
       this.websocket = new WebSocket(this.url + "?access_token=" + token);