-
Notifications
You must be signed in to change notification settings - Fork 0
/
folderCreator.js
92 lines (66 loc) · 2.46 KB
/
folderCreator.js
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
const {app, /* BrowserWindow, */ ipcMain } = require("electron");
const { BrowserWindow } = require('electron-acrylic-window');
const path = require("path");
const fs = require("fs");
const createShortcut = require('windows-shortcuts');
const { exec } = require('child_process');
let home = require("os").homedir();
let appDIr = home + '/Documents/Windows App Folder';
if (!fs.existsSync(appDIr)){
fs.mkdirSync(appDIr);
}
let exeLocation = path.join(__dirname, "WindowsAppFolder-win32-x64");
if(app.isPackaged) exeLocation = path.join(__dirname, '..', '..')
const createWindow = () => {
const win = new BrowserWindow({
width: 1200,
height: 1200,
transparent: true,
frame: false,
icon: __dirname + '/src/assets/icon/logo.png',
vibrancy: {
theme: '#FFFFFF05', // (default) or 'dark' or '#rrggbbaa'
effect: 'blur', // (default) or 'blur'
disableOnBlur: false, // (default)
},
webPreferences: {
preload: path.join(__dirname, "preload.js")
}
});
win.maximize()
ipcMain.handle("getFolders", (req, data) => {
let folders = fs.readdirSync(appDIr);
if(!folders.length){
folders = "no folders";
}
return folders;
})
ipcMain.handle("createFolder", (req, data) => {
if(!data || !data.name) return "no data";
let finalDir = appDIr + "/" + data.name;
if(fs.existsSync(finalDir)) return "alread exists";
fs.mkdirSync(finalDir);
fs.mkdirSync(finalDir+"/windowsAppFolderContent_DontEditOrExclude/");
console.log( __dirname+"/WindowsAppFolder-win32-x64/WindowsAppFolder.exe");
createShortcut.create(finalDir+"/windowsAppFolderContent_DontEditOrExclude/"+data.name+".lnk", {
target: exeLocation+"/WindowsAppFolder.exe",
args: `"${data.name}" "${data.styleType}"`,
}, () => {
exec('start "" "'+finalDir+'"', () => app.quit());
});
return "success";
})
ipcMain.handle("openFolderDir", (req, data) => {
if(!data) return app.quit();
let finalDir = appDIr + "/" + data;
exec('start "" "'+finalDir+'"', () => app.quit());
})
ipcMain.handle("close", () => {
app.quit();
})
win.loadFile("src/createFolder.html")
}
app.whenReady().then(createWindow);
app.on("window-all-closed", () => {
if(process.platform !== "darwin") app.quit()
})