新增HTTP开放API服务

This commit is contained in:
lyswhut
2024-03-29 14:43:32 +08:00
parent 1e03791e82
commit 9c0ae12959
35 changed files with 681 additions and 340 deletions
@@ -0,0 +1,18 @@
import { mainHandle } from '@common/mainIpc'
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
import {
startServer,
stopServer,
getStatus,
} from '@main/modules/openApi'
export default () => {
mainHandle<LX.OpenAPI.Actions, any>(WIN_MAIN_RENDERER_EVENT_NAME.open_api_action, async({ params: data }) => {
switch (data.action) {
case 'enable':
return data.data.enable ? await startServer(parseInt(data.data.port)) : await stopServer()
case 'status': return getStatus()
}
})
}