windowOptions.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import path from 'path';
  2. import { getBaseDir } from 'ee-core/ps';
  3. import type { BrowserWindowConstructorOptions } from 'electron';
  4. /**
  5. * 主窗口与智能工作台窗口共用的 webPreferences。
  6. *
  7. * 两个窗口必须一致:渲染进程目前依赖 nodeIntegration 直接 require('electron') 调 IPC,
  8. * 智能窗口若单独改成 contextIsolation,现有 preload 又没启用,行为会和主窗口不一致。
  9. */
  10. export const sharedWebPreferences = {
  11. // webSecurity: false,
  12. contextIsolation: false,
  13. nodeIntegration: true,
  14. };
  15. /** 智能工作台窗口的默认尺寸与下限(bounds 落盘恢复时也按这个下限校验) */
  16. export const smartWindowSize = {
  17. width: 1280,
  18. height: 860,
  19. minWidth: 1280,
  20. minHeight: 860,
  21. };
  22. /**
  23. * 智能工作台窗口选项。
  24. *
  25. * 刻意不设 parent:Windows 下带 parent 的子窗口会始终悬浮在主窗口之上,
  26. * 用户无法把主窗口切到前面;VS Code 的 Agents window 也是独立顶层窗口。
  27. */
  28. export function getSmartWindowOptions(): BrowserWindowConstructorOptions {
  29. return {
  30. title: '清鉴 · 智能工作台',
  31. ...smartWindowSize,
  32. webPreferences: { ...sharedWebPreferences },
  33. frame: false,
  34. show: false,
  35. backgroundColor: '#ffffff',
  36. icon: path.join(getBaseDir(), 'public', 'images', 'logo-32.png'),
  37. };
  38. }