优化数据分组逻辑.

This commit is contained in:
lijiahangmax
2024-08-23 01:44:05 +08:00
parent 252c538571
commit 1fca5a1912
17 changed files with 101 additions and 213 deletions

View File

@@ -101,7 +101,11 @@ export function getExecCommandLogTailToken(request: ExecLogTailRequest) {
* 下载批量执行日志文件
*/
export function downloadExecCommandLogFile(id: number) {
return axios.get('/asset/exec-command-log/download', { unwrap: true, params: { id } });
return axios.get('/asset/exec-command-log/download', {
unwrap: true,
responseType: 'blob',
params: { id },
});
}
/**

View File

@@ -94,7 +94,11 @@ export function getExecJobLogTailToken(request: ExecLogTailRequest) {
* 下载计划任务日志文件
*/
export function downloadExecJobLogFile(id: number) {
return axios.get('/asset/exec-job-log/download', { unwrap: true, params: { id } });
return axios.get('/asset/exec-job-log/download', {
unwrap: true,
responseType: 'blob',
params: { id },
});
}
/**

View File

@@ -2,6 +2,52 @@ import Mock from 'mockjs';
// import './user';
import '@/views/dashboard/workplace/mock';
// Mock XHR
interface XHR {
responseType: string;
timeout: number;
withCredentials: boolean;
onabort: () => void;
onerror: () => void;
onload: () => void;
onloadend: () => void;
onloadstart: () => void;
onprogress: () => void;
onreadystatechange: () => void;
ontimeout: () => void;
}
// Mock XHR Custom
interface XHRCustom extends XHR {
custom: XHRCustom;
xhr: XHR;
match: boolean;
}
// @ts-ignore
Mock.XHR.prototype.send = (() => {
// @ts-ignore
const _send = Mock.XHR.prototype.send;
const defaultEvent = () => {
};
return function (this: XHRCustom) {
if (!this.match) {
this.custom.xhr.responseType = this.responseType || '';
this.custom.xhr.timeout = this.timeout || 0;
this.custom.xhr.withCredentials = this.withCredentials || false;
this.custom.xhr.onabort = this.onabort || defaultEvent;
this.custom.xhr.onerror = this.onerror || defaultEvent;
this.custom.xhr.onload = this.onload || defaultEvent;
this.custom.xhr.onloadend = this.onloadend || defaultEvent;
this.custom.xhr.onloadstart = this.onloadstart || defaultEvent;
this.custom.xhr.onprogress = this.onprogress || defaultEvent;
this.custom.xhr.onreadystatechange = this.onreadystatechange || defaultEvent;
this.custom.xhr.ontimeout = this.ontimeout || defaultEvent;
}
return _send.apply(this, arguments);
};
})();
Mock.setup({
timeout: '600-1000',
});

View File

@@ -109,7 +109,7 @@ export function openDownloadFile(url: string) {
* 下载文件
*/
export function downloadFile(res: any, fileName: string = '') {
const blob = new Blob([res.data]);
const blob = new Blob([res.data], { type: 'application/octet-stream' });
const tempLink = document.createElement('a');
const blobURL = window.URL.createObjectURL(blob);
tempLink.style.display = 'none';

View File

@@ -78,6 +78,9 @@
import UserSelector from '@/components/user/user/selector/index.vue';
import HostSelector from '@/components/asset/host/selector/index.vue';
const emits = defineEmits(['clear']);
const { toOptions } = useDictStore();
const { visible, setVisible } = useVisible();
const { loading, setLoading } = useLoading();
@@ -94,10 +97,6 @@
const formModel = ref<HostConnectLogQueryRequest>({});
const emits = defineEmits(['clear']);
const { toOptions } = useDictStore();
// 打开
const open = (record: any) => {
renderForm({ ...defaultForm(), ...record });