mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
修改任务日志自动滚动逻辑
This commit is contained in:
parent
518436d5ca
commit
0144f3b131
|
@ -1,4 +1,4 @@
|
||||||
export const LOG_END_SYMBOL = '\n ';
|
export const LOG_END_SYMBOL = ' ';
|
||||||
|
|
||||||
export const TASK_COMMAND = 'task';
|
export const TASK_COMMAND = 'task';
|
||||||
export const QL_COMMAND = 'ql';
|
export const QL_COMMAND = 'ql';
|
||||||
|
|
|
@ -124,8 +124,7 @@ handle_task_after() {
|
||||||
local end_timestamp=$(format_timestamp "$time_format" "$etime")
|
local end_timestamp=$(format_timestamp "$time_format" "$etime")
|
||||||
local diff_time=$(($end_timestamp - $begin_timestamp))
|
local diff_time=$(($end_timestamp - $begin_timestamp))
|
||||||
|
|
||||||
echo -e "\n\n## 执行结束... $end_time 耗时 $diff_time 秒"
|
echo -e "\n\n## 执行结束... $end_time 耗时 $diff_time 秒 "
|
||||||
echo -e "\n "
|
|
||||||
|
|
||||||
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,8 +499,7 @@ main() {
|
||||||
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
||||||
|
|
||||||
if [[ "$p1" != "repo" ]] && [[ "$p1" != "raw" ]]; then
|
if [[ "$p1" != "repo" ]] && [[ "$p1" != "raw" ]]; then
|
||||||
eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒" $cmd
|
eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒 " $cmd
|
||||||
eval echo -e "\\\n " $cmd
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f $file_path ]]; then
|
if [[ -f $file_path ]]; then
|
||||||
|
|
|
@ -179,3 +179,15 @@ tr.drop-over-upward td {
|
||||||
margin-left: 40px;
|
margin-left: 40px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.log-modal {
|
||||||
|
.log-container {
|
||||||
|
overflow-y: auto;
|
||||||
|
min-height: 300px;
|
||||||
|
max-height: calc(80vh - 110px);
|
||||||
|
max-height: calc(80vh - var(--vh-offset, 110px));
|
||||||
|
|
||||||
|
padding: 24px;
|
||||||
|
margin: -24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ const CronLogModal = ({
|
||||||
const [loading, setLoading] = useState<any>(true);
|
const [loading, setLoading] = useState<any>(true);
|
||||||
const [executing, setExecuting] = useState<any>(true);
|
const [executing, setExecuting] = useState<any>(true);
|
||||||
const [isPhone, setIsPhone] = useState(false);
|
const [isPhone, setIsPhone] = useState(false);
|
||||||
|
const scrollInfoRef = useRef({ value: 0, down: true });
|
||||||
|
|
||||||
const getCronLog = (isFirst?: boolean) => {
|
const getCronLog = (isFirst?: boolean) => {
|
||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
|
@ -44,17 +45,19 @@ const CronLogModal = ({
|
||||||
.then(({ code, data }) => {
|
.then(({ code, data }) => {
|
||||||
if (
|
if (
|
||||||
code === 200 &&
|
code === 200 &&
|
||||||
localStorage.getItem('logCron') === String(cron.id)
|
localStorage.getItem('logCron') === String(cron.id) &&
|
||||||
|
data !== value
|
||||||
) {
|
) {
|
||||||
const log = data as string;
|
const log = data as string;
|
||||||
setValue(log || '暂无日志');
|
setValue(log || '暂无日志');
|
||||||
const hasNext = log && !logEnded(log) && !log.includes('重启面板') && !log.includes('任务未运行或运行失败,请尝试手动运行');
|
const hasNext = Boolean(
|
||||||
|
log &&
|
||||||
|
!logEnded(log) &&
|
||||||
|
!log.includes('重启面板') &&
|
||||||
|
!log.includes('任务未运行或运行失败,请尝试手动运行'),
|
||||||
|
);
|
||||||
setExecuting(hasNext);
|
setExecuting(hasNext);
|
||||||
setTimeout(() => {
|
autoScroll();
|
||||||
document
|
|
||||||
.querySelector('#log-flag')!
|
|
||||||
.scrollIntoView({ behavior: 'smooth' });
|
|
||||||
}, 1000);
|
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getCronLog();
|
getCronLog();
|
||||||
|
@ -92,11 +95,33 @@ const CronLogModal = ({
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const autoScroll = () => {
|
||||||
|
if (!scrollInfoRef.current.down) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
document
|
||||||
|
.querySelector('#log-flag')!
|
||||||
|
.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
localStorage.removeItem('logCron');
|
localStorage.removeItem('logCron');
|
||||||
handleCancel();
|
handleCancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleScroll = (e) => {
|
||||||
|
const sTop = e.target.scrollTop;
|
||||||
|
if (scrollInfoRef.current.down) {
|
||||||
|
scrollInfoRef.current = {
|
||||||
|
value: sTop,
|
||||||
|
down: sTop > scrollInfoRef.current.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const titleElement = () => {
|
const titleElement = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -141,6 +166,7 @@ const CronLogModal = ({
|
||||||
</Button>,
|
</Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
<div onScroll={handleScroll} className="log-container">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<PageLoading />
|
<PageLoading />
|
||||||
) : (
|
) : (
|
||||||
|
@ -159,6 +185,7 @@ const CronLogModal = ({
|
||||||
</pre>
|
</pre>
|
||||||
)}
|
)}
|
||||||
<div id="log-flag"></div>
|
<div id="log-flag"></div>
|
||||||
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export const LOG_END_SYMBOL = '\n ';
|
export const LOG_END_SYMBOL = ' ';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user