1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

feat(task): fix Issue Where Task Logs Continue Periodic Requests After Being Opened (#7567)

This commit is contained in:
zhengkunwang 2024-12-26 10:18:47 +08:00 committed by GitHub
parent 4a4e568d4a
commit 008c369a9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 18 deletions

View File

@ -45,7 +45,7 @@ var WebUrlMap = map[string]struct{}{
"/apps/all": {}, "/apps/all": {},
"/apps/installed": {}, "/apps/installed": {},
"/apps/upgrade": {}, "/apps/upgrade": {},
"apps/setting": {}, "/apps/setting": {},
"/containers": {}, "/containers": {},
"/containers/container": {}, "/containers/container": {},
@ -56,7 +56,7 @@ var WebUrlMap = map[string]struct{}{
"/containers/compose": {}, "/containers/compose": {},
"/containers/template": {}, "/containers/template": {},
"/containers/setting": {}, "/containers/setting": {},
"containers/dashboard": {}, "/containers/dashboard": {},
"/cronjobs": {}, "/cronjobs": {},
@ -88,6 +88,7 @@ var WebUrlMap = map[string]struct{}{
"/logs/website": {}, "/logs/website": {},
"/logs/system": {}, "/logs/system": {},
"/logs/ssh": {}, "/logs/ssh": {},
"/logs/task": {},
"/settings": {}, "/settings": {},
"/settings/panel": {}, "/settings/panel": {},
@ -134,8 +135,8 @@ var WebUrlMap = map[string]struct{}{
"/xpack/alert/log": {}, "/xpack/alert/log": {},
"/xpack/alert/setting": {}, "/xpack/alert/setting": {},
"/xpack/setting": {}, "/xpack/setting": {},
"xpack/node": {}, "/xpack/node": {},
"xpack/waf/stat": {}, "/xpack/waf/stat": {},
} }
var DynamicRoutes = []string{ var DynamicRoutes = []string{

View File

@ -26,5 +26,5 @@ export const searchTasks = (req: Log.SearchTaskReq) => {
}; };
export const countExecutingTask = () => { export const countExecutingTask = () => {
return http.get<number>(`/tasks/executing/count`); return http.get<number>(`/logs/tasks/executing/count`);
}; };

View File

@ -1,5 +1,5 @@
<template> <template>
<div v-loading="isLoading"> <div v-loading="initLog && isLoading">
<div v-if="defaultButton"> <div v-if="defaultButton">
<el-checkbox border v-model="tailLog" class="float-left" @change="changeTail(false)"> <el-checkbox border v-model="tailLog" class="float-left" @change="changeTail(false)">
{{ $t('commons.button.watch') }} {{ $t('commons.button.watch') }}
@ -94,6 +94,7 @@ const maxPage = ref(0);
const minPage = ref(0); const minPage = ref(0);
let timer: NodeJS.Timer | null = null; let timer: NodeJS.Timer | null = null;
const logPath = ref(''); const logPath = ref('');
const initLog = ref(false);
const firstLoading = ref(false); const firstLoading = ref(false);
const logs = ref<string[]>([]); const logs = ref<string[]>([]);
@ -213,6 +214,7 @@ const getContent = async (pre: boolean) => {
} }
nextTick(() => { nextTick(() => {
console.log('pre', pre);
if (pre) { if (pre) {
logContainer.value.scrollTop = 2000; logContainer.value.scrollTop = 2000;
} else { } else {
@ -249,10 +251,14 @@ const getContent = async (pre: boolean) => {
const onCloseLog = async () => { const onCloseLog = async () => {
tailLog.value = false; tailLog.value = false;
clearInterval(Number(timer)); if (timer) {
clearInterval(Number(timer));
timer = null;
}
timer = null; timer = null;
isLoading.value = false; isLoading.value = false;
emit('update:isReading', false); emit('update:isReading', false);
initLog.value = false;
}; };
watch( watch(
@ -263,6 +269,7 @@ watch(
); );
const init = async () => { const init = async () => {
initLog.value = true;
if (props.config.tail) { if (props.config.tail) {
tailLog.value = props.config.tail; tailLog.value = props.config.tail;
} else { } else {
@ -287,20 +294,10 @@ onMounted(async () => {
}); });
onUnmounted(() => { onUnmounted(() => {
console.log('onUnmounted');
onCloseLog(); onCloseLog();
}); });
onMounted(async () => {
firstLoading.value = true;
await init();
nextTick(() => {
if (logContainer.value) {
logContainer.value.scrollTop = totalHeight.value;
containerHeight.value = logContainer.value.getBoundingClientRect().height;
}
});
});
defineExpose({ changeTail, onDownload, clearLog }); defineExpose({ changeTail, onDownload, clearLog });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -25,6 +25,10 @@ defineProps({
type: String, type: String,
default: '30%', default: '30%',
}, },
tail: {
type: Boolean,
default: true,
},
}); });
const config = reactive({ const config = reactive({
@ -33,6 +37,7 @@ const config = reactive({
taskOperate: '', taskOperate: '',
resourceID: 0, resourceID: 0,
taskType: '', taskType: '',
tail: true,
}); });
const open = ref(false); const open = ref(false);