11<template >
22 <DrawerPro
33 v-model =" open"
4- :header =" title "
4+ :header =" $t('website.source') "
55 @close =" handleClose"
66 :size =" globalStore.isFullScreen ? 'full' : 'large'"
77 :fullScreen =" true"
88 >
99 <template #content >
10- <div v-if =" req.file != 'config'" >
11- <el-tabs v-model =" req.file" type =" card" @tab-click =" handleChange" >
12- <el-tab-pane :label =" $t('logs.runLog')" name =" out.log" ></el-tab-pane >
13- <el-tab-pane :label =" $t('logs.errLog')" name =" err.log" ></el-tab-pane >
14- </el-tabs >
15- <el-checkbox border v-model =" tailLog" class =" float-left" @change =" changeTail" >
16- {{ $t('commons.button.watch') }}
17- </el-checkbox >
18- <el-button class =" ml-5" @click =" cleanLog" icon =" Delete" >
19- {{ $t('commons.button.clean') }}
20- </el-button >
21- </div >
22- <br />
2310 <div v-loading =" loading" >
2411 <CodemirrorPro class =" mt-5" v-model =" content" :heightDiff =" 400" ></CodemirrorPro >
2512 </div >
2815 <template #footer >
2916 <span >
3017 <el-button @click =" handleClose" :disabled =" loading" >{{ $t('commons.button.cancel') }}</el-button >
31- <el-button type =" primary" :disabled =" loading" @click =" submit()" v-if = " req.file === 'config' " >
18+ <el-button type =" primary" :disabled =" loading" @click =" submit()" >
3219 {{ $t('commons.button.confirm') }}
3320 </el-button >
3421 </span >
3522 </template >
3623 </DrawerPro >
37- <OpDialog ref =" opRef" @search =" getContent" />
3824</template >
3925<script lang="ts" setup>
4026import { onUnmounted , reactive , ref } from ' vue' ;
4127import { operateSupervisorProcessFile } from ' @/api/modules/host-tool' ;
4228import i18n from ' @/lang' ;
43- import { TabsPaneContext } from ' element-plus' ;
4429import { MsgSuccess } from ' @/utils/message' ;
4530import { GlobalStore } from ' @/store' ;
4631const globalStore = GlobalStore ();
@@ -55,10 +40,6 @@ const req = reactive({
5540 operate: ' ' ,
5641 content: ' ' ,
5742});
58- const title = ref (' ' );
59- const opRef = ref ();
60-
61- let timer: NodeJS .Timer | null = null ;
6243
6344const em = defineEmits ([' search' ]);
6445
@@ -73,21 +54,6 @@ const getContent = () => {
7354 });
7455};
7556
76- const handleChange = (tab : TabsPaneContext ) => {
77- req .file = tab .props .name .toString ();
78- getContent ();
79- };
80-
81- const changeTail = () => {
82- if (tailLog .value ) {
83- timer = setInterval (() => {
84- getContent ();
85- }, 1000 * 5 );
86- } else {
87- onCloseLog ();
88- }
89- };
90-
9157const handleClose = () => {
9258 content .value = ' ' ;
9359 open .value = false ;
@@ -117,26 +83,12 @@ const acceptParams = (name: string, file: string, operate: string) => {
11783 req .file = file ;
11884 req .operate = operate ;
11985
120- title .value = file == ' config' ? i18n .global .t (' website.source' ) : i18n .global .t (' commons.button.log' );
12186 getContent ();
12287 open .value = true ;
12388};
12489
125- const cleanLog = async () => {
126- let log = req .file === ' out.log' ? i18n .global .t (' logs.runLog' ) : i18n .global .t (' logs.errLog' );
127- opRef .value .acceptParams ({
128- title: i18n .global .t (' commons.button.clean' ),
129- names: [req .name ],
130- msg: i18n .global .t (' commons.msg.operatorHelper' , [log , i18n .global .t (' commons.button.clean' )]),
131- api: operateSupervisorProcessFile ,
132- params: { name: req .name , operate: ' clear' , file: req .file },
133- });
134- };
135-
13690const onCloseLog = async () => {
13791 tailLog .value = false ;
138- clearInterval (Number (timer ));
139- timer = null ;
14092};
14193
14294onUnmounted (() => {
0 commit comments