tpa_web_component
Version:
TPA Web Components Library
84 lines (80 loc) • 2.38 kB
JavaScript
import { getZipLog, getApplicationSupportDirectoryAllPath, getDownloadPath } from '../utils/callingAppApi';
import { ElNotification } from 'element-plus';
function zipLogUtil(successCallback, failCallback) {
// 容错
let timer = setTimeout(() => {
// 10s秒之内没有反应,则提示打包无响应,不阻塞后续操作
// ziping.value = false;
failCallback();
ElNotification({
title: '提示',
message: '日志打包无响应',
type: 'warning',
})
}, 10000)
getApplicationSupportDirectoryAllPath((res) => {
if (res.data.code == 0) {
const tree = res.data.tree;
let logpath = '';
tree.some(item => {
if (/log$/.test(item.path)) {
logpath = item.path;
return true;
}
})
getDownloadPath(res2 => {
if (res2.data.code == 0) {
getZipLog({
zipLogPathList: [logpath],
downloadPath: res2.data.downloadPath
}, (data) => {
console.log(data)
if (data.data.code && data.data.code != 0) {
clearTimeout(timer);
// ziping.value = false;
failCallback();
ElNotification({
title: '提示',
message: data.data.errmsg || '日志获取失败',
type: 'warning',
})
return;
}
if (!data.data.message) {
// 不是正常数据 证明出错了
clearTimeout(timer);
// ziping.value = false;
failCallback();
ElNotification({
title: '提示',
message: '日打包失败',
type: 'warning',
})
return;
}
clearTimeout(timer);
successCallback(data.data)
})
} else {
clearTimeout(timer);
// ziping.value = false;
failCallback();
ElNotification({
title: '提示',
message: '获取存储目录失败',
type: 'warning',
})
}
})
} else {
clearTimeout(timer);
ziping.value = false;
ElNotification({
title: '提示',
message: '获取打包目录失败',
type: 'warning',
})
}
})
}
export default zipLogUtil;