-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
103 lines (90 loc) · 2.56 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>FFMPEG WRAPPER</title>
<link href="static/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="app"></div>
<script>
const electron = require('electron');
const {remote} = electron;
const {Menu, MenuItem} = remote
const {spawn, exec} = require('child_process');
const path = require('path');
const fs = require('fs');
const staticPath = path.join(__dirname, 'static') + '/';
let OS = process.platform;
let ffmpeg = '"' + path.join(__dirname, `static/ffmpeg/${OS}/ffmpeg`) + '"';
if (OS === 'win32') ffmpeg = ffmpeg.replace(/\//g, '\\');
const APP_SETTING = {
getData: function () {
if (typeof(Storage) !== "undefined") {
let data;
try {
data = JSON.parse(localStorage.getItem('setting')) || {};
} catch (e) {
data = {};
}
return data;
} else {
return {};
}
},
setData: function (data) {
localStorage.setItem('setting', JSON.stringify(data));
}
};
// Create menu
const menu = new Menu()
menu.append(new MenuItem({
label: 'About FFMEPG Wrapper',
icon: 'static/img/about-icon.png',
click() {
electron.shell.openExternal('https://huydq.xyz')
}
}))
menu.append(new MenuItem({type: 'separator'}))
menu.append(new MenuItem({
label: 'Source Code (Github)',
icon: 'static/img/github-icon.png',
click() {
electron.shell.openExternal('https://github.com/robinhuy/ffmpeg-wrapper')
}
}))
// Add context menu
window.addEventListener('contextmenu', (e) => {
e.preventDefault()
menu.popup(remote.getCurrentWindow())
}, false)
// Check required libraries
document.addEventListener('DOMContentLoaded', function () {
// Check FFMPEG was installed
exec(ffmpeg + ' -version', (err, stdout, stderr) => {
if (err || stderr) {
alert('Error! Cannot load FFMPEG library');
}
})
// Request enable Desktop Notification
if (Notification && Notification.permission !== 'granted') {
Notification.requestPermission();
}
});
function notifyDesktop(title, message) {
if (Notification && Notification.permission === 'granted') {
// Open Notification
let notification = new Notification(title, {
icon: 'logo.png',
body: message,
});
// Onclick to Notification
notification.onclick = function () {
// todo:Open app window
};
}
}
</script>
<script src="dist/build.js"></script>
</body>
</html>