feat(terminal): add persistent browser font size controls

This commit is contained in:
2026-10-03 16:10:42 +08:00
parent 298a3c8a58
commit a8afaf3b80
8 changed files with 178 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
import { MIN_FONT_SIZE, MAX_FONT_SIZE, FONT_SIZE_KEY, readFontSize, saveFontSize } from './terminal-preferences.js';
let state = {
gpus: [],
liveAgents: { ok: false, agents: [] },
@@ -342,5 +344,17 @@ $('liveAgentForm').addEventListener('submit', async (event) => {
}
});
const terminalFontSize = $('terminalFontSize');
for (let size = MIN_FONT_SIZE; size <= MAX_FONT_SIZE; size++) {
terminalFontSize.add(new Option(`${size} px`, String(size)));
}
terminalFontSize.value = String(readFontSize());
terminalFontSize.addEventListener('change', () => {
if (!saveFontSize(terminalFontSize.value)) toast('无法保存终端字号,请允许浏览器存储设置。', 'error');
});
window.addEventListener('storage', (event) => {
if (event.key === FONT_SIZE_KEY || event.key === null) terminalFontSize.value = String(readFontSize());
});
refresh();
setInterval(refresh, 60000);