查询列表功能
This commit is contained in:
@@ -3,12 +3,18 @@
|
||||
* https://rudon.blog.csdn.net/
|
||||
*/
|
||||
import axios from 'axios'
|
||||
import { getToken, setToken, removeToken } from '@/utils/storage'
|
||||
import { getToken, getUser } from '@/utils/storage'
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
// 请求地址前缀
|
||||
let baseURL = ''
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
console.log(process.env.NODE_ENV)
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// 生产环境
|
||||
baseURL = ""
|
||||
baseURL = "http://192.168.0.119:8080/api/"
|
||||
} else {
|
||||
// 开发环境
|
||||
baseURL = ""
|
||||
@@ -16,14 +22,15 @@ if (process.env.NODE_ENV === 'production') {
|
||||
|
||||
// 请求拦截器
|
||||
axios.interceptors.request.use((config) => {
|
||||
if (getToken()) {
|
||||
config.headers['token'] = getToken();
|
||||
}
|
||||
// if (getToken()) {
|
||||
// config.headers['token'] = getToken();
|
||||
// }
|
||||
|
||||
// 请求超时时间 - 毫秒
|
||||
config.timeout = 10000
|
||||
config.timeout = 60000
|
||||
config.baseURL = baseURL
|
||||
// 自定义Content-type
|
||||
// config.headers['Content-type'] = 'application/json'
|
||||
config.headers['Content-type'] = 'application/json'
|
||||
return config;
|
||||
}, (error) => {
|
||||
return Promise.reject(error)
|
||||
@@ -65,6 +72,34 @@ export function getAxios({ url, params }) {
|
||||
|
||||
// axios的post请求
|
||||
export function postAxios({ url, data }) {
|
||||
if (url != 'account/login') {
|
||||
|
||||
axios.post('account/cheekalive', {
|
||||
userId: getUser().userId,
|
||||
currcode: getToken(),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
console.log(res)
|
||||
}).catch(err => {
|
||||
if (err.message == "Network Error") {
|
||||
// alert("网络错误,请检查网络连接")
|
||||
ElMessage.error('网络连接错误');
|
||||
} else {
|
||||
ElMessage.error(err.message);
|
||||
}
|
||||
// console.log(err)
|
||||
// reject(err)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post(
|
||||
url,
|
||||
@@ -77,7 +112,14 @@ export function postAxios({ url, data }) {
|
||||
).then(res => {
|
||||
resolve(res.data)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
if (err.message == "Network Error") {
|
||||
// alert("网络错误,请检查网络连接")
|
||||
ElMessage.error('网络连接错误');
|
||||
} else {
|
||||
ElMessage.error(err.message);
|
||||
}
|
||||
// console.log(err)
|
||||
// reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
37
src/utils/pythonBridge.js
Normal file
37
src/utils/pythonBridge.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// pythonBridge.js
|
||||
import { ref, onMounted } from 'vue';
|
||||
|
||||
export function usePythonBridge() {
|
||||
const bridge = ref(null);
|
||||
|
||||
// 初始化 QWebChannel
|
||||
const initBridge = () => {
|
||||
new QWebChannel(qt.webChannelTransport, (channel) => {
|
||||
bridge.value = channel.objects.bridge;
|
||||
});
|
||||
};
|
||||
|
||||
// 调用 Python 方法
|
||||
const callPython = (data) => {
|
||||
if (bridge.value) {
|
||||
bridge.value.stringFromJs(data);
|
||||
}
|
||||
};
|
||||
|
||||
// 从 Python 获取数据
|
||||
const getPythonData = () => {
|
||||
if (bridge.value) {
|
||||
bridge.value.stringToJs(function (result) {
|
||||
alert(result);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 在组件挂载时初始化桥接
|
||||
onMounted(initBridge);
|
||||
|
||||
return {
|
||||
callPython,
|
||||
getPythonData
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,20 @@
|
||||
export default {
|
||||
getToken() {
|
||||
return localStorage.getItem('token');
|
||||
},
|
||||
setToken(token) {
|
||||
localStorage.setItem('token', token);
|
||||
},
|
||||
removeToken() {
|
||||
localStorage.removeItem('token');
|
||||
}
|
||||
export function setToken(token) {
|
||||
localStorage.setItem('token', token);
|
||||
}
|
||||
|
||||
export function getToken() {
|
||||
return localStorage.getItem('token');
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
localStorage.removeItem('token');
|
||||
}
|
||||
|
||||
export function setUser(user) {
|
||||
|
||||
localStorage.setItem('user', JSON.stringify(user));
|
||||
}
|
||||
|
||||
export function getUser() {
|
||||
return JSON.parse(localStorage.getItem('user'));
|
||||
}
|
||||
Reference in New Issue
Block a user