🐛 fix(window): 修复 Windows 恢复窗口后字体缩放异常

- 记录最小化和隐藏状态以识别任务栏恢复场景

- 恢复窗口时使用 restore 缩放修复路径校正 viewport drift

- 增加任务栏恢复窗口缩放逻辑测试
This commit is contained in:
Syngnat
2026-05-12 21:47:24 +08:00
parent 10a695ba0f
commit 0fea730908
3 changed files with 53 additions and 7 deletions

View File

@@ -17,6 +17,12 @@ describe('windowStateUi', () => {
expect(shouldApplyWindowsScaleFix('ratio-change', true)).toBe(true);
});
it('applies the Windows scale fix when a minimized taskbar window is restored with viewport drift', () => {
expect(shouldApplyWindowsScaleFix('restore', true)).toBe(true);
expect(shouldApplyWindowsScaleFix('restore', false)).toBe(false);
expect(shouldToggleMaximisedWindowForScaleFix('restore', true)).toBe(true);
});
it('debounces resize-triggered Windows scale checks until window transitions settle', () => {
expect(resolveWindowsScaleCheckDelayMs('resize')).toBeGreaterThan(0);
expect(resolveWindowsScaleCheckDelayMs('focus')).toBe(0);

View File

@@ -1,12 +1,12 @@
export type WindowVisualState = 'normal' | 'maximized' | 'fullscreen';
export type WindowScaleFixReason = 'activation' | 'ratio-change';
export type WindowScaleFixReason = 'activation' | 'ratio-change' | 'restore';
export type WindowsScaleCheckTrigger = 'focus' | 'pageshow' | 'poll' | 'resize' | 'visibilitychange';
export type TitleBarToggleIconKey = 'maximize' | 'restore';
export const shouldApplyWindowsScaleFix = (
reason: WindowScaleFixReason,
hasViewportScaleDrift: boolean,
): boolean => reason === 'ratio-change' && hasViewportScaleDrift;
): boolean => (reason === 'ratio-change' || reason === 'restore') && hasViewportScaleDrift;
export const shouldToggleMaximisedWindowForScaleFix = shouldApplyWindowsScaleFix;