fix: Fix the problem of failed task log acquisition (#8604)

This commit is contained in:
ssongliu 2025-05-12 16:45:58 +08:00 committed by GitHub
parent bb5f04a9b0
commit 02a9267fa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 24 additions and 8 deletions

View file

@ -120,12 +120,17 @@ class RequestHttp {
get<T>(url: string, params?: object, _object = {}): Promise<ResultData<T>> {
return this.service.get(url, { params, ..._object });
}
post<T>(url: string, params?: object, timeout?: number): Promise<ResultData<T>> {
return this.service.post(url, params, {
post<T>(url: string, params?: object, timeout?: number, headers?: object): Promise<ResultData<T>> {
let config = {
baseURL: import.meta.env.VITE_API_URL as string,
timeout: timeout ? timeout : (ResultEnum.TIMEOUT as number),
withCredentials: true,
});
headers: headers,
};
if (headers) {
config.headers = headers;
}
return this.service.post(url, params, config);
}
postLocalNode<T>(url: string, params?: object, timeout?: number): Promise<ResultData<T>> {
return this.service.post(url, params, {

View file

@ -122,7 +122,10 @@ export const addFavorite = (path: string) => {
return http.post<any>('files/favorite', { path: path });
};
export const readByLine = (req: File.FileReadByLine) => {
export const readByLine = (req: File.FileReadByLine, operateNode?: string) => {
if (operateNode) {
return http.post<any>('files/read', req, TimeoutEnum.T_40S, { CurrentNode: operateNode });
}
return http.post<any>('files/read', req);
};

View file

@ -49,6 +49,8 @@ interface LogProps {
taskType?: string;
taskOperate?: string;
resourceID?: number;
operateNode?: string;
}
const props = defineProps({
@ -64,6 +66,8 @@ const props = defineProps({
taskOperate: '',
resourceID: 0,
taskID: '',
operateNode: '',
}),
},
defaultButton: {
@ -201,7 +205,7 @@ const getContent = async (pre: boolean) => {
isLoading.value = true;
emit('update:isReading', true);
const res = await readByLine(readReq);
const res = await readByLine(readReq, props.config.operateNode || '');
logPath.value = res.data.path;
firstLoading.value = false;

View file

@ -42,25 +42,29 @@ const config = reactive({
taskType: '',
tail: true,
colorMode: 'task',
operateNode: '',
});
const open = ref(false);
const showTail = ref(true);
const openWithTaskID = (id: string, tail: boolean) => {
const openWithTaskID = (id: string, tail: boolean, operateNode?: string) => {
config.taskID = id;
if (tail === undefined) {
config.tail = true;
} else {
config.tail = tail;
}
config.operateNode = operateNode || '';
open.value = true;
bus.emit('refreshTask', true);
};
const openWithResourceID = (taskType: string, taskOperate: string, resourceID: number) => {
const openWithResourceID = (taskType: string, taskOperate: string, resourceID: number, operateNode?: string) => {
config.taskType = taskType;
config.resourceID = resourceID;
config.taskOperate = taskOperate;
config.operateNode = operateNode || '';
open.value = true;
};

View file

@ -214,7 +214,7 @@ const onSync = async () => {
};
const openTaskLog = (taskID: string) => {
taskLogRef.value.openWithTaskID(taskID);
taskLogRef.value.openWithTaskID(taskID, true, 'local');
};
const search = async () => {