-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
36 lines (31 loc) · 979 Bytes
/
main.js
File metadata and controls
36 lines (31 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('node:path')
const { TodosModel } = require('./todosModel')
const { startMcpServer } = require('./mcpServer')
const todosModel = new TodosModel()
app.whenReady().then(() => {
const win = new BrowserWindow({
width: 600,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
},
})
const todosApi = {
list: () => todosModel.list(),
add: (title) => {
const newTodo = todosModel.add(title)
win.webContents.send('update', todosModel.list())
return newTodo
},
complete: (id) => {
todosModel.complete(id)
win.webContents.send('update', todosModel.list())
}
}
ipcMain.handle('list', () => todosApi.list())
ipcMain.handle('add', (_event, title) => todosApi.add(title))
ipcMain.handle('complete', (_event, id) => todosApi.complete(id))
win.loadFile('index.html')
startMcpServer(todosApi)
})