-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
98 lines (83 loc) · 2.85 KB
/
main.js
File metadata and controls
98 lines (83 loc) · 2.85 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const { app, BrowserWindow, Menu, ipcMain } = require('electron');
const path = require('path');
function createWindow() {
const mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
},
titleBarStyle: 'hiddenInset',
vibrancy: 'under-window',
transparent: true,
frame: true,
title: 'SkillSnap - AI Micro-Skill Mentor'
});
mainWindow.loadFile('index.html');
// Dev tools in development
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools();
}
}
// Free AI code analysis
function analyzeCodeForFree(code) {
const commonIssues = {
'syntax': [
{ pattern: /console\.log\([^)]*\)/g, fix: 'Use proper debugging techniques' },
{ pattern: /var\s+\w+/g, fix: 'Use let/const instead of var' },
{ pattern: /==/g, fix: 'Use === for strict equality comparison' }
],
'best_practices': [
{ pattern: /function\s*\(/g, fix: 'Consider using arrow functions for better scope handling' },
{ pattern: /for\s*\(\s*;\s*;\s*\)/g, fix: 'Ensure your for loop has proper initialization, condition, and increment' }
]
};
let results = { issues: [], suggestions: [] };
for (let category in commonIssues) {
commonIssues[category].forEach(issue => {
if (issue.pattern.test(code)) {
results.issues.push({
category: category,
description: issue.fix,
severity: 'medium'
});
}
});
}
return results;
}
// Simple email authentication system
const users = new Map();
ipcMain.handle('user-signup', async (event, { email, password }) => {
if (users.has(email)) {
return { success: false, message: 'Email already exists' };
}
users.set(email, { password, progress: {} });
return { success: true, message: 'Signup successful' };
});
ipcMain.handle('user-login', async (event, { email, password }) => {
const user = users.get(email);
if (user && user.password === password) {
return { success: true, user: { email, progress: user.progress } };
}
return { success: false, message: 'Invalid credentials' };
});
ipcMain.handle('analyze-code', async (event, code) => {
return analyzeCodeForFree(code);
});
ipcMain.handle('save-progress', async (event, progressData) => {
return { success: true };
});
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});