poi-plugin-inventory-cleaner 1.16.1 → 1.16.2
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/index.js +33 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -446,6 +446,39 @@ function App() {
|
|
|
446
446
|
if (element) element.scrollTo({ top: 0, behavior: 'smooth' })
|
|
447
447
|
}, [])
|
|
448
448
|
|
|
449
|
+
// 窗口位置自愈:如果记住的位置在所有屏幕之外,挪回主屏
|
|
450
|
+
React.useEffect(() => {
|
|
451
|
+
try {
|
|
452
|
+
const remote = require('@electron/remote')
|
|
453
|
+
const windows = remote.BrowserWindow.getAllWindows()
|
|
454
|
+
const target = windows.find((win) =>
|
|
455
|
+
String(win.webContents.getURL() || '').includes('poi-plugin-inventory-cleaner'),
|
|
456
|
+
)
|
|
457
|
+
if (!target) return
|
|
458
|
+
const bounds = target.getBounds()
|
|
459
|
+
const displays = remote.screen.getAllDisplays()
|
|
460
|
+
const onScreen = displays.some((display) => {
|
|
461
|
+
const area = display.workArea
|
|
462
|
+
return (
|
|
463
|
+
bounds.x < area.x + area.width &&
|
|
464
|
+
bounds.x + bounds.width > area.x &&
|
|
465
|
+
bounds.y < area.y + area.height &&
|
|
466
|
+
bounds.y + bounds.height > area.y
|
|
467
|
+
)
|
|
468
|
+
})
|
|
469
|
+
if (onScreen) return
|
|
470
|
+
const area = remote.screen.getPrimaryDisplay().workArea
|
|
471
|
+
target.setBounds({
|
|
472
|
+
x: area.x + 80,
|
|
473
|
+
y: area.y + 60,
|
|
474
|
+
width: Math.min(1200, area.width - 160),
|
|
475
|
+
height: Math.min(900, area.height - 120),
|
|
476
|
+
})
|
|
477
|
+
} catch (_error) {
|
|
478
|
+
// 非 Electron 环境或没有权限时忽略
|
|
479
|
+
}
|
|
480
|
+
}, [])
|
|
481
|
+
|
|
449
482
|
const firstKeepSave = React.useRef(true)
|
|
450
483
|
React.useEffect(() => {
|
|
451
484
|
if (firstKeepSave.current) {
|