diff --git a/packages/backend/src/appearance/appearance.repository.ts b/packages/backend/src/appearance/appearance.repository.ts index 004a49e..3bfe530 100644 --- a/packages/backend/src/appearance/appearance.repository.ts +++ b/packages/backend/src/appearance/appearance.repository.ts @@ -55,6 +55,9 @@ let terminalTextStrokeEnabledFound = false; case 'editorFontSize': settings.editorFontSize = parseInt(row.value, 10); break; + case 'mobileEditorFontSize': + settings.mobileEditorFontSize = parseInt(row.value, 10); + break; case 'terminalBackgroundImage': settings.terminalBackgroundImage = row.value || undefined; break; @@ -122,6 +125,7 @@ case 'terminalTextStrokeEnabled': terminalFontSize: settings.terminalFontSize ?? defaults.terminalFontSize, terminalFontSizeMobile: settings.terminalFontSizeMobile ?? defaults.terminalFontSizeMobile, editorFontSize: settings.editorFontSize ?? defaults.editorFontSize, + mobileEditorFontSize: settings.mobileEditorFontSize ?? defaults.mobileEditorFontSize, editorFontFamily: settings.editorFontFamily ?? defaults.editorFontFamily, terminalBackgroundImage: settings.terminalBackgroundImage ?? defaults.terminalBackgroundImage, pageBackgroundImage: settings.pageBackgroundImage ?? defaults.pageBackgroundImage, @@ -172,6 +176,7 @@ const getDefaultAppearanceSettings = (): Omit => { terminalFontSize: 14, terminalFontSizeMobile: 14, // 移动端默认字体大小 editorFontSize: 14, + mobileEditorFontSize: 16, //移动端编辑器默认字体大小 editorFontFamily: 'Consolas, "Noto Sans SC", "Microsoft YaHei"', terminalBackgroundImage: undefined, pageBackgroundImage: undefined, @@ -213,6 +218,7 @@ export const ensureDefaultSettingsExist = async (db: sqlite3.Database): Promise< { key: 'terminalFontSize', value: defaults.terminalFontSize }, { key: 'terminalFontSizeMobile', value: defaults.terminalFontSizeMobile }, { key: 'editorFontSize', value: defaults.editorFontSize }, + { key: 'mobileEditorFontSize', value: defaults.mobileEditorFontSize }, { key: 'editorFontFamily', value: defaults.editorFontFamily }, { key: 'terminalBackgroundImage', value: defaults.terminalBackgroundImage ?? '' }, // 数据库中使用空字符串 { key: 'pageBackgroundImage', value: defaults.pageBackgroundImage ?? '' }, // 数据库中使用空字符串 diff --git a/packages/backend/src/appearance/appearance.service.ts b/packages/backend/src/appearance/appearance.service.ts index bc219ae..a841cb5 100644 --- a/packages/backend/src/appearance/appearance.service.ts +++ b/packages/backend/src/appearance/appearance.service.ts @@ -114,6 +114,16 @@ export const updateSettings = async (settingsDto: UpdateAppearanceDto): Promise< settingsDto.editorFontSize = size; } + // 验证 mobileEditorFontSize (如果提供了) + if (settingsDto.mobileEditorFontSize !== undefined && settingsDto.mobileEditorFontSize !== null) { + const size = Number(settingsDto.mobileEditorFontSize); + if (isNaN(size) || size <= 0) { + throw new Error(`无效的移动端编辑器字体大小: ${settingsDto.mobileEditorFontSize}。必须是一个正数。`); + } + // 确保类型正确传递给仓库层 + settingsDto.mobileEditorFontSize = size; + } + // 验证 editorFontFamily (如果提供了) if (settingsDto.hasOwnProperty('editorFontFamily')) { if (settingsDto.editorFontFamily === null) { diff --git a/packages/frontend/src/components/CodeMirrorMobileEditor.vue b/packages/frontend/src/components/CodeMirrorMobileEditor.vue index d980d97..efb8245 100644 --- a/packages/frontend/src/components/CodeMirrorMobileEditor.vue +++ b/packages/frontend/src/components/CodeMirrorMobileEditor.vue @@ -3,8 +3,9 @@