feat: 新增界面整体缩放与字体超大档,修复设置页溢出

- 界面缩放:Electron webContents.setZoomFactor,档位 90%/100%/110%/125%/150%
  - 主进程新增 set-zoom-factor IPC,启动时从 window-state.json 恢复 zoomFactor
  - 窗口尺寸保存与退出前均持久化当前 zoom
  - displaySettings 新增 UiScaleOption + initUiScale,App.vue 启动恢复
  - SettingsModal 新增「界面缩放」卡片,实时经 IPC 应用并持久化
- 字体大小新增「超大」档(html font-size 20px),共 5 档
- 修复设置模态框在字体/界面放大后内容超出视口:面板限制
  max-h-[calc(100vh-2rem)],内容区 flex-1 overflow-y-auto 滚动
This commit is contained in:
xiyidaiwa
2026-08-17 23:40:23 +08:00
parent 7b658e9dd1
commit e25a3c9d8f
5 changed files with 191 additions and 7 deletions
+75 -3
View File
@@ -13,7 +13,7 @@
@click.self="closeModal"
>
<div
class="relative w-full max-w-md overflow-hidden rounded-3xl border border-white/10 bg-white/95 shadow-2xl dark:border-slate-800 dark:bg-slate-900"
class="relative flex max-h-[calc(100vh-2rem)] w-full max-w-md flex-col overflow-hidden rounded-3xl border border-white/10 bg-white/95 shadow-2xl dark:border-slate-800 dark:bg-slate-900"
>
<!-- 标题栏 -->
<div
@@ -35,8 +35,8 @@
</button>
</div>
<!-- 设置内容 -->
<div class="p-6 space-y-4">
<!-- 设置内容可滚动标题/底部固定 -->
<div class="flex-1 overflow-y-auto p-6 space-y-4">
<!-- 更新检测开关 -->
<div
class="flex items-center justify-between rounded-2xl border border-slate-200/60 bg-slate-50/50 px-4 py-4 dark:border-slate-800/60 dark:bg-slate-800/50"
@@ -213,6 +213,51 @@
</div>
</div>
</div>
<!-- 界面缩放整体缩放图标 / 间距 / 布局等比变化 -->
<div
class="rounded-2xl border border-slate-200/60 bg-slate-50/50 px-4 py-4 dark:border-slate-800/60 dark:bg-slate-800/50"
>
<div class="flex items-start gap-3">
<div
class="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-teal-100 text-teal-600 dark:bg-teal-900/30 dark:text-teal-400"
>
<i class="fas fa-search-plus"></i>
</div>
<div class="min-w-0 flex-1">
<p
class="text-sm font-medium text-slate-800 dark:text-slate-200"
>
界面缩放
</p>
<p class="text-xs text-slate-500 dark:text-slate-400">
整体放大或缩小界面图标间距布局等比变化
</p>
<div
class="mt-3 inline-flex w-full overflow-hidden rounded-lg border border-slate-200 dark:border-slate-700"
role="radiogroup"
aria-label="界面缩放"
>
<button
v-for="opt in uiScaleOptions"
:key="opt.value"
type="button"
role="radio"
:aria-checked="uiScale === opt.value"
class="flex-1 px-2 py-1.5 text-xs font-medium transition-colors"
:class="
uiScale === opt.value
? 'bg-brand text-white'
: 'bg-white text-slate-500 hover:bg-slate-100 dark:bg-slate-700 dark:text-slate-400 dark:hover:bg-slate-600'
"
@click="selectUiScale(opt.value)"
>
{{ opt.label }}
</button>
</div>
</div>
</div>
</div>
</div>
<!-- 底部提示 -->
@@ -240,6 +285,11 @@ import {
setFontSize,
FONT_SIZE_OPTIONS,
type FontSizeOption,
getUiScale,
setUiScale,
uiScaleToFactor,
UI_SCALE_OPTIONS,
type UiScaleOption,
} from "../global/displaySettings";
const props = defineProps<{
@@ -265,6 +315,9 @@ const strategyOptions: Array<{ value: TagPriorityStrategy; label: string }> = [
// 字体大小档位选项(小 / 标准 / 大 / 特大)
const fontSizeOptions = FONT_SIZE_OPTIONS;
// 界面缩放档位选项(90% / 100% / 110% / 125% / 150%
const uiScaleOptions = UI_SCALE_OPTIONS;
const tagPriorityStrategy = ref<TagPriorityStrategy>("auto");
// 加载标签优先显示策略(从持久化读取)
@@ -291,6 +344,24 @@ const selectFontSize = (value: FontSizeOption) => {
setFontSize(value);
};
// 界面整体缩放档位(Electron setZoomFactor,连图标/间距/布局等比变化)
const uiScale = ref<UiScaleOption>("100");
const loadUiScale = () => {
uiScale.value = getUiScale();
};
// 选择并保存界面缩放档位(立即经 IPC 应用到主窗口)
const selectUiScale = async (value: UiScaleOption) => {
uiScale.value = value;
setUiScale(value);
try {
await window.ipcRenderer.invoke("set-zoom-factor", uiScaleToFactor(value));
} catch (error) {
console.error("应用界面缩放失败:", error);
}
};
const settings = ref<Settings>({
enableUpdateCheck: true,
enableCreateDesktop: true,
@@ -352,6 +423,7 @@ watch(
loadSettings();
loadTagPriority();
loadFontSize();
loadUiScale();
}
},
);