添加矿机租赁项目跳转
This commit is contained in:
@@ -193,6 +193,11 @@
|
||||
<span class="line"></span>
|
||||
</div>
|
||||
</li>
|
||||
<!-- 矿机租赁 -->
|
||||
<li @click="handelMachineLease">
|
||||
{{ $t(`home.machineLease`) }}
|
||||
</li>
|
||||
|
||||
<!-- 工单管理 -->
|
||||
<!-- <li
|
||||
v-show="ManagementShow"
|
||||
@@ -641,6 +646,81 @@ export default {
|
||||
this.isLogin = false;
|
||||
this.isDropdownVisible = false;
|
||||
},
|
||||
/**
|
||||
* 简单的AES加密函数
|
||||
* @param {string} text - 要加密的文本
|
||||
* @param {string} secretKey - 密钥
|
||||
* @returns {string} 加密后的字符串
|
||||
*/
|
||||
encryptData(text, secretKey) {
|
||||
try {
|
||||
// 使用简单的XOR加密(生产环境建议使用更安全的加密库如crypto-js)
|
||||
let encrypted = '';
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
encrypted += String.fromCharCode(text.charCodeAt(i) ^ secretKey.charCodeAt(i % secretKey.length));
|
||||
}
|
||||
return btoa(encrypted); // Base64编码
|
||||
} catch (error) {
|
||||
console.error('加密失败:', error);
|
||||
return text; // 如果加密失败,返回原文
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 处理机器租赁跳转,携带加密的用户参数
|
||||
*/
|
||||
handelMachineLease(){
|
||||
try {
|
||||
// 获取当前用户信息和其他需要传递的参数
|
||||
|
||||
const token =localStorage.getItem('token') || '';
|
||||
const userEmail = localStorage.getItem('userEmail') || '';
|
||||
const language = this.$i18n.locale || 'zh';
|
||||
const username = localStorage.getItem('username') || '';
|
||||
|
||||
// 定义加密密钥(生产环境应该从环境变量或配置文件中获取)
|
||||
const secretKey = 'mining-pool-secret-key-2024';
|
||||
|
||||
// 准备要加密的敏感数据
|
||||
const sensitiveData = {
|
||||
token: token,
|
||||
userEmail: userEmail,
|
||||
timestamp: Date.now()
|
||||
};
|
||||
|
||||
// 加密敏感数据
|
||||
const encryptedData = this.encryptData(JSON.stringify(sensitiveData), secretKey);
|
||||
|
||||
// 构建带参数的URL(敏感数据加密,其他数据明文)
|
||||
const baseUrl = "http://10.168.2.120:8080/";
|
||||
const params = new URLSearchParams({
|
||||
data: encryptedData, // 加密的敏感数据
|
||||
language: language,
|
||||
username: username,
|
||||
source: 'mining-pool', // 标识来源项目
|
||||
version: '1.0' // 数据版本,用于兼容性
|
||||
});
|
||||
|
||||
const urlWithParams = `${baseUrl}?${params.toString()}`;
|
||||
|
||||
// 当前窗口打开
|
||||
window.open(urlWithParams, "_self");
|
||||
|
||||
// 记录跳转日志(用于调试,不记录敏感信息)
|
||||
console.log('跳转到机器租赁系统,携带参数:', {
|
||||
|
||||
userEmail: userEmail ? '***' : '',
|
||||
language,
|
||||
source: 'mining-pool',
|
||||
encrypted: true
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('跳转机器租赁系统时发生错误:', error);
|
||||
this.$message.error("加载系统失败 稍后重试");
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user