diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index 4d128913b..8a47e337a 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -120,12 +120,17 @@ class RequestHttp { get(url: string, params?: object, _object = {}): Promise> { return this.service.get(url, { params, ..._object }); } - post(url: string, params?: object, timeout?: number): Promise> { - return this.service.post(url, params, { + post(url: string, params?: object, timeout?: number, headers?: object): Promise> { + 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(url: string, params?: object, timeout?: number): Promise> { return this.service.post(url, params, { diff --git a/frontend/src/api/modules/files.ts b/frontend/src/api/modules/files.ts index 59b3497ae..a3e6eed11 100644 --- a/frontend/src/api/modules/files.ts +++ b/frontend/src/api/modules/files.ts @@ -122,7 +122,10 @@ export const addFavorite = (path: string) => { return http.post('files/favorite', { path: path }); }; -export const readByLine = (req: File.FileReadByLine) => { +export const readByLine = (req: File.FileReadByLine, operateNode?: string) => { + if (operateNode) { + return http.post('files/read', req, TimeoutEnum.T_40S, { CurrentNode: operateNode }); + } return http.post('files/read', req); }; diff --git a/frontend/src/components/log/file/index.vue b/frontend/src/components/log/file/index.vue index d30e7a812..68f29a6f9 100644 --- a/frontend/src/components/log/file/index.vue +++ b/frontend/src/components/log/file/index.vue @@ -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; diff --git a/frontend/src/components/log/task/index.vue b/frontend/src/components/log/task/index.vue index 2306fff2b..ceb3368bc 100644 --- a/frontend/src/components/log/task/index.vue +++ b/frontend/src/components/log/task/index.vue @@ -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; }; diff --git a/frontend/src/views/cronjob/library/index.vue b/frontend/src/views/cronjob/library/index.vue index 98937e525..4738f6277 100644 --- a/frontend/src/views/cronjob/library/index.vue +++ b/frontend/src/views/cronjob/library/index.vue @@ -214,7 +214,7 @@ const onSync = async () => { }; const openTaskLog = (taskID: string) => { - taskLogRef.value.openWithTaskID(taskID); + taskLogRef.value.openWithTaskID(taskID, true, 'local'); }; const search = async () => {