-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.js
113 lines (103 loc) · 3.92 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
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
/**
* @param {} size : int the rect clip width of the loding svg
* @param {} dotsize : int the r of a loading dot
* @param {} dotcolor : "#xxxxxx" the color of the dot
*/
CreateLodingRing = function (size, dotsize, dotcolor) {
//#region Create Element
var ring = Object();
let loadingring = document.createElementNS("http://www.w3.org/2000/svg", "svg");
loadingring.id = "winloding";
loadingring.setAttribute("viewBox", "0 0" + " " + size + " " + size);
loadingring.setAttribute("width", "10%")
loadingring.setAttribute("height", "10%")
loadingring.style.right = "5%";
loadingring.style.bottom = "5%";
loadingring.style.position = "absolute";
for (let i = 0; i < 6; i++) {
let dot = document.createElementNS("http://www.w3.org/2000/svg", "circle");
dot.style.transformOrigin = "center center";
dot.style.opacity = 0;
dot.setAttribute("class", "d" + (i + 1));
dot.setAttribute("fill", dotcolor);
dot.setAttribute("cx", size / 2);
dot.setAttribute("cy", dotsize + 2);
dot.setAttribute("r", dotsize);
loadingring.appendChild(dot);
}
document.body.appendChild(loadingring);
console.log(loadingring);
//#endregion
var tl = anime.timeline({
loop: true
});
for (let i = 0; i < 6; i++) {
let basevalue = -110 - 6 * i;
tl.add(
{
targets: "#winloding .d" + (i + 1),
rotate: [
{ value: basevalue, duration: 0, easing: "cubicBezier(0.13,0.21,0.1,0.7)" },
{ value: basevalue + 120, duration: 433, easing: "cubicBezier(0.02,0.33,0.38,0.77)" },
{ value: basevalue + 203, duration: 767, easing: "linear" },
{ value: basevalue + 315, duration: 417, easing: "cubicBezier(0.57,0.17,0.95,0.75)" },
{ value: basevalue + 467, duration: 400, easing: "cubicBezier(0,0.19,0.07,0.72)" },
{ value: basevalue + 549, duration: 766, easing: "linear" },
{ value: basevalue + 695, duration: 434, easing: "cubicBezier(0,0,0.95,0.37)" }
],
opacity: [
{ value: 1, duration: 1, easing: "linear" },
{ value: 1, duration: 3210, easing: "linear" },
{ value: 0, duration: 10, easing: "linear" },
{ value: 0, duration: 260, easing: "linear" }
]
},
167 * i
);
}
ring.timeline = tl;
ring.svgitem = loadingring;
return ring;
}
let ipcRenderer = require('electron').ipcRenderer;
var max = document.getElementById('max');
if (max) {
max.addEventListener('click', () => {
//发送最大化命令
ipcRenderer.send('window-max');
//最大化图形切换
if (max.getAttribute('src') == 'images/max.png') {
max.setAttribute('src', 'images/maxed.png');
} else {
max.setAttribute('src', 'images/max.png');
}
})
}
var min = document.getElementById('min');
if (min) {
min.addEventListener('click', () => {
//发送最小化命令
ipcRenderer.send('window-min');
})
}
document.getElementById('close').addEventListener('click', () => {
//发送关闭命令
ipcRenderer.send('window-close');
})
ipcRenderer.on('main-window-max', (event) => {
max.classList.remove('icon-max');
max.classList.add('icon-maxed');
});
ipcRenderer.on('main-window-unmax', (event) => {
max.classList.remove('icon-maxed');
max.classList.add('icon-max');
});
function jump(text) {
ipcRenderer.send(text);
}