feat(remote): 优化日志独立滚动与自动跟随
This commit is contained in:
@@ -301,6 +301,8 @@ https://control.example.com
|
|||||||
- 按实例筛选。
|
- 按实例筛选。
|
||||||
- 按运行筛选。
|
- 按运行筛选。
|
||||||
- 按实例名、账号或正文过滤。
|
- 按实例名、账号或正文过滤。
|
||||||
|
- 日志区域独立滚动,不带动整页或机器列表。
|
||||||
|
- “自动滚动”开关控制新日志到达时是否跟随到底部,选择保存在浏览器本地。
|
||||||
- 恢复全部日志。
|
- 恢复全部日志。
|
||||||
- 清空当前浏览器显示,不删除服务端数据。
|
- 清空当前浏览器显示,不删除服务端数据。
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,13 @@
|
|||||||
color: #e9eef4;
|
color: #e9eef4;
|
||||||
}
|
}
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
body { margin: 0; background: #111418; }
|
html, body { height: 100%; }
|
||||||
|
body { margin: 0; overflow: hidden; background: #111418; }
|
||||||
button, input { font: inherit; }
|
button, input { font: inherit; }
|
||||||
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
|
.shell {
|
||||||
|
height: 100vh; min-height: 0; overflow: hidden;
|
||||||
|
display: grid; grid-template-rows: auto minmax(0, 1fr);
|
||||||
|
}
|
||||||
header {
|
header {
|
||||||
display: flex; align-items: center; gap: 16px; padding: 14px 20px;
|
display: flex; align-items: center; gap: 16px; padding: 14px 20px;
|
||||||
border-bottom: 1px solid #2a3038; background: #171b20;
|
border-bottom: 1px solid #2a3038; background: #171b20;
|
||||||
@@ -40,7 +44,7 @@
|
|||||||
.danger { border-color: #74434a; background: #3a2428; }
|
.danger { border-color: #74434a; background: #3a2428; }
|
||||||
main {
|
main {
|
||||||
display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(440px, .8fr);
|
display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(440px, .8fr);
|
||||||
gap: 14px; padding: 14px; min-height: 0;
|
gap: 14px; padding: 14px; min-height: 0; overflow: hidden;
|
||||||
}
|
}
|
||||||
.panel {
|
.panel {
|
||||||
min-height: 0; border: 1px solid #2a3038; background: #171b20;
|
min-height: 0; border: 1px solid #2a3038; background: #171b20;
|
||||||
@@ -51,12 +55,12 @@
|
|||||||
border-bottom: 1px solid #2a3038;
|
border-bottom: 1px solid #2a3038;
|
||||||
}
|
}
|
||||||
.panel-head strong { font-size: 14px; }
|
.panel-head strong { font-size: 14px; }
|
||||||
.machines { overflow: auto; padding: 10px; }
|
.machines { flex: 1; min-height: 0; overflow: auto; padding: 10px; }
|
||||||
.subhead {
|
.subhead {
|
||||||
padding: 9px 14px; border-top: 1px solid #2a3038; border-bottom: 1px solid #2a3038;
|
padding: 9px 14px; border-top: 1px solid #2a3038; border-bottom: 1px solid #2a3038;
|
||||||
background: #1c2229; font-size: 13px; font-weight: 600;
|
background: #1c2229; font-size: 13px; font-weight: 600;
|
||||||
}
|
}
|
||||||
.runs { overflow: auto; max-height: 230px; padding: 4px 12px 10px; }
|
.runs { flex: 0 1 230px; min-height: 90px; overflow: auto; padding: 4px 12px 10px; }
|
||||||
.run {
|
.run {
|
||||||
display: grid; grid-template-columns: 72px 1fr 160px 72px;
|
display: grid; grid-template-columns: 72px 1fr 160px 72px;
|
||||||
gap: 10px; padding: 7px 0; border-bottom: 1px solid #232a32; font-size: 12px;
|
gap: 10px; padding: 7px 0; border-bottom: 1px solid #232a32; font-size: 12px;
|
||||||
@@ -104,12 +108,17 @@
|
|||||||
.logs-panel { min-width: 0; }
|
.logs-panel { min-width: 0; }
|
||||||
.log-filter { display: flex; gap: 8px; align-items: center; }
|
.log-filter { display: flex; gap: 8px; align-items: center; }
|
||||||
.log-filter input { width: 180px; }
|
.log-filter input { width: 180px; }
|
||||||
|
.auto-scroll {
|
||||||
|
display: inline-flex; align-items: center; gap: 5px;
|
||||||
|
color: #9dabba; font-size: 12px; white-space: nowrap;
|
||||||
|
}
|
||||||
|
.auto-scroll input { width: auto; }
|
||||||
.log-scope {
|
.log-scope {
|
||||||
padding: 4px 8px; border: 1px solid #35404c; border-radius: 999px;
|
padding: 4px 8px; border: 1px solid #35404c; border-radius: 999px;
|
||||||
color: #9dabba; font-size: 11px; white-space: nowrap;
|
color: #9dabba; font-size: 11px; white-space: nowrap;
|
||||||
}
|
}
|
||||||
#logs {
|
#logs {
|
||||||
overflow: auto; flex: 1; padding: 8px 0;
|
overflow: auto; flex: 1; min-height: 0; padding: 8px 0; overscroll-behavior: contain;
|
||||||
font-family: "Cascadia Mono", "Consolas", monospace; font-size: 12px;
|
font-family: "Cascadia Mono", "Consolas", monospace; font-size: 12px;
|
||||||
}
|
}
|
||||||
.log {
|
.log {
|
||||||
@@ -124,8 +133,13 @@
|
|||||||
.level-success { color: #59d19b; }
|
.level-success { color: #59d19b; }
|
||||||
.empty { padding: 24px; text-align: center; color: #778493; }
|
.empty { padding: 24px; text-align: center; color: #778493; }
|
||||||
@media (max-width: 980px) {
|
@media (max-width: 980px) {
|
||||||
main { grid-template-columns: 1fr; }
|
body { overflow: auto; }
|
||||||
.logs-panel { min-height: 52vh; }
|
.shell { height: auto; min-height: 100vh; overflow: visible; }
|
||||||
|
main {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
grid-template-rows: minmax(360px, 48vh) minmax(360px, 52vh);
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
.instance { grid-template-columns: 1fr 1fr; }
|
.instance { grid-template-columns: 1fr 1fr; }
|
||||||
.actions { justify-content: flex-start; }
|
.actions { justify-content: flex-start; }
|
||||||
.token-box input { width: 180px; }
|
.token-box input { width: 180px; }
|
||||||
@@ -164,6 +178,10 @@
|
|||||||
<button id="scope-clear">全部日志</button>
|
<button id="scope-clear">全部日志</button>
|
||||||
<button id="export-csv">导出当前 CSV</button>
|
<button id="export-csv">导出当前 CSV</button>
|
||||||
<button id="export-json">导出当前 JSON</button>
|
<button id="export-json">导出当前 JSON</button>
|
||||||
|
<label class="auto-scroll" title="新日志到达时自动滚动到底部">
|
||||||
|
<input id="auto-scroll" type="checkbox">
|
||||||
|
自动滚动
|
||||||
|
</label>
|
||||||
<button id="clear">清空</button>
|
<button id="clear">清空</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -181,6 +199,7 @@
|
|||||||
const summary = document.getElementById('summary');
|
const summary = document.getElementById('summary');
|
||||||
const logsRoot = document.getElementById('logs');
|
const logsRoot = document.getElementById('logs');
|
||||||
const filterInput = document.getElementById('filter');
|
const filterInput = document.getElementById('filter');
|
||||||
|
const autoScrollInput = document.getElementById('auto-scroll');
|
||||||
const clearButton = document.getElementById('clear');
|
const clearButton = document.getElementById('clear');
|
||||||
const scopeLabel = document.getElementById('log-scope');
|
const scopeLabel = document.getElementById('log-scope');
|
||||||
const scopeClearButton = document.getElementById('scope-clear');
|
const scopeClearButton = document.getElementById('scope-clear');
|
||||||
@@ -196,6 +215,7 @@
|
|||||||
const logs = [];
|
const logs = [];
|
||||||
|
|
||||||
tokenInput.value = token;
|
tokenInput.value = token;
|
||||||
|
autoScrollInput.checked = localStorage.getItem('douyu-control-auto-scroll') !== 'false';
|
||||||
if (bootstrapToken) {
|
if (bootstrapToken) {
|
||||||
localStorage.setItem('douyu-control-token', bootstrapToken);
|
localStorage.setItem('douyu-control-token', bootstrapToken);
|
||||||
history.replaceState(null, '', location.pathname + location.search);
|
history.replaceState(null, '', location.pathname + location.search);
|
||||||
@@ -212,6 +232,12 @@
|
|||||||
logs.length = 0;
|
logs.length = 0;
|
||||||
renderLogs();
|
renderLogs();
|
||||||
});
|
});
|
||||||
|
autoScrollInput.addEventListener('change', () => {
|
||||||
|
localStorage.setItem('douyu-control-auto-scroll', String(autoScrollInput.checked));
|
||||||
|
if (autoScrollInput.checked) {
|
||||||
|
logsRoot.scrollTop = logsRoot.scrollHeight;
|
||||||
|
}
|
||||||
|
});
|
||||||
scopeClearButton.addEventListener('click', () => selectScope('', '', '', '全部实例'));
|
scopeClearButton.addEventListener('click', () => selectScope('', '', '', '全部实例'));
|
||||||
exportCsvButton.addEventListener('click', () => exportLogs('csv'));
|
exportCsvButton.addEventListener('click', () => exportLogs('csv'));
|
||||||
exportJsonButton.addEventListener('click', () => exportLogs('json'));
|
exportJsonButton.addEventListener('click', () => exportLogs('json'));
|
||||||
@@ -546,6 +572,7 @@
|
|||||||
|
|
||||||
function renderLogs() {
|
function renderLogs() {
|
||||||
const filter = filterInput.value.trim().toLowerCase();
|
const filter = filterInput.value.trim().toLowerCase();
|
||||||
|
const previousScrollTop = logsRoot.scrollTop;
|
||||||
logsRoot.replaceChildren();
|
logsRoot.replaceChildren();
|
||||||
const visible = logs.filter(event => {
|
const visible = logs.filter(event => {
|
||||||
if (!filter) return true;
|
if (!filter) return true;
|
||||||
@@ -565,7 +592,11 @@
|
|||||||
);
|
);
|
||||||
logsRoot.append(row);
|
logsRoot.append(row);
|
||||||
}
|
}
|
||||||
logsRoot.scrollTop = logsRoot.scrollHeight;
|
if (autoScrollInput.checked) {
|
||||||
|
logsRoot.scrollTop = logsRoot.scrollHeight;
|
||||||
|
} else {
|
||||||
|
logsRoot.scrollTop = previousScrollTop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function element(tag, className = '', text = '') {
|
function element(tag, className = '', text = '') {
|
||||||
|
|||||||
Reference in New Issue
Block a user