单点登录
This commit is contained in:
@@ -14,7 +14,7 @@ let baseURL = ''
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// 生产环境
|
||||
baseURL = "http://120.26.251.180:8085/"
|
||||
// baseURL = "http://192.168.0.114:8085/"
|
||||
// baseURL = "http://192.168.0.115:8085/"
|
||||
} else {
|
||||
// 开发环境
|
||||
baseURL = "http://120.26.251.180:8085/"
|
||||
@@ -38,11 +38,6 @@ axios.interceptors.request.use((config) => {
|
||||
|
||||
// 响应拦截器
|
||||
axios.interceptors.response.use((response) => {
|
||||
/**
|
||||
* 可添加请求响应的处理逻辑, 例如接口自定义的response.data.code不是200代表失败。
|
||||
* 错误的话 return Promise.reject(response)
|
||||
* 正确的话 return response
|
||||
*/
|
||||
return response
|
||||
}, (error) => {
|
||||
// 可添加请求失败后的处理逻辑
|
||||
@@ -52,8 +47,6 @@ axios.interceptors.response.use((response) => {
|
||||
|
||||
|
||||
// axios的get请求
|
||||
// 导出一个函数,用于发送GET请求
|
||||
// 返回一个Promise对象
|
||||
export function getAxios({ url, params }) {
|
||||
// 使用axios发送GET请求
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -74,35 +67,7 @@ export function getAxios({ url, params }) {
|
||||
export function postAxios({ url, data }) {
|
||||
if (url != 'api/account/login') {
|
||||
|
||||
axios.post('api/account/cheekalive', {
|
||||
userId: getUser().userId,
|
||||
currcode: getToken(),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
if (res) {
|
||||
|
||||
} else {
|
||||
alert("账号在其他地方登录!")
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
|
||||
}).catch(err => {
|
||||
if (err.message == "Network Error") {
|
||||
// alert("网络错误,请检查网络连接")
|
||||
ElMessage.error('网络连接错误');
|
||||
} else {
|
||||
ElMessage.error(err.message);
|
||||
}
|
||||
// console.log(err)
|
||||
// reject(err)
|
||||
|
||||
})
|
||||
throttledCheekalive();
|
||||
|
||||
}
|
||||
|
||||
@@ -165,7 +130,43 @@ export const downFile = async (urlstr, data) => {
|
||||
|
||||
|
||||
}
|
||||
//请求前验证
|
||||
function cheekalive() {
|
||||
axios.post('api/account/cheekalive', {
|
||||
userId: getUser().userId,
|
||||
currcode: getToken(),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
console.log(res.data)
|
||||
if (res.data) {
|
||||
|
||||
} else {
|
||||
alert("账号在其他地方登录!")
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
//节流函数
|
||||
function throttle(func, limit) {
|
||||
let inThrottle;
|
||||
return function () {
|
||||
const args = arguments;
|
||||
const context = this;
|
||||
if (!inThrottle) {
|
||||
func.apply(context, args);
|
||||
inThrottle = true;
|
||||
setTimeout(() => inThrottle = false, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const throttledCheekalive = throttle(cheekalive, 5000);
|
||||
|
||||
export default axios
|
||||
@@ -3,6 +3,7 @@ import { ref, onMounted } from 'vue';
|
||||
const bridge = ref(null);
|
||||
// 初始化 QWebChannel
|
||||
const initBridge = () => {
|
||||
if (/localhost/.test(window.location.href)) return
|
||||
new QWebChannel(qt.webChannelTransport, (channel) => {
|
||||
bridge.value = channel.objects.bridge;
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column v-for="label in labelList" :key="label.paramCode" :prop="label.paramCode"
|
||||
:label="label.paramCodeMeaning" width="120">
|
||||
<template #default="scope">
|
||||
<template v-if="label.paramCode != 'createDt'" #default="scope">
|
||||
<el-popover v-if="!(label.paramCode == 'hostcoins' || label.paramCode == 'ysthostcoins')"
|
||||
placement="bottom" :width="600" trigger="hover">
|
||||
<div style="height: 300px;">
|
||||
@@ -65,6 +65,7 @@
|
||||
</div>
|
||||
<template #reference>
|
||||
<!-- 鼠标移入时开启 -->
|
||||
|
||||
<span @mouseover="openPopover(scope.row.hostId, label.paramCode)"
|
||||
@mouseout="closePopover(scope.row.hostId, label.paramCode)">
|
||||
{{ scope.row[label.paramCode] }}
|
||||
|
||||
Reference in New Issue
Block a user