-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
60 lines (54 loc) · 1.65 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
const { app, BrowserWindow, TouchBar } = require('electron');
const { TouchBarButton } = TouchBar;
const path = require('path');
const axios = require('axios');
const _ = require('lodash');
const USDollarLabel = new TouchBarButton();
const euroLabel = new TouchBarButton();
const coin = new TouchBarButton();
const gold = new TouchBarButton();
getPrice = () => {
USDollarLabel.label = `دلار آمریکا: 🔄`;
euroLabel.label = `یورو: 🔄`;
coin.label = `سکه: 🔄`;
gold.label = `طلا ۱۸ عیار: 🔄`;
axios.get('http://call3.tgju.org/ajax.json?2019092012-20190920111730-cqBKXSqADeUcLetq5z2Z')
.then(function(response) {
const data = _.get(response, ['data', 'current']);
USDollarLabel.label = `دلار آمریکا: ${_.get(data, ['price_dollar_rl', 'h'])} ﷼`;
euroLabel.label = `یورو: ${_.get(data, ['price_eur', 'p'])} ﷼`;
coin.label = `سکه: ${_.get(data, ['sekee', 'p'])} ﷼`;
gold.label = `طلا ۱۸ عیار: ${_.get(data, ['geram18', 'p'])} ﷼`;
});
};
getPrice();
setInterval(getPrice, 30000);
const touchBar = new TouchBar({
items: [
USDollarLabel,
euroLabel,
coin,
gold,
],
});
touchBar.escapeItem = new TouchBarButton({
'label': '🔄',
click: getPrice,
});
let window;
app.once('ready', () => {
window = new BrowserWindow({
frame: false,
titleBarStyle: 'hiddenInset',
width: 0,
height: 0,
transparent: true,
icon: path.join(__dirname, 'icons/logo.icns'),
resizable: false,
skipTaskbar: true,
fullscreenable: false,
});
window.loadURL('about:blank');
window.setTouchBar(touchBar);
window.removeMenu();
});