mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-11 03:38:02 +00:00
27 lines
770 B
TypeScript
27 lines
770 B
TypeScript
export const setTextScale = (scale: number) => {
|
|
if (typeof document === 'undefined') {
|
|
return;
|
|
}
|
|
|
|
document.documentElement.style.setProperty('--app-text-scale', `${scale}`);
|
|
};
|
|
|
|
export const normalizeAppFontFamily = (fontFamily?: string | null) =>
|
|
typeof fontFamily === 'string' ? fontFamily.trim().replace(/[\u0000-\u001f\u007f]/g, '') : '';
|
|
|
|
export const setAppFontFamily = (fontFamily?: string | null) => {
|
|
if (typeof document === 'undefined') {
|
|
return;
|
|
}
|
|
|
|
const normalized = normalizeAppFontFamily(fontFamily);
|
|
if (!normalized) {
|
|
document.documentElement.style.removeProperty('--app-font-family');
|
|
return;
|
|
}
|
|
|
|
document.documentElement.style.setProperty(
|
|
'--app-font-family',
|
|
`"${normalized.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`
|
|
);
|
|
};
|