-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
83 lines (67 loc) · 2.35 KB
/
main.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
"use strict";
const electron = require("electron");
const {app, BrowserWindow, ipcMain, shell} = electron;
const fse = require('fs-extra')
initialize_env();
const screen_shot_util = require('./index.js');
global.mainWindow = null;
app.on('ready', () => {
createWindow();
});
app.on('window-all-closed', () => {
electron.session.defaultSession.clearCache(() => {});
app.quit();
});
app.on('activate', () => {
createWindow();
});
function createWindow() {
if(global.mainWindow !== null ) {
return;
}
global.mainWindow = new BrowserWindow({width: 350, height: 700});
global.mainWindow.loadURL('file://' + __dirname + '/index.html');
global.mainWindow.webContents.session.clearCache(function() {});
// global.mainWindow.webContents.openDevTools();
// ウィンドウが閉じられたらアプリも終了
global.mainWindow.on('closed', () => global.mainWindow = null );
}
ipcMain.on('take_screen_shots', (event, arg) => {
screen_shot_util.take_all_screen_shot();
});
ipcMain.on('open_origin_directory', (event, arg) => {
shell.showItemInFolder(app.getPath('userData') + '/' + 'origin' + '/');
});
ipcMain.on('open_login_config', (event, arg) => {
shell.showItemInFolder(app.getPath('userData') + '/config.json');
});
ipcMain.on('open_url_list', (event, arg) => {
shell.showItemInFolder(app.getPath('userData') + '/url_list.json');
});
ipcMain.on('open_diff_directory', (event, arg) => {
shell.showItemInFolder(app.getPath('userData') + '/' + 'diff' + '/');
});
ipcMain.on('open_test_result_directory', (event, arg) => {
shell.showItemInFolder(app.getPath('userData') + '/' + 'test_result' + '/');
});
ipcMain.on('open_origin_directory', (event, arg) => {
shell.showItemInFolder(app.getPath('userData') + '/' + 'origin' + '/');
});
function initialize_env() {
var copy_targets = ['config.json', 'url_list.json'];
copy_targets.forEach( (filename) => {
console.log(filename)
var copy_from = __dirname + '/' + filename;
var copy_dist = app.getPath('userData') + '/' + filename;
if(!fse.existsSync(copy_dist)) {
fse.copySync(copy_from, copy_dist);
}
});
var base_directories = ['diff', 'origin', 'test_result'];
base_directories.forEach( (dirname) => {
var directory_path = app.getPath('userData') + '/' + dirname
if(!fse.existsSync(directory_path)) {
fse.mkdirSync(directory_path);
}
});
}