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