-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
58 lines (47 loc) · 950 Bytes
/
index.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
const Guark =
{
env_data: null,
env()
{
if (this.env_data === null) {
return this.call("env").then(r => {
this.env_data = r
return r
})
}
return new Promise((res) => res(this.env_data))
},
// Invoke a hook.
hook(name)
{
return this.call("hook", {name: name})
},
// Call exported Go functions.
call(funcName, args)
{
return window["__guark_func_"+ funcName.replace('.', '$')](args || {})
},
// Send desktop notification.
notify(message, args)
{
return this.call("notify.send", Object.assign(args || {}, {message: message}))
},
// exit the app.
exit()
{
return this.call("exit")
},
};
//
// Overrride default window funcs.
//
window.alert = function(message) {
console.log("use dialog plugin instead of alert:", message)
}
window.confirm = function(message) {
console.log("use dialog plugin instead of confirm:", message)
}
window.close = function() {
Guark.exit()
}
module.exports = Guark