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

@@ -0,0 +1,27 @@
export const DEFAULT_FONT_SIZE = 10;
export const MIN_FONT_SIZE = 8;
export const MAX_FONT_SIZE = 32;
export const FONT_SIZE_KEY = 'kanban.terminalFontSize';
export function validatedFontSize(value) {
const size = Number(value);
return Number.isInteger(size) && size >= MIN_FONT_SIZE && size <= MAX_FONT_SIZE
? size : DEFAULT_FONT_SIZE;
}
export function readFontSize(storage) {
try {
return validatedFontSize((storage ?? globalThis.localStorage).getItem(FONT_SIZE_KEY));
} catch {
return DEFAULT_FONT_SIZE;
}
}
export function saveFontSize(value, storage) {
try {
(storage ?? globalThis.localStorage).setItem(FONT_SIZE_KEY, String(validatedFontSize(value)));
return true;
} catch {
return false;
}
}