-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
60 lines (50 loc) · 1.79 KB
/
main.js
File metadata and controls
60 lines (50 loc) · 1.79 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const { app, BrowserWindow, ipcMain, Menu, dialog } = require("electron");
const path = require("path");
const { lerPlanilha } = require("./services/planilha");
const { fazerLogin, selecionarTurma } = require("./services/automacao");
let conteudo = null
Menu.setApplicationMenu(null);
function createWindow() {
const win = new BrowserWindow({
width: 350,
height: 500,
icon: path.join(__dirname, "assets/icon.png"),
resizable: false, // não redimensiona
maximizable: false, // desativa maximizar
minimizable: true, // pode minimizar
fullscreenable: false,
webPreferences: {
preload: path.join(__dirname, "preload.js")
}
});
win.loadFile("index.html");
}
ipcMain.handle("selecionar-planilha", async () => {
const result = await dialog.showOpenDialog({
properties: ["openFile"],
filters: [
{ name: "Planilhas Excel", extensions: ["xlsx"] }
]
});
if (result.canceled) {
return null;
}
return result.filePaths[0]; // 👈 caminho REAL
});
ipcMain.handle("processar-planilha", async (_, dados) => {
if (!dados.caminhoArquivo) {
throw new Error("Caminho da planilha inválido");
}
const lista = lerPlanilha(dados.caminhoArquivo);
console.log(lista.length+" aulas");
conteudo = lista;
});
ipcMain.handle("iniciar-automacao", async (_, dados) => {
const { browser, page } = await fazerLogin(dados);
let turma_disciplina = dados.turma + " - " + dados.disciplina;
await selecionarTurma({browser, page, turma_disciplina});
// aqui depois você continua o fluxo:
// selecionar turma, mês, inserir aulas...
return "Login realizado com sucesso";
});
app.whenReady().then(createWindow);