Add, Fix: percent, versioning, start

This commit is contained in:
cutls 2020-04-07 14:00:20 +09:00
parent 6fbfdf0323
commit 429a5c764f
7 changed files with 65 additions and 34 deletions

View File

@ -34,11 +34,12 @@ function dl(mainWindow, lang_path, base, dirname) {
}
})
//アプデDL
ipc.on('download-btn', (e, args) => {
ipc.on('download-btn', async (e, args) => {
function dl(url, file, dir, e) {
e.sender.webContents.send('mess', 'ダウンロードを開始します。')
const opts = {
directory: dir,
filename: file,
openFolderWhenDone: true,
onProgress: function(event) {
e.sender.webContents.send('prog', event)
@ -54,29 +55,27 @@ function dl(mainWindow, lang_path, base, dirname) {
}
var platform = process.platform
var bit = process.arch
dialog.showSaveDialog(
null,
{
title: 'Save',
defaultPath: app.getPath('home') + '/' + args[1]
},
savedFiles => {
console.log(savedFiles)
if (!savedFiles) {
return false
}
if (platform == 'win32') {
var m = savedFiles.match(/(.+)\\(.+)$/)
} else {
var m = savedFiles.match(/(.+)\/(.+)$/)
}
//console.log(m);
if (isExistFile(savedFiles)) {
fs.unlinkSync(savedFiles)
}
dl(args[0], args[1], m[1], e)
}
)
var options = {
title: 'Save',
defaultPath: app.getPath('home') + '/' + args[1]
}
const file = await dialog.showSaveDialog(null, options)
const savedFiles = file.filePath
console.log(savedFiles)
if (!savedFiles) {
return false
}
if (platform == 'win32') {
var m = savedFiles.match(/(.+)\\(.+)$/)
} else {
var m = savedFiles.match(/(.+)\/(.+)$/)
}
//console.log(m);
if (isExistFile(savedFiles)) {
fs.unlinkSync(savedFiles)
}
console.log(m)
dl(args[0], m[2], m[1], e)
})
function isExistFile(file) {

View File

@ -18,7 +18,7 @@
"hardwareAcceleration": "Disable hardware acceleration",
"hardwareAccelerationWarn": "Auto restarted",
"theme": "Themes",
"popup": "Popup notification(on Windows)",
"popup": "Popup notification",
"popupwarn": "Hide to set \"0\"",
"s": "sec",
"nativenotf": "Native notification",
@ -38,6 +38,7 @@
"useragentWarn":"Restart when changed",
"frame": "Window frame",
"frameWarn": "If 'off', the window looks cool.",
"downloadWin": "Versioning(o Windows downloader)",
"absolute": "absolute value",
"srcUrl": "Search engine",
"srcUrlWarn": "{q} will be replaced to query.",

View File

@ -37,6 +37,7 @@
"useragentWarn":"再起動すんで。",
"frame": "ウィンドウのフレーム",
"frameWarn": "フレーム無しやとタイトルバーがシュッとするで。再起動すんで。",
"downloadWin": "バージョニングする(Windowsのダウンローダ)",
"absolute": "絶対指定",
"srcUrl": "検索エンジン",
"srcUrlWarn": "{q}が検索文字列になるで。",

View File

@ -38,6 +38,7 @@
"useragentWarn":"再起動します。",
"frame": "ウィンドウのフレーム",
"frameWarn": "フレーム無しだと、タイトルバーのデザインがクールになります。再起動します。",
"downloadWin": "バージョニングする(Windowsのダウンローダ)",
"absolute": "絶対指定",
"srcUrl": "検索エンジン",
"srcUrlWarn": "{q}が検索文字列に置換されます。",

View File

@ -1,4 +1,4 @@
let ver = '20.2.0 (Kawaii)'
let ver = '20.2.1 (Kawaii)'
if (process.argv.indexOf('--automatic') === -1) {
let input = require('readline-sync').question('version string [empty: ' + ver + ' (default)]? ')
if (input) {

View File

@ -162,6 +162,16 @@ var envConstruction = [
}
]
}
},{
id: 'download',
storage: 'dl-win',
checkbox: true,
setValue: 'no',
text: {
head: '@@downloadWin@@',
desc: 'ex: TheDesk-1.0.0-setup.exe',
checkbox: yesno
}
}
]
var tlConstruction = [

View File

@ -166,22 +166,42 @@
if (sel == "install") {
if (bit == "x64") {
var url = json["winx64"];
var file = "TheDesk-setup.exe";
if(localStorage.getItem("dl-win") == "yes") {
var file = "TheDesk-" + json.unique + "-setup.exe";
} else {
var file = "TheDesk-setup.exe";
}
} else if (bit == "ia32") {
var url = json["winia32"];
var file = "TheDesk-setup-ia32.exe";
if(localStorage.getItem("dl-win") == "yes") {
var file = "TheDesk-" + json.unique + "-setup-ia32.exe";
} else {
var file = "TheDesk-setup-ia32.exe";
}
}
} else if (sel == "portable") {
if (bit == "x64") {
var url = json["winx64p"];
var file = "TheDesk.exe";
if(localStorage.getItem("dl-win") == "yes") {
var file = "TheDesk-" + json.unique + ".exe";
} else {
var file = "TheDesk.exe";
}
} else if (bit == "ia32") {
var url = json["winia32p"];
var file = "TheDesk-ia32.exe";
if(localStorage.getItem("dl-win") == "yes") {
var file = "TheDesk-" + json.unique + "-ia32.exe";
} else {
var file = "TheDesk-ia32.exe";
}
}
} else if (sel == "linux") {
var url = json["linuxx64"];
var file = "thedesk.zip";
if(localStorage.getItem("dl-win") == "yes") {
var file = "thedesk-" + json.unique_linux + ".zip";
} else {
var file = "thedesk.zip";
}
} else if (sel == "linuxdeb") {
var url = json["linuxdeb"];
var file = "thedesk_" + json.unique_linux + "_amd64.deb";
@ -199,9 +219,8 @@
postMessage(["sendSinmpleIpc", "quit"], "*");
}
function updateProg(arg) {
console.log(arg);
$(".determinate").css("width", arg * 100 + "%");
$("#prog").text(Math.floor(arg * 100) + "%");
$(".determinate").css("width", arg.percent * 100 + "%");
$("#prog").text(Math.floor(arg.percent * 100) + "%");
}
function updateMess(arg) {
console.log(arg);