🐛 fix(window): 适配分辨率变化后的窗口边界

- 运行期检测普通窗口是否超出当前可用屏幕并自动收回
- 启动恢复时同步裁剪超过当前屏幕的窗口尺寸

Fixes #594
This commit is contained in:
Syngnat
2026-06-27 11:17:42 +08:00
parent bfb61c8449
commit 080ae0986a
4 changed files with 156 additions and 13 deletions

View File

@@ -23,4 +23,18 @@ describe('windowRestoreBounds', () => {
{ availWidth: 1600, availHeight: 900, availLeft: 0, availTop: 0 },
)).toEqual({ width: 900, height: 640, x: 350, y: 130 });
});
it('shrinks a restored window that is larger than the current visible screen', () => {
expect(resolveVisibleStartupWindowBounds(
{ width: 2560, height: 1440, x: 0, y: 0 },
{ availWidth: 1440, availHeight: 860, availLeft: 0, availTop: 25 },
)).toEqual({ width: 1440, height: 860, x: 0, y: 25 });
});
it('keeps oversized restored bounds inside an offset visible screen', () => {
expect(resolveVisibleStartupWindowBounds(
{ width: 2400, height: 1200, x: 1800, y: 60 },
{ availWidth: 1728, availHeight: 1040, availLeft: 1728, availTop: 40 },
)).toEqual({ width: 1728, height: 1040, x: 1728, y: 40 });
});
});