core: 修复 wget 换行符为 \r 导致 html 日志不换行

This commit is contained in:
bin456789 2023-11-06 19:08:23 +08:00
parent db94e18bb3
commit ea89d61b86
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -11,10 +11,9 @@
}
#log-container {
height: calc(100vh - 20px);
padding: 10px;
height: calc(100vh - 24px);
padding: 12px;
overflow-y: scroll;
white-space: pre;
}
#scroll-to-bottom {
@ -38,7 +37,7 @@
</head>
<body>
<div id="log-container"></div>
<pre id="log-container"></pre>
<button id="scroll-to-bottom">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M5 10l7 7 7-7H5z" />
@ -59,7 +58,8 @@
if (response.ok) {
const logContent = await response.text();
logContainer.textContent = logContent;
// 修复 wget 换行符为 \r 导致不换行
logContainer.textContent = logContent.replace(/[\r\n]+/g, "\n");;
if (shouldScrollToBottom) {
logContainer.scrollTop = logContainer.scrollHeight;