@lynker-desktop/electron-window-manager 0.0.9-alpha.10 → 0.0.9-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common/index.d.ts CHANGED
@@ -57,5 +57,20 @@ export interface BVItem extends BrowserView {
57
57
  /** 初始化url */
58
58
  _initUrl?: string;
59
59
  }
60
+ /**
61
+ * 预加载配置接口
62
+ */
63
+ export interface PreloadWebContentsConfig {
64
+ /** 预加载的 URL */
65
+ url: string;
66
+ /** 是否预加载普通窗口 */
67
+ enableBW?: boolean;
68
+ /** 是否预加载无边框有按钮的窗口 */
69
+ enableBW_FramelessWithButtons?: boolean;
70
+ /** 是否预加载无边框无按钮的窗口 */
71
+ enableBW_FramelessNoButtons?: boolean;
72
+ /** 是否预加载浏览器视图 */
73
+ enableBV?: boolean;
74
+ }
60
75
  export {};
61
76
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAE3H,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,+BAA+B,EAAE,QAAQ,CAAC;IACxF,MAAM,CAAC,EAAE,MAAM,GAAG,+BAA+B,CAAC,QAAQ,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,6BAA6B,EAAE,QAAQ,CAAC;IACpF,MAAM,CAAC,EAAE,MAAM,GAAG,+BAA+B,CAAC,QAAQ,CAAC,CAAC;CAC7D;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,2BAA2B,CAAC,EAAE,GAAG,CAAC;KACnC;CACF;AAED,MAAM,MAAM,6BAA6B,GACrC,CAAC;IAAE,IAAI,CAAC,EAAE,IAAI,CAAC;IAAC,aA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AAS,CAAC,EAAE;QACV,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,aAAa,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC;IACpD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,MAAO,SAAQ,aAAa;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa;IACb,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,MAAO,SAAQ,WAAW;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa;IACb,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,eAAe;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,qBAAqB;IACrB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,iBAAiB;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -57,5 +57,20 @@ export interface BVItem extends BrowserView {
57
57
  /** 初始化url */
58
58
  _initUrl?: string;
59
59
  }
60
+ /**
61
+ * 预加载配置接口
62
+ */
63
+ export interface PreloadWebContentsConfig {
64
+ /** 预加载的 URL */
65
+ url: string;
66
+ /** 是否预加载普通窗口 */
67
+ enableBW?: boolean;
68
+ /** 是否预加载无边框有按钮的窗口 */
69
+ enableBW_FramelessWithButtons?: boolean;
70
+ /** 是否预加载无边框无按钮的窗口 */
71
+ enableBW_FramelessNoButtons?: boolean;
72
+ /** 是否预加载浏览器视图 */
73
+ enableBV?: boolean;
74
+ }
60
75
  export {};
61
76
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAE3H,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,+BAA+B,EAAE,QAAQ,CAAC;IACxF,MAAM,CAAC,EAAE,MAAM,GAAG,+BAA+B,CAAC,QAAQ,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,6BAA6B,EAAE,QAAQ,CAAC;IACpF,MAAM,CAAC,EAAE,MAAM,GAAG,+BAA+B,CAAC,QAAQ,CAAC,CAAC;CAC7D;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,2BAA2B,CAAC,EAAE,GAAG,CAAC;KACnC;CACF;AAED,MAAM,MAAM,6BAA6B,GACrC,CAAC;IAAE,IAAI,CAAC,EAAE,IAAI,CAAC;IAAC,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAAG,IAAI,CAAC,iCAAiC,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,GACxH,CAAC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,aAAa,CAAC,EAAE,eAAe,CAAA;CAAE,GAAG,IAAI,CAAC,iCAAiC,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC;AAE1H,UAAU,iCAAiC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG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AAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,MAAO,SAAQ,WAAW;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa;IACb,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,eAAe;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,qBAAqB;IACrB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,iBAAiB;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -1,12 +1,12 @@
1
1
  import { WebContents } from 'electron';
2
- import type { ElectronWindowsManagerOptions, BWItem, BVItem } from '../common';
2
+ import type { ElectronWindowsManagerOptions, BWItem, BVItem, PreloadWebContentsConfig } from '../common';
3
3
  export declare const getCustomSession: () => Electron.Session;
4
4
  export declare const enable: (win: WebContents) => void;
5
5
  export declare class WindowsManager {
6
6
  loadingViewUrl: string | undefined;
7
7
  errorViewUrl: string | undefined;
8
8
  preload?: string;
9
- preloadWebContentsUrl?: string;
9
+ preloadWebContentsConfig?: PreloadWebContentsConfig;
10
10
  windows: Map<number, BWItem | BVItem>;
11
11
  preloadedBW: BWItem | null;
12
12
  preloadedBW_FramelessWithButtons: BWItem | null;
@@ -32,12 +32,12 @@ export declare class WindowsManager {
32
32
  * - 不带点的(如 example.com)只匹配主域名。
33
33
  * - 'localhost'、'127.0.0.1'、'::1' 以及局域网 IP(如 192.168.x.x、10.x.x.x、172.16.x.x~172.31.x.x)都视为本地白名单。
34
34
  */
35
- constructor(preload?: string, loadingViewUrl?: string, errorViewUrl?: string, preloadWebContentsUrl?: string, webviewDomainWhiteList?: string[]);
35
+ constructor(preload?: string, loadingViewUrl?: string, errorViewUrl?: string, preloadWebContentsConfig?: PreloadWebContentsConfig, webviewDomainWhiteList?: string[]);
36
36
  /**
37
- * 设置预加载的webContents的url
38
- * @param preloadWebContentsUrl 预加载的webContents的url
37
+ * 设置预加载的webContents配置
38
+ * @param preloadWebContentsConfig 预加载的webContents配置
39
39
  */
40
- setPreloadWebContentsUrl(preloadWebContentsUrl: string): void;
40
+ setPreloadWebContentsConfig(preloadWebContentsConfig: PreloadWebContentsConfig): void;
41
41
  /**
42
42
  * 预加载实例
43
43
  */
@@ -83,5 +83,5 @@ export declare class WindowsManager {
83
83
  createPreloadWebContents(url: string): Promise<unknown>;
84
84
  }
85
85
  export declare let isInitialized: boolean;
86
- export declare const initialize: (preload?: string, loadingViewUrl?: string, errorViewUrl?: string, preloadWebContentsUrl?: string, webviewDomainWhiteList?: string[]) => WindowsManager;
86
+ export declare const initialize: (preload?: string, loadingViewUrl?: string, errorViewUrl?: string, preloadWebContentsConfig?: PreloadWebContentsConfig, webviewDomainWhiteList?: string[]) => WindowsManager;
87
87
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,WAAW,EAAiG,MAAM,UAAU,CAAA;AAItK,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE/E,eAAO,MAAM,gBAAgB,wBAQzB,CAAC;AAUL,eAAO,MAAM,MAAM,QAAS,WAAW,SAEtC,CAAA;A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AE,GAAG,OAAO,CAAC,MAAM,CAAC;IAChF,MAAM,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IAcxE;;OAEG;YACW,kBAAkB;IAsBhC;;OAEG;YACW,aAAa;IA0a3B,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,6BAA6B;IAmF5E,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS;IA6B3D,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IACvC,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAyBtC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAqC/B,QAAQ;IA0BR,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM;IAqCjD,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS;IAgB9E,UAAU;IAKV,OAAO,CAAC,0BAA0B;IAyBlC,OAAO,CAAC,wBAAwB;IAiB1B,wBAAwB,CAAC,GAAG,EAAE,MAAM;CAqB3C;AAID,eAAO,IAAI,aAAa,SAAQ,CAAC;AAEjC,eAAO,MAAM,UAAU,aAAc,MAAM,mBAAmB,MAAM,iBAAiB,MAAM,6BAA6B,wBAAwB,2BAA2B,MAAM,EAAE,KAAG,cA4QrL,CAAA"}
package/esm/main/index.js CHANGED
@@ -56,7 +56,7 @@ class WindowsManager {
56
56
  * - 不带点的(如 example.com)只匹配主域名。
57
57
  * - 'localhost'、'127.0.0.1'、'::1' 以及局域网 IP(如 192.168.x.x、10.x.x.x、172.16.x.x~172.31.x.x)都视为本地白名单。
58
58
  */
59
- constructor(preload, loadingViewUrl, errorViewUrl, preloadWebContentsUrl, webviewDomainWhiteList) {
59
+ constructor(preload, loadingViewUrl, errorViewUrl, preloadWebContentsConfig, webviewDomainWhiteList) {
60
60
  // 预加载的窗口
61
61
  this.preloadedBW = null;
62
62
  // 预加载的窗口(无边框,有按钮)
@@ -74,25 +74,25 @@ class WindowsManager {
74
74
  this.windows = new Map();
75
75
  this.loadingViewUrl = `${loadingViewUrl ?? ''}`;
76
76
  this.errorViewUrl = `${errorViewUrl ?? ''}`;
77
- this.preloadWebContentsUrl = `${preloadWebContentsUrl ?? ''}`;
77
+ this.preloadWebContentsConfig = preloadWebContentsConfig;
78
78
  this.webviewDomainWhiteList = webviewDomainWhiteList || [];
79
- log('log', 'preloadWebContentsUrl: ', this.preloadWebContentsUrl);
80
- if (this.preloadWebContentsUrl) {
79
+ log('log', 'preloadWebContentsConfig: ', this.preloadWebContentsConfig);
80
+ if (this.preloadWebContentsConfig) {
81
81
  app.on('ready', () => {
82
- if (this.preloadWebContentsUrl) {
83
- this.setPreloadWebContentsUrl(this.preloadWebContentsUrl);
82
+ if (this.preloadWebContentsConfig) {
83
+ this.setPreloadWebContentsConfig(this.preloadWebContentsConfig);
84
84
  }
85
85
  });
86
86
  }
87
87
  }
88
88
  /**
89
- * 设置预加载的webContents的url
90
- * @param preloadWebContentsUrl 预加载的webContents的url
89
+ * 设置预加载的webContents配置
90
+ * @param preloadWebContentsConfig 预加载的webContents配置
91
91
  */
92
- setPreloadWebContentsUrl(preloadWebContentsUrl) {
92
+ setPreloadWebContentsConfig(preloadWebContentsConfig) {
93
93
  try {
94
- this.preloadWebContentsUrl = preloadWebContentsUrl;
95
- if (this.preloadWebContentsUrl) {
94
+ this.preloadWebContentsConfig = preloadWebContentsConfig;
95
+ if (this.preloadWebContentsConfig) {
96
96
  this._preloadInstances();
97
97
  }
98
98
  else {
@@ -103,7 +103,7 @@ class WindowsManager {
103
103
  }
104
104
  }
105
105
  catch (error) {
106
- log('error', 'setPreloadWebContentsUrl error:', error);
106
+ log('error', 'setPreloadWebContentsConfig error:', error);
107
107
  }
108
108
  }
109
109
  /**
@@ -114,23 +114,52 @@ class WindowsManager {
114
114
  return;
115
115
  this.preloading = true;
116
116
  try {
117
- if (this.preloadWebContentsUrl) {
118
- // 预加载的窗口
119
- this.preloadedBW = this.preloadedBW || await this._createPreloadBW({});
120
- // 预加载的窗口(无边框,有按钮)
121
- this.preloadedBW_FramelessWithButtons = this.preloadedBW_FramelessWithButtons || await this._createPreloadBW({
122
- frame: false,
123
- transparent: true,
124
- titleBarStyle: 'hidden',
125
- });
126
- // 预加载的窗口(无边框,无按钮)
127
- this.preloadedBW_FramelessNoButtons = this.preloadedBW_FramelessNoButtons || await this._createPreloadBW({
128
- frame: false,
129
- transparent: true,
130
- titleBarStyle: 'customButtonsOnHover',
131
- });
132
- // 预加载的BV
133
- this.preloadedBV = this.preloadedBV || await this._createPreloadBV();
117
+ if (this.preloadWebContentsConfig) {
118
+ log('log', 'preloadWebContentsConfig: ', this.preloadWebContentsConfig);
119
+ // 根据配置决定是否预加载普通窗口
120
+ if (this.preloadWebContentsConfig.enableBW !== false) {
121
+ if (!this.preloadedBW) {
122
+ this._createPreloadBW({}).then(i => {
123
+ this.preloadedBW = i;
124
+ log('log', 'init preloadedBW: ', !!this.preloadedBW);
125
+ });
126
+ }
127
+ }
128
+ // 根据配置决定是否预加载无边框有按钮的窗口
129
+ if (this.preloadWebContentsConfig.enableBW_FramelessWithButtons !== false) {
130
+ if (!this.preloadedBW_FramelessWithButtons) {
131
+ this._createPreloadBW({
132
+ frame: false,
133
+ transparent: true,
134
+ titleBarStyle: 'hidden',
135
+ }).then(i => {
136
+ this.preloadedBW_FramelessWithButtons = i;
137
+ log('log', 'init preloadedBW_FramelessWithButtons: ', !!this.preloadedBW_FramelessWithButtons);
138
+ });
139
+ }
140
+ }
141
+ // 根据配置决定是否预加载无边框无按钮的窗口
142
+ if (this.preloadWebContentsConfig.enableBW_FramelessNoButtons !== false) {
143
+ if (!this.preloadedBW_FramelessNoButtons) {
144
+ this._createPreloadBW({
145
+ frame: false,
146
+ transparent: true,
147
+ titleBarStyle: 'customButtonsOnHover',
148
+ }).then(i => {
149
+ this.preloadedBW_FramelessNoButtons = i;
150
+ log('log', 'init preloadedBW_FramelessNoButtons: ', !!this.preloadedBW_FramelessNoButtons);
151
+ });
152
+ }
153
+ }
154
+ // 根据配置决定是否预加载浏览器视图
155
+ if (this.preloadWebContentsConfig.enableBV !== false) {
156
+ if (!this.preloadedBV) {
157
+ this._createPreloadBV().then(i => {
158
+ this.preloadedBV = i;
159
+ log('log', 'init preloadedBV: ', !!this.preloadedBV);
160
+ });
161
+ }
162
+ }
134
163
  }
135
164
  }
136
165
  catch (e) {
@@ -146,8 +175,8 @@ class WindowsManager {
146
175
  _createPreloadBW(options = {}) {
147
176
  return new Promise((resolve) => {
148
177
  const preload = this.preload;
149
- const url = this.preloadWebContentsUrl;
150
- if (this.preloadWebContentsUrl) {
178
+ const url = this.preloadWebContentsConfig?.url;
179
+ if (this.preloadWebContentsConfig?.url) {
151
180
  const webPreferences = (options.webPreferences || {});
152
181
  const instance = new BrowserWindow({
153
182
  ...options,
@@ -178,7 +207,7 @@ class WindowsManager {
178
207
  log('error', '预加载 BW 设置 _id 失败', error);
179
208
  }
180
209
  // @ts-ignore
181
- log('log', '创建预BW: ', instance._id, this.preloadWebContentsUrl);
210
+ log('log', '创建预BW: ', instance._id, this.preloadWebContentsConfig?.url);
182
211
  // instance.webContents.once('did-finish-load', () => {
183
212
  // resolve(instance as BWItem);
184
213
  // });
@@ -188,6 +217,9 @@ class WindowsManager {
188
217
  instance.loadURL(url ? `${url}` : 'about:blank');
189
218
  resolve(instance);
190
219
  }
220
+ else {
221
+ resolve(null);
222
+ }
191
223
  });
192
224
  }
193
225
  /**
@@ -197,8 +229,8 @@ class WindowsManager {
197
229
  _createPreloadBV(options = {}) {
198
230
  return new Promise((resolve) => {
199
231
  const preload = this.preload;
200
- const url = this.preloadWebContentsUrl;
201
- if (this.preloadWebContentsUrl) {
232
+ const url = this.preloadWebContentsConfig?.url;
233
+ if (this.preloadWebContentsConfig?.url) {
202
234
  const webPreferences = (options.webPreferences || {});
203
235
  const instance = new BrowserView({
204
236
  webPreferences: {
@@ -226,7 +258,7 @@ class WindowsManager {
226
258
  log('error', '预加载 BV 设置 _id 失败', error);
227
259
  }
228
260
  // @ts-ignore
229
- log('log', '创建预BV: ', instance._id, this.preloadWebContentsUrl);
261
+ log('log', '创建预BV: ', instance._id, this.preloadWebContentsConfig?.url);
230
262
  // instance.webContents.once('did-finish-load', () => {
231
263
  // resolve(instance as BVItem);
232
264
  // });
@@ -236,6 +268,9 @@ class WindowsManager {
236
268
  instance.webContents.loadURL(url || 'about:blank');
237
269
  resolve(instance);
238
270
  }
271
+ else {
272
+ resolve(null);
273
+ }
239
274
  });
240
275
  }
241
276
  create(options) {
@@ -278,44 +313,50 @@ class WindowsManager {
278
313
  options.type = type;
279
314
  // 优先复用预创建实例
280
315
  let preloadWin = null;
281
- if (type === 'BW' && usePreload && this.preloadWebContentsUrl) {
316
+ if (type === 'BW' && usePreload && this.preloadWebContentsConfig?.url) {
282
317
  const bwOptions = browserWindowOptions || {};
283
318
  if (bwOptions.frame === false) {
284
319
  if (bwOptions.titleBarStyle === 'customButtonsOnHover') {
285
- preloadWin = this.preloadedBW_FramelessNoButtons;
286
- this.preloadedBW_FramelessNoButtons = await this._createPreloadBW({
287
- frame: false,
288
- transparent: true,
289
- titleBarStyle: 'customButtonsOnHover',
290
- webPreferences: {
291
- preload: bwOptions?.webPreferences?.preload || this.preload,
292
- }
293
- });
320
+ if (this.preloadWebContentsConfig.enableBW_FramelessNoButtons !== false) {
321
+ preloadWin = this.preloadedBW_FramelessNoButtons;
322
+ this.preloadedBW_FramelessNoButtons = await this._createPreloadBW({
323
+ frame: false,
324
+ transparent: true,
325
+ titleBarStyle: 'customButtonsOnHover',
326
+ webPreferences: {
327
+ preload: bwOptions?.webPreferences?.preload || this.preload,
328
+ }
329
+ });
330
+ }
294
331
  }
295
332
  else {
296
- preloadWin = this.preloadedBW_FramelessWithButtons;
297
- this.preloadedBW_FramelessWithButtons = await this._createPreloadBW({
298
- frame: false,
299
- transparent: true,
300
- titleBarStyle: 'hidden',
333
+ if (this.preloadWebContentsConfig.enableBW_FramelessWithButtons !== false) {
334
+ preloadWin = this.preloadedBW_FramelessWithButtons;
335
+ this.preloadedBW_FramelessWithButtons = await this._createPreloadBW({
336
+ frame: false,
337
+ transparent: true,
338
+ titleBarStyle: 'hidden',
339
+ webPreferences: {
340
+ preload: this.preload,
341
+ }
342
+ });
343
+ }
344
+ }
345
+ }
346
+ else {
347
+ if (this.preloadWebContentsConfig.enableBW !== false) {
348
+ preloadWin = this.preloadedBW;
349
+ this.preloadedBW = await this._createPreloadBW({
301
350
  webPreferences: {
302
- preload: this.preload,
351
+ preload: bwOptions?.webPreferences?.preload || this.preload,
303
352
  }
304
353
  });
305
354
  }
306
355
  }
307
- else {
308
- preloadWin = this.preloadedBW;
309
- this.preloadedBW = await this._createPreloadBW({
310
- webPreferences: {
311
- preload: bwOptions?.webPreferences?.preload || this.preload,
312
- }
313
- });
314
- }
315
356
  }
316
- if (type === 'BV' && usePreload && this.preloadWebContentsUrl) {
357
+ if (type === 'BV' && usePreload && this.preloadWebContentsConfig?.url) {
317
358
  const bvOptions = browserWindowOptions || {};
318
- if (this.preloadedBV) {
359
+ if (this.preloadWebContentsConfig.enableBV !== false) {
319
360
  preloadWin = this.preloadedBV;
320
361
  this.preloadedBV = await this._createPreloadBV({
321
362
  webPreferences: {
@@ -980,7 +1021,7 @@ class WindowsManager {
980
1021
  // @ts-ignore
981
1022
  global['__ELECTRON_WINDOWS_MANAGER__'] = undefined;
982
1023
  let isInitialized = false;
983
- const initialize = (preload, loadingViewUrl, errorViewUrl, preloadWebContentsUrl, webviewDomainWhiteList) => {
1024
+ const initialize = (preload, loadingViewUrl, errorViewUrl, preloadWebContentsConfig, webviewDomainWhiteList) => {
984
1025
  // @ts-ignore
985
1026
  if (isInitialized && global['__ELECTRON_WINDOWS_MANAGER__']) {
986
1027
  // @ts-ignore
@@ -988,7 +1029,7 @@ const initialize = (preload, loadingViewUrl, errorViewUrl, preloadWebContentsUrl
988
1029
  }
989
1030
  isInitialized = true;
990
1031
  // @ts-ignore
991
- const wm = global['__ELECTRON_WINDOWS_MANAGER__'] = new WindowsManager(preload, loadingViewUrl, errorViewUrl, preloadWebContentsUrl, webviewDomainWhiteList);
1032
+ const wm = global['__ELECTRON_WINDOWS_MANAGER__'] = new WindowsManager(preload, loadingViewUrl, errorViewUrl, preloadWebContentsConfig, webviewDomainWhiteList);
992
1033
  eIpc.mainIPC.handleRenderer('__ELECTRON_WINDOW_MANAGER_IPC_CHANNEL__', async (data) => {
993
1034
  if (data?.type === 'create') {
994
1035
  const opt = data;
@@ -1148,9 +1189,9 @@ const initialize = (preload, loadingViewUrl, errorViewUrl, preloadWebContentsUrl
1148
1189
  return undefined;
1149
1190
  }
1150
1191
  // 是否开启预加载窗口
1151
- if (data?.type === 'setPreloadWebContentsUrl') {
1192
+ if (data?.type === 'setPreloadWebContentsConfig') {
1152
1193
  const opt = data;
1153
- wm.setPreloadWebContentsUrl(opt.data);
1194
+ wm.setPreloadWebContentsConfig(opt.data);
1154
1195
  }
1155
1196
  if (data?.type === 'createPreloadWebContents') {
1156
1197
  const opt = data;