@thirty-coder/electron-base-kit 0.2.0 → 0.2.1
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/dist/index.js +24 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -276,20 +276,30 @@ function attachPersistence(win, key) {
|
|
|
276
276
|
save();
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
var guarded = /* @__PURE__ */ new Set();
|
|
280
|
+
var screenHooked = false;
|
|
281
|
+
function guardAll() {
|
|
282
|
+
for (const win of guarded) {
|
|
283
|
+
if (win.isDestroyed()) {
|
|
284
|
+
guarded.delete(win);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
if (win.isMaximized() || win.isMinimized() || win.isFullScreen()) continue;
|
|
283
288
|
const current = win.getBounds();
|
|
284
289
|
const area = bestWorkArea(current);
|
|
285
|
-
if (intersectArea(current, area) / (current.width * current.height) >= VISIBLE_RATIO)
|
|
290
|
+
if (intersectArea(current, area) / (current.width * current.height) >= VISIBLE_RATIO) continue;
|
|
286
291
|
win.setBounds(centerOnPrimary(current));
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function attachDisplayGuard(win) {
|
|
295
|
+
guarded.add(win);
|
|
296
|
+
if (!screenHooked) {
|
|
297
|
+
screenHooked = true;
|
|
298
|
+
import_electron2.screen.on("display-removed", guardAll);
|
|
299
|
+
import_electron2.screen.on("display-metrics-changed", guardAll);
|
|
300
|
+
}
|
|
290
301
|
win.once("closed", () => {
|
|
291
|
-
|
|
292
|
-
import_electron2.screen.removeListener("display-metrics-changed", handle);
|
|
302
|
+
guarded.delete(win);
|
|
293
303
|
});
|
|
294
304
|
}
|
|
295
305
|
function createWindow(options) {
|
|
@@ -305,6 +315,10 @@ function createWindow(options) {
|
|
|
305
315
|
const key = `window.${id}`;
|
|
306
316
|
const saved = remember ? settings.get(`${key}.bounds`, void 0) : void 0;
|
|
307
317
|
const maximized = remember ? settings.get(`${key}.maximized`, false) : false;
|
|
318
|
+
if (!remember) {
|
|
319
|
+
settings.remove(`${key}.bounds`);
|
|
320
|
+
settings.remove(`${key}.maximized`);
|
|
321
|
+
}
|
|
308
322
|
const { bounds, center } = resolveBounds(isBounds(saved) ? saved : void 0, size, ensureVisible);
|
|
309
323
|
const win = new import_electron2.BrowserWindow({
|
|
310
324
|
...bounds,
|