-
Notifications
You must be signed in to change notification settings - Fork 44
/
control.js
66 lines (54 loc) · 1.45 KB
/
control.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
import { ipcRenderer } from 'electron';
// Used in Renderer process
/**
* Tell browser view to load url
* @param {string} url
*/
const sendEnterURL = url => ipcRenderer.send('url-enter', url);
/**
* Tell browser view url in address bar changed
* @param {string} url
*/
const sendChangeURL = url => ipcRenderer.send('url-change', url);
const sendAct = actName => {
ipcRenderer.send('act', actName);
};
/**
* Tell browser view to goBack
*/
const sendGoBack = () => sendAct('goBack');
/**
* Tell browser view to goForward
*/
const sendGoForward = () => sendAct('goForward');
// Tell browser view to reload
const sendReload = () => sendAct('reload');
// Tell browser view to stop load
const sendStop = () => sendAct('stop');
/**
* Tell browser view to close tab
* @param {TabID} id
*/
const sendCloseTab = id => ipcRenderer.send('close-tab', id);
/**
* Create a new tab
* @param {string} [url]
* @param {object} [references]
*/
const sendNewTab = (url, references) => ipcRenderer.send('new-tab', url, references);
/**
* Tell browser view to switch to specified tab
* @param {TabID} id
*/
const sendSwitchTab = id => ipcRenderer.send('switch-tab', id);
module.exports = {
sendEnterURL, // sendEnterURL(url) to load url
sendChangeURL, // sendChangeURL(url) on addressbar input change
sendGoBack,
sendGoForward,
sendReload,
sendStop,
sendNewTab, // sendNewTab([url])
sendSwitchTab, // sendSwitchTab(toID)
sendCloseTab // sendCloseTab(id)
};