-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrenderer.js
212 lines (185 loc) · 5.4 KB
/
renderer.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
const TabGroup = require("electron-tabs");
const {
remote,
shell
} = require('electron')
const electronLocalshortcut = require('electron-localshortcut');
let tabGroup = new TabGroup({});
let mail = tabGroup.addTab({
title: "메일",
src: "https://mail.google.com/a/nonce.community",
visible: true,
active: true,
closable: false
});
let notion = tabGroup.addTab({
title: "노션",
// src: "https://www.notion.so/noncefoundation",
src: "https://www.notion.so/googlepopupredirect?redirectToAuth=true",
visible: true,
active: false,
closable: false
});
let slack = tabGroup.addTab({
title: "슬랙",
src: "https://nonce-community.slack.com",
visible: true,
active: false,
closable: false
});
let calendar = tabGroup.addTab({
title: "캘린더",
src: "https://calendar.google.com/a/nonce.community",
visible: true,
active: false,
closable: false
});
let drive = tabGroup.addTab({
title: "구글 드라이브",
src: "https://drive.google.com/a/nonce.community",
visible: true,
active: false,
closable: false
});
let groups = tabGroup.addTab({
title: "그룹메일",
src: "https://groups.google.com/a/nonce.community",
visible: true,
active: false,
closable: false
});
let analytics = tabGroup.addTab({
title: "애널리틱스",
src: "https://analytics.google.com/analytics/a/nonce.foundation",
visible: true,
active: false,
closable: false
});
let facebook = tabGroup.addTab({
title: "페이스북",
src: "https://www.facebook.com/nonce.community/",
visible: true,
active: false,
closable: false
});
let twitter = tabGroup.addTab({
title: "트위터",
src: "https://twitter.com/nonce_community",
visible: true,
active: false,
closable: false
});
let brunch = tabGroup.addTab({
title: "브런치",
src: "https://brunch.co.kr/@nonce#articles",
visible: true,
active: false,
closable: false
});
let help = tabGroup.addTab({
title: "사용법",
src: "help.html",
visible: true,
active: false,
closable: false
});
let nextTab;
const goToNextTab = () => {
nextTab = tabGroup.getNextTab();
if (!nextTab) {
nextTab = tabGroup.getTabByPosition(1);
}
nextTab.activate();
}
let prevTab;
const goToPrevTab = () => {
prevTab = tabGroup.getPreviousTab();
if (!prevTab) {
prevTab = tabGroup.getTabByPosition(-1);
}
prevTab.activate();
}
const goToTabByPosition = (position) => () => {
tabGroup.getTabByPosition(position).activate();
}
const goForward = () => {
let activeTab = tabGroup.getActiveTab();
if(activeTab) {
activeTab.webview.goForward()
}
}
const goBackward = () => {
let activeTab = tabGroup.getActiveTab();
if(activeTab) {
activeTab.webview.goBack()
}
}
const redo = () => {
let activeTab = tabGroup.getActiveTab();
if(activeTab) {
activeTab.webview.redo()
}
}
const undo = () => {
let activeTab = tabGroup.getActiveTab();
if(activeTab) {
activeTab.webview.undo()
}
}
const copy = () => {
let activeTab = tabGroup.getActiveTab();
if(activeTab) {
activeTab.webview.copy()
}
}
const paste = () => {
let activeTab = tabGroup.getActiveTab();
if(activeTab) {
activeTab.webview.paste()
}
}
const selectAll = () => {
let activeTab = tabGroup.getActiveTab();
if(activeTab) {
activeTab.webview.selectAll()
}
}
const reLoadPage = () => {
let activeTab = tabGroup.getActiveTab();
if(activeTab) {
activeTab.webview.loadURL(activeTab.webviewAttributes.src);
}
}
tabGroup.getTabs().forEach(tab => {
tab.webview.addEventListener('new-window', (event, url, frameName, disposition, options, additionalFeatures) => {
shell.openExternal(event.url);
});
});
let win = remote.getCurrentWindow()
electronLocalshortcut.register(win, 'Ctrl+Tab', goToNextTab);
electronLocalshortcut.register(win, 'Ctrl+Shift+Tab', goToPrevTab);
electronLocalshortcut.register(win, 'Cmd+Right', goToNextTab);
electronLocalshortcut.register(win, 'Cmd+Left', goToPrevTab);
electronLocalshortcut.register(win, 'CmdOrCtrl+1', goToTabByPosition(1));
electronLocalshortcut.register(win, 'CmdOrCtrl+2', goToTabByPosition(2));
electronLocalshortcut.register(win, 'CmdOrCtrl+3', goToTabByPosition(3));
electronLocalshortcut.register(win, 'CmdOrCtrl+4', goToTabByPosition(4));
electronLocalshortcut.register(win, 'CmdOrCtrl+5', goToTabByPosition(5));
electronLocalshortcut.register(win, 'CmdOrCtrl+6', goToTabByPosition(6));
electronLocalshortcut.register(win, 'CmdOrCtrl+7', goToTabByPosition(7));
electronLocalshortcut.register(win, 'CmdOrCtrl+8', goToTabByPosition(8));
electronLocalshortcut.register(win, 'CmdOrCtrl+9', goToTabByPosition(9));
electronLocalshortcut.register(win, 'CmdOrCtrl+0', goToTabByPosition(-1));
electronLocalshortcut.register(win, 'CmdOrCtrl+PageUp', goToPrevTab);
electronLocalshortcut.register(win, 'CmdOrCtrl+PageDown', goToNextTab);
electronLocalshortcut.register(win, 'CmdOrCtrl+R', reLoadPage);
electronLocalshortcut.register(win, 'CmdOrCtrl+[', goBackward);
electronLocalshortcut.register(win, 'CmdOrCtrl+]', goForward);
electronLocalshortcut.register(win, 'CmdOrCtrl+Z', undo);
electronLocalshortcut.register(win, 'CmdOrCtrl+Shift+Z', redo);
electronLocalshortcut.register(win, 'CmdOrCtrl+C', copy);
electronLocalshortcut.register(win, 'CmdOrCtrl+V', paste);
electronLocalshortcut.register(win, 'CmdOrCtrl+A', selectAll);