This repository has been archived by the owner on Jul 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
109 lines (91 loc) · 2.69 KB
/
start.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
const remote = require('electron').remote;
const ipc = require('electron').ipcRenderer;
const fs = require("fs");
setInterval(() => {
let songName = document.getElementById("iframe").contentWindow.document.getElementById("mainFrame").contentWindow.document.getElementById("shareMediaSongName").innerHTML;
document.getElementById("fun-songName").value = songName;
mdui.mutation();
}, 1000);
setTimeout(() => {
setInterval(() => {
let cacheSize = ipc.sendSync('session', 1);
document.getElementById("cacheSize").value = cacheSize;
document.getElementById("iframe").height = 590 + (hei - 700);
mdui.mutation();
}, 500);
}, 1000);
setInterval(() => {
saveConfig();
}, 10000);
var hei;
var mode;
ipc.on('resize', function (event, data) {
if (!data[2]) {
document.getElementById("config-w").value = data[0];
document.getElementById("config-h").value = data[1];
}
document.getElementById("iframe").height = 590 + (data[1] - 700);
hei = data[1];
});
fs.readFile(`./config.json`, (err, data) => {
if (!err) {
let obj = JSON.parse(data.toString());
console.log(obj);
let w = obj.window.w;
let h = obj.window.h;
let r = obj.window.r;
hei = h;
document.getElementById("config-w").value = w;
document.getElementById("config-h").value = h;
}
});
function reload() {
ipc.send('reload', 1);
}
function switchWindow(name) {
mode = name;
saveConfig(true);
reload();
}
function saveConfig(isSync) {
let w = document.getElementById("config-w").value;
let h = document.getElementById("config-h").value;
w = Number(w);
h = Number(h);
document.getElementById("iframe").height = 590 + (h - 700);
let data = JSON.stringify({
window: {
w: w,
h: h
},
mode: mode
});
if (!isSync)
fs.writeFile("./config.json", data, (err) => {
if (err) {
mdui.snackbar({
message: '保存失败',
position: 'right-bottom',
timeout: 5000
});
} else {}
});
else fs.writeFileSync("./config.json", data);
}
function close() {
var window = remote.getCurrentWindow();
window.close();
}
function min() {
var window = remote.getCurrentWindow();
window.minimize();
}
ipc.once('system-type', function (event, e) {
let systemType = document.getElementById("system-type");
systemType.innerHTML = "for " + e;
});
ipc.send('system-type', 'type');
mdui.mutation();
function about() {
mdui.alert(`<div class="mdui-typo">GitHub: <p>irose-tools/electron-iirose</p></div>`, "关于");
}