完善功能
This commit is contained in:
@@ -11,11 +11,10 @@ const router = useRouter();
|
||||
|
||||
// 请求地址前缀
|
||||
let baseURL = ''
|
||||
console.log(process.env.NODE_ENV)
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// 生产环境
|
||||
baseURL = "http://120.26.251.180:8085/api/"
|
||||
// baseURL = "http://192.168.0.100:8085/api/"
|
||||
// baseURL = "http://192.168.0.108:8085/api/"
|
||||
} else {
|
||||
// 开发环境
|
||||
baseURL = ""
|
||||
@@ -85,7 +84,6 @@ export function postAxios({ url, data }) {
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
console.log(res)
|
||||
}).catch(err => {
|
||||
if (err.message == "Network Error") {
|
||||
// alert("网络错误,请检查网络连接")
|
||||
@@ -128,5 +126,38 @@ export function postAxios({ url, data }) {
|
||||
})
|
||||
})
|
||||
}
|
||||
export const downFile = async (urlstr, data) => {
|
||||
|
||||
// 发送请求,获取文件流
|
||||
const response = await axios.post(urlstr, data, { responseType: 'blob' });
|
||||
|
||||
// 获取文件名(如果后端设置了 Content-Disposition)
|
||||
const contentDisposition = response.headers['content-disposition'];
|
||||
let fileName = 'default-file-name'; // 默认文件名
|
||||
console.log(contentDisposition)
|
||||
console.log(response)
|
||||
if (contentDisposition) {
|
||||
// 从响应头中提取文件名
|
||||
const fileNameMatch = contentDisposition.match(/filename="(.+)"/);
|
||||
if (fileNameMatch && fileNameMatch.length > 1) {
|
||||
fileName = fileNameMatch[1];
|
||||
}
|
||||
}
|
||||
|
||||
// 创建一个临时的下载链接
|
||||
const blob = new Blob([response.data], { type: response.headers['content-type'] });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = fileName; // 设置下载的文件名
|
||||
a.click();
|
||||
|
||||
// 释放 URL 对象
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default axios
|
||||
@@ -47,18 +47,14 @@ export function usePythonBridge() {
|
||||
|
||||
// 登录tk后台
|
||||
const loginBackStage = (data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (bridge.value) {
|
||||
bridge.value.loginBackStage(data, function (result) {
|
||||
if (result) {
|
||||
resolve(result);
|
||||
} else {
|
||||
reject(result);
|
||||
}
|
||||
|
||||
});
|
||||
if (bridge.value) {
|
||||
if (data.index == 0) {
|
||||
bridge.value.loginBackStage(JSON.stringify(data));
|
||||
} else if (data.index == 1) {
|
||||
bridge.value.loginBackStageCopy(JSON.stringify(data));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//跳转到主播页面
|
||||
@@ -70,6 +66,31 @@ export function usePythonBridge() {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//查询登录状态
|
||||
const backStageloginStatus = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (bridge.value) {
|
||||
bridge.value.backStageloginStatus(function (result) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
//查询登录状态
|
||||
const backStageloginStatusCopy = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (bridge.value) {
|
||||
bridge.value.backStageloginStatusCopy(function (result) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
// 在组件挂载时初始化桥接
|
||||
onMounted(initBridge);
|
||||
|
||||
@@ -78,6 +99,8 @@ export function usePythonBridge() {
|
||||
fetchDataCount,
|
||||
loginBackStage,
|
||||
loginTikTok,
|
||||
givePyAnchorId
|
||||
givePyAnchorId,
|
||||
backStageloginStatus,
|
||||
backStageloginStatusCopy
|
||||
};
|
||||
}
|
||||
@@ -26,9 +26,20 @@ export function getNumData() {
|
||||
return JSON.parse(localStorage.getItem('num'));
|
||||
}
|
||||
|
||||
// 导出一个函数,用于设置用户密码
|
||||
export function setUserPass(userdata) {
|
||||
localStorage.setItem('userPass', JSON.stringify(userdata));
|
||||
}
|
||||
// 导出一个函数,用于获取用户密码
|
||||
export function getUserPass() {
|
||||
return JSON.parse(localStorage.getItem('userPass'));
|
||||
}
|
||||
|
||||
// 用于设置tk账户密码
|
||||
export function setTkUser(userdata) {
|
||||
localStorage.setItem('tkuser', JSON.stringify(userdata));
|
||||
}
|
||||
// 用于获取tk账户密码
|
||||
export function getTkUser() {
|
||||
return JSON.parse(localStorage.getItem('tkuser'));
|
||||
}
|
||||
Reference in New Issue
Block a user