⚡ 优化执行逻辑.
This commit is contained in:
77
orion-ops-ui/src/components/exec/log/panel-modal/index.vue
Normal file
77
orion-ops-ui/src/components/exec/log/panel-modal/index.vue
Normal file
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<a-modal v-model:visible="visible"
|
||||
title-align="start"
|
||||
title="执行日志"
|
||||
width="94%"
|
||||
:top="80"
|
||||
:body-style="{ padding: '0' }"
|
||||
:align-center="false"
|
||||
:draggable="true"
|
||||
:mask-closable="false"
|
||||
:unmount-on-close="true"
|
||||
:footer="false"
|
||||
@close="handleClose">
|
||||
<a-spin class="modal-body" :loading="loading">
|
||||
<!-- 日志面板 -->
|
||||
<exec-log-panel ref="log" :visible-back="false" />
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'execLogPanelModal'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useVisible from '@/hooks/visible';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { nextTick, ref } from 'vue';
|
||||
import { getExecLog } from '@/api/exec/exec-log';
|
||||
import ExecLogPanel from '../panel/index.vue';
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { loading, setLoading } = useLoading();
|
||||
|
||||
const log = ref();
|
||||
|
||||
// TODO 测试卸载
|
||||
|
||||
// 打开
|
||||
const open = async (id: number) => {
|
||||
setVisible(true);
|
||||
setLoading(true);
|
||||
try {
|
||||
// 获取执行日志
|
||||
const { data } = await getExecLog(id);
|
||||
// 打开日志
|
||||
nextTick(() => {
|
||||
log.value.open(data);
|
||||
});
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setVisible(false);
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 关闭回调
|
||||
const handleClose = () => {
|
||||
handleClear();
|
||||
};
|
||||
|
||||
// 清空
|
||||
const handleClear = () => {
|
||||
setLoading(false);
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.modal-body {
|
||||
width: 100%;
|
||||
height: calc(100vh - 140px);
|
||||
}
|
||||
</style>
|
||||
@@ -41,14 +41,14 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecCommandHostResponse } from '@/api/exec/exec';
|
||||
import type { ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import { useDictStore } from '@/store';
|
||||
import { execHostStatusKey } from './const';
|
||||
|
||||
const props = defineProps<{
|
||||
visibleBack: boolean;
|
||||
current: number;
|
||||
hosts: Array<ExecCommandHostResponse>;
|
||||
hosts: Array<ExecHostLogQueryResponse>;
|
||||
}>();
|
||||
const emits = defineEmits(['back', 'selected']);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecCommandResponse } from '@/api/exec/exec';
|
||||
import type { ExecLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import { onUnmounted, ref, nextTick } from 'vue';
|
||||
import { getExecLogStatus } from '@/api/exec/exec-log';
|
||||
import { execHostStatus, execStatus } from './const';
|
||||
@@ -39,16 +39,20 @@
|
||||
const currentHostExecId = ref();
|
||||
const statusIntervalId = ref();
|
||||
const finishIntervalId = ref();
|
||||
const command = ref<ExecCommandResponse>();
|
||||
const command = ref<ExecLogQueryResponse>();
|
||||
|
||||
// 打开
|
||||
const open = (record: ExecCommandResponse) => {
|
||||
const open = (record: ExecLogQueryResponse) => {
|
||||
command.value = record;
|
||||
currentHostExecId.value = record.hosts[0].id;
|
||||
// 注册状态轮询
|
||||
statusIntervalId.value = setInterval(fetchTaskStatus, 5000);
|
||||
// 注册完成时间轮询
|
||||
finishIntervalId.value = setInterval(setTaskFinishTime, 1000);
|
||||
// 定时查询执行状态
|
||||
if (record.status === execStatus.WAITING ||
|
||||
record.status === execStatus.RUNNING) {
|
||||
// 注册状态轮询
|
||||
statusIntervalId.value = setInterval(fetchTaskStatus, 5000);
|
||||
// 注册完成时间轮询
|
||||
finishIntervalId.value = setInterval(setTaskFinishTime, 1000);
|
||||
}
|
||||
// 打开日志
|
||||
nextTick(() => {
|
||||
logView.value?.open();
|
||||
|
||||
@@ -160,7 +160,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecCommandHostResponse } from '@/api/exec/exec';
|
||||
import type { ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import type { ILogAppender } from './const';
|
||||
import { ref } from 'vue';
|
||||
import { execHostStatus, execHostStatusKey } from './const';
|
||||
@@ -172,7 +172,7 @@
|
||||
import 'xterm/css/xterm.css';
|
||||
|
||||
const props = defineProps<{
|
||||
host: ExecCommandHostResponse;
|
||||
host: ExecHostLogQueryResponse;
|
||||
appender: ILogAppender
|
||||
}>();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { VNodeRef } from 'vue';
|
||||
import type { ExecCommandResponse } from '@/api/exec/exec';
|
||||
import type { ExecLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import type { LogDomRef, ILogAppender } from './const';
|
||||
import { nextTick, onBeforeMount, ref, watch } from 'vue';
|
||||
import LogAppender from './log-appender';
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
const props = defineProps<{
|
||||
current: number;
|
||||
command: ExecCommandResponse;
|
||||
command: ExecLogQueryResponse;
|
||||
}>();
|
||||
|
||||
const logRefs = ref<Array<LogDomRef>>([]);
|
||||
|
||||
Reference in New Issue
Block a user