fantasia-archive/src-electron/customContentBridgeAPIs/faDevToolsControlAPI.ts
2023-09-12 21:20:26 +02:00

43 lines
1.1 KiB
TypeScript

import { BrowserWindow } from '@electron/remote'
import { I_faDevToolsControl } from 'app/interfaces/I_faDevToolsControl'
export const faDevToolsControlAPI: I_faDevToolsControl = {
checkDecToolsStatus () {
const currentWindow = BrowserWindow.getFocusedWindow()
if (currentWindow !== null) {
return currentWindow.webContents.isDevToolsOpened()
}
return false
},
toggleDevTools () {
const currentWindow = BrowserWindow.getFocusedWindow()
if (currentWindow !== null) {
const devToolsOpened = currentWindow.webContents.isDevToolsOpened()
if (devToolsOpened) {
currentWindow.webContents.closeDevTools()
} else {
currentWindow.webContents.openDevTools()
}
}
},
openDevTools () {
const currentWindow = BrowserWindow.getFocusedWindow()
if (currentWindow !== null) {
currentWindow.webContents.openDevTools()
}
},
closeDevTools () {
const currentWindow = BrowserWindow.getFocusedWindow()
if (currentWindow !== null) {
currentWindow.webContents.closeDevTools()
}
}
}