项目文件夹

文件
T
caorushizi 7eb5ef0d54 v0.0.1
2020-03-23 23:38:25 +08:00

35 行
1.1 KiB
JavaScript

const {remote} = require("electron");
const native = require("../build/Release/addon");
window.addEventListener('DOMContentLoaded', () => {
$("#alert").hide();
// m3u8 文件地址
$("#exampleInputEmail1").val("https://www.yxlmbbs.com:65/20200318/6PnR6gn6/1500kb/hls/index.m3u8");
// 选择文件夹按钮
$("#selectFolder").click(() => {
remote.dialog.showOpenDialog({
defaultPath: remote.app.getPath("downloads"),
properties: ["openDirectory"]
}).then(({filePaths}) => {
if (filePaths.length !== 1) {
return false
}
$("#folder").val(filePaths[0])
})
});
$("#startDownload").click((event) => {
event.preventDefault();
const nameValue = $("#exampleInputPassword1").val();
const pathValue = $("#folder").val();
const urlValue = $("#exampleInputEmail1").val();
if (nameValue && pathValue && urlValue) {
$("#alert").hide();
console.log(native.add(nameValue, pathValue, urlValue))
} else {
$("#alert").show()
}
});
});