mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-08-29 20:16:42 +08:00
Fix typora macos (#542)
* 🔨 Refactor(custom): add debug log * 🐛 Fix(custom): fix active enent with typora
This commit is contained in:
+22
-14
@@ -47,6 +47,24 @@ const defaultStartMode = {
|
|||||||
linux: ISartMode.MINI,
|
linux: ISartMode.MINI,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isPointInRect = (point: Electron.Point, rect: Electron.Rectangle) =>
|
||||||
|
point.x >= rect.x && point.x < rect.x + rect.width && point.y >= rect.y && point.y < rect.y + rect.height
|
||||||
|
|
||||||
|
const isLikelyDockActivation = () => {
|
||||||
|
if (process.platform !== 'darwin') return true
|
||||||
|
|
||||||
|
const cursorPoint = screen.getCursorScreenPoint()
|
||||||
|
const display = screen.getDisplayNearestPoint(cursorPoint)
|
||||||
|
const isInWorkArea = isPointInRect(cursorPoint, display.workArea)
|
||||||
|
const isInMenuBar =
|
||||||
|
cursorPoint.y >= display.bounds.y &&
|
||||||
|
cursorPoint.y < display.workArea.y &&
|
||||||
|
cursorPoint.x >= display.workArea.x &&
|
||||||
|
cursorPoint.x < display.workArea.x + display.workArea.width
|
||||||
|
|
||||||
|
return !isInWorkArea && !isInMenuBar
|
||||||
|
}
|
||||||
|
|
||||||
const handleStartUpFiles = (argv: string[], cwd: string) => {
|
const handleStartUpFiles = (argv: string[], cwd: string) => {
|
||||||
const files = getUploadFiles(argv, cwd, logger)
|
const files = getUploadFiles(argv, cwd, logger)
|
||||||
|
|
||||||
@@ -218,28 +236,18 @@ class LifeCycle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#onRunning() {
|
#onRunning() {
|
||||||
let pendingActivateWindowTimer: ReturnType<typeof setTimeout> | null = null
|
|
||||||
|
|
||||||
app.on('second-instance', (_, commandLine, workingDirectory) => {
|
app.on('second-instance', (_, commandLine, workingDirectory) => {
|
||||||
logger.info('detect second instance')
|
logger.info('detect second instance')
|
||||||
if (pendingActivateWindowTimer !== null) {
|
|
||||||
clearTimeout(pendingActivateWindowTimer)
|
|
||||||
pendingActivateWindowTimer = null
|
|
||||||
}
|
|
||||||
const result = handleStartUpFiles(commandLine, workingDirectory)
|
const result = handleStartUpFiles(commandLine, workingDirectory)
|
||||||
|
logger.info('handleStartUpFiles result:', String(result))
|
||||||
if (!result) {
|
if (!result) {
|
||||||
windowManager.create(IWindowList.SETTING_WINDOW)
|
windowManager.create(IWindowList.SETTING_WINDOW)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
if (!windowManager.has(IWindowList.SETTING_WINDOW)) {
|
logger.info('activate is called')
|
||||||
if (pendingActivateWindowTimer !== null) clearTimeout(pendingActivateWindowTimer)
|
if (!windowManager.has(IWindowList.SETTING_WINDOW) && isLikelyDockActivation()) {
|
||||||
pendingActivateWindowTimer = setTimeout(() => {
|
windowManager.create(IWindowList.SETTING_WINDOW)
|
||||||
pendingActivateWindowTimer = null
|
|
||||||
if (!windowManager.has(IWindowList.SETTING_WINDOW)) {
|
|
||||||
windowManager.create(IWindowList.SETTING_WINDOW)
|
|
||||||
}
|
|
||||||
}, 300)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const storedAutoStartEnabled = picgo.getConfig<boolean>(configPaths.settings.autoStart) || false
|
const storedAutoStartEnabled = picgo.getConfig<boolean>(configPaths.settings.autoStart) || false
|
||||||
|
|||||||
@@ -90,8 +90,10 @@ class Server {
|
|||||||
} else {
|
} else {
|
||||||
const remoteAddress = request.socket.remoteAddress || 'unknown'
|
const remoteAddress = request.socket.remoteAddress || 'unknown'
|
||||||
logger.info('[PicList Server] get a POST request from IP:', remoteAddress)
|
logger.info('[PicList Server] get a POST request from IP:', remoteAddress)
|
||||||
|
const isLocalRequest =
|
||||||
|
remoteAddress === '::1' || remoteAddress === '127.0.0.1' || remoteAddress === '::ffff:127.0.0.1'
|
||||||
let urlSP = query ? new URLSearchParams(query) : undefined
|
let urlSP = query ? new URLSearchParams(query) : undefined
|
||||||
if (remoteAddress === '::1' || remoteAddress === '127.0.0.1' || remoteAddress === '::ffff:127.0.0.1') {
|
if (isLocalRequest) {
|
||||||
const serverKey = picgo.getConfig<string>(configPaths.settings.serverKey) || ''
|
const serverKey = picgo.getConfig<string>(configPaths.settings.serverKey) || ''
|
||||||
if (urlSP) {
|
if (urlSP) {
|
||||||
urlSP.set('key', serverKey)
|
urlSP.set('key', serverKey)
|
||||||
|
|||||||
Reference in New Issue
Block a user