Add filesize

This commit is contained in:
cutls 2020-05-02 23:32:46 +09:00
parent af3e87b0e3
commit bb71a28375
4 changed files with 157 additions and 146 deletions

View File

@ -1,6 +1,6 @@
//バージョンチェッカー //バージョンチェッカー
function verck(ver, jp) { function verck(ver, jp) {
console.log('%c Welcome😊', 'color: red;font-size:200%;') console.log('%c Welcome😊 ' + ver, 'color: red;font-size:200%;')
var date = new Date() var date = new Date()
var show = false var show = false
if (localStorage.getItem('ver') != ver && localStorage.getItem('winstore')) { if (localStorage.getItem('ver') != ver && localStorage.getItem('winstore')) {

View File

@ -42,7 +42,7 @@ function dl(mainWindow, lang_path, base, dirname) {
filename: file, filename: file,
openFolderWhenDone: true, openFolderWhenDone: true,
onProgress: function(event) { onProgress: function(event) {
e.sender.webContents.send('prog', event) e.sender.webContents.send('prog', [event, args[2]])
}, },
saveAs: false saveAs: false
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "thedesk", "name": "thedesk",
"version": "20.3.2", "version": "20.3.3",
"codename": "Kawaii", "codename": "Kawaii",
"description": "TheDesk is a Mastodon client for PC.", "description": "TheDesk is a Mastodon client for PC.",
"repository": "https://github.com/cutls/TheDesk", "repository": "https://github.com/cutls/TheDesk",

View File

@ -7,14 +7,14 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
@@comment-start@@ @@comment-start@@
<script type="text/javascript"> <script type="text/javascript">
var _jipt = []; var _jipt = []
_jipt.push(["project", "thedesk"]); _jipt.push(['project', 'thedesk'])
</script> </script>
<script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script> <script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script>
@@comment-end@@ @@comment-end@@
<style> <style>
body { body {
font-family: "Open Sans"; font-family: 'Open Sans';
-webkit-app-region: drag; -webkit-app-region: drag;
cursor: move; cursor: move;
padding: 10px; padding: 10px;
@ -112,13 +112,13 @@
<div>@@nextver@@</div> <div>@@nextver@@</div>
</a> </a>
</div> </div>
<a class="pointer waves-effect" onclick="skipper();" style="margin-top:5px">@@continue@@</a> <a class="pointer waves-effect" onclick="skipper();" style="margin-top: 5px;">@@continue@@</a>
</div> </div>
<div id="dlnow" class="hide"> <div id="dlnow" class="hide" style="width: 70%;">
<h4>@@dlnow@@</h4> <h4>@@dlnow@@</h4>
<h4 id="prog"></h4> <h4 id="prog"></h4>
<div class="progress"> <div class="progress">
<div class="determinate" style="width: 0%"></div> <div class="determinate" style="width: 0%;"></div>
</div> </div>
</div> </div>
</div> </div>
@ -126,165 +126,176 @@
<script type="text/javascript" src="../../js/platform/end.js"></script> <script type="text/javascript" src="../../js/platform/end.js"></script>
<script> <script>
function skipper() { function skipper() {
$("#dlnow").addClass("hide"); $('#dlnow').addClass('hide')
$("#box").toggleClass("show"); $('#box').toggleClass('show')
if ($("#box").hasClass("hide") && $("#skipper").hasClass("hide")) { if ($('#box').hasClass('hide') && $('#skipper').hasClass('hide')) {
$("#skipper").removeClass("hide"); $('#skipper').removeClass('hide')
$("#skipper").addClass("show"); $('#skipper').addClass('show')
} else { } else {
$("#box").toggleClass("hide"); $('#box').toggleClass('hide')
$("#skipper").toggleClass("hide"); $('#skipper').toggleClass('hide')
$("#skipper").toggleClass("show"); $('#skipper').toggleClass('show')
} }
} }
verck(); verck()
function update(sel) { function update(sel) {
$("#box").toggleClass("show"); $('#box').toggleClass('show')
$("#box").toggleClass("hide"); $('#box').toggleClass('hide')
$("#dlnow").toggleClass("hide"); $('#dlnow').toggleClass('hide')
$("#dlnow").toggleClass("show"); $('#dlnow').toggleClass('show')
$("#prog").text(""); $('#prog').text('')
var bit = localStorage.getItem("bit"); var bit = localStorage.getItem('bit')
var start = "https://thedesk.top/ver.json"; var start = 'https://thedesk.top/ver.json'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { "content-type": "application/json" } headers: { 'content-type': 'application/json' },
}) })
.then(function (response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function (text) { response.text().then(function (text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text)
}); })
} }
return response.json(); return response.json()
}) })
.catch(function (error) { .catch(function (error) {
todo(error);setLog(start, "JSON", error); todo(error)
console.error(error); setLog(start, 'JSON', error)
console.error(error)
}) })
.then(function (json) { .then(function (json) {
if (sel == "install") { if (sel == 'install') {
if (bit == "x64") { if (bit == 'x64') {
var url = json["winx64"]; var url = json['winx64']
if(localStorage.getItem("dl-win") == "yes") { if (localStorage.getItem('dl-win') == 'yes') {
var file = "TheDesk-" + json.unique + "-setup.exe"; var file = 'TheDesk-' + json.unique + '-setup.exe'
} else { } else {
var file = "TheDesk-setup.exe"; var file = 'TheDesk-setup.exe'
} }
} else if (bit == "ia32") { var filesize = json.winx64_size
var url = json["winia32"]; } else if (bit == 'ia32') {
if(localStorage.getItem("dl-win") == "yes") { var url = json['winia32']
var file = "TheDesk-" + json.unique + "-setup-ia32.exe"; if (localStorage.getItem('dl-win') == 'yes') {
var file = 'TheDesk-' + json.unique + '-setup-ia32.exe'
} else { } else {
var file = "TheDesk-setup-ia32.exe"; var file = 'TheDesk-setup-ia32.exe'
} }
var filesize = json.winia32_size
} }
} else if (sel == "portable") { } else if (sel == 'portable') {
if (bit == "x64") { if (bit == 'x64') {
var url = json["winx64p"]; var url = json['winx64p']
if(localStorage.getItem("dl-win") == "yes") { if (localStorage.getItem('dl-win') == 'yes') {
var file = "TheDesk-" + json.unique + ".exe"; var file = 'TheDesk-' + json.unique + '.exe'
} else { } else {
var file = "TheDesk.exe"; var file = 'TheDesk.exe'
} }
} else if (bit == "ia32") { var filesize = json.winx64p_size
var url = json["winia32p"]; } else if (bit == 'ia32') {
if(localStorage.getItem("dl-win") == "yes") { var url = json['winia32p']
var file = "TheDesk-" + json.unique + "-ia32.exe"; if (localStorage.getItem('dl-win') == 'yes') {
var file = 'TheDesk-' + json.unique + '-ia32.exe'
} else { } else {
var file = "TheDesk-ia32.exe"; var file = 'TheDesk-ia32.exe'
} }
var filesize = json.winia32p_size
} }
} else if (sel == "linux") { } else if (sel == 'linux') {
var url = json["linuxx64"]; var url = json['linuxx64']
if(localStorage.getItem("dl-win") == "yes") { if (localStorage.getItem('dl-win') == 'yes') {
var file = "thedesk-" + json.unique_linux + ".zip"; var file = 'thedesk-' + json.unique_linux + '.zip'
} else { } else {
var file = "thedesk.zip"; var file = 'thedesk.zip'
} }
} else if (sel == "linuxdeb") { var filesize = json.linuxx64_size
var url = json["linuxdeb"]; } else if (sel == 'linuxdeb') {
var file = "thedesk_" + json.unique_linux + "_amd64.deb"; var url = json['linuxdeb']
} else if (sel == "linuxsnap") { var file = 'thedesk_' + json.unique_linux + '_amd64.deb'
var url = json["linuxsnap"]; var filesize = json.linuxdeb_size
var file = "thedesk_" + json.unique_linux + "_amd64.snap"; } else if (sel == 'linuxsnap') {
} else if (sel == "mac") { var url = json['linuxsnap']
var url = json["mac"]; var file = 'thedesk_' + json.unique_linux + '_amd64.snap'
var file = "TheDesk-" + json.unique_mac + ".dmg"; var filesize = json.linuxsnap_size
} else if (sel == 'mac') {
var url = json['mac']
var file = 'TheDesk-' + json.unique_mac + '.dmg'
var filesize = json.mac_size
} }
postMessage(["downloadButton", [url, file]], "*"); postMessage(['downloadButton', [url, file, filesize]], '*')
}); })
} }
function quit() { function quit() {
postMessage(["sendSinmpleIpc", "quit"], "*"); postMessage(['sendSinmpleIpc', 'quit'], '*')
} }
function updateProg(arg) { function updateProg(arg) {
$(".determinate").css("width", arg.percent * 100 + "%"); $('.determinate').css('width', arg[0].percent * 100 + '%')
$("#prog").text(Math.floor(arg.percent * 100) + "%"); $('#prog').html(`${Math.floor(arg[0].percent * 100)}%<br />(${Math.floor(arg[0].percent*arg[1]/1024/1024*10)/10} MB / ${Math.floor(arg[1]/1024/1024*10)/10} MB)`)
} }
function updateMess(arg) { function updateMess(arg) {
console.log(arg); console.log(arg)
$("#prog").text(arg); $('#prog').text(arg)
} }
function verck() { function verck() {
var platform = localStorage.getItem("platform"); var platform = localStorage.getItem('platform')
var bit = localStorage.getItem("bit"); var bit = localStorage.getItem('bit')
if (platform == "win32") { if (platform == 'win32') {
$(".windows").removeClass("hide"); $('.windows').removeClass('hide')
} else if (platform == "linux") { } else if (platform == 'linux') {
$(".linux").removeClass("hide"); $('.linux').removeClass('hide')
} else if (platform == "darwin") { } else if (platform == 'darwin') {
$(".mac").removeClass("hide"); $('.mac').removeClass('hide')
} }
var start = "https://thedesk.top/ver.json"; var start = 'https://thedesk.top/ver.json'
fetch(start, { fetch(start, {
method: "GET", method: 'GET',
headers: { "content-type": "application/json" } headers: { 'content-type': 'application/json' },
}) })
.then(function (response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function (text) { response.text().then(function (text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text)
}); })
} }
return response.json(); return response.json()
}) })
.catch(function (error) { .catch(function (error) {
todo(error);setLog(start, "JSON", error); todo(error)
console.error(error); setLog(start, 'JSON', error)
console.error(error)
}) })
.then(function (json) { .then(function (json) {
console.log(json); console.log(json)
if (platform == "win32") { if (platform == 'win32') {
$("#ver").text(json.desk); $('#ver').text(json.desk)
localStorage.setItem("next-ver", json.desk); localStorage.setItem('next-ver', json.desk)
var url = "https://github.com/cutls/TheDesk/releases/tag/v" + json.unique; var url = 'https://github.com/cutls/TheDesk/releases/tag/v' + json.unique
} else if (platform == "linux") { } else if (platform == 'linux') {
$("#ver").text(json.desk_linux); $('#ver').text(json.desk_linux)
localStorage.setItem("next-ver", json.desk_linux); localStorage.setItem('next-ver', json.desk_linux)
var url = "https://github.com/cutls/TheDesk/releases/tag/v" + json.unique_linux; var url = 'https://github.com/cutls/TheDesk/releases/tag/v' + json.unique_linux
} else if (platform == "darwin") { } else if (platform == 'darwin') {
$("#ver").text(json.desk_mac); $('#ver').text(json.desk_mac)
localStorage.setItem("next-ver", json.desk_mac); localStorage.setItem('next-ver', json.desk_mac)
var url = "https://github.com/cutls/TheDesk/releases/tag/v" + json.unique_mac; var url = 'https://github.com/cutls/TheDesk/releases/tag/v' + json.unique_mac
} }
$("#github").attr("href", url); $('#github').attr('href', url)
$("#now").text(localStorage.getItem("ver")); $('#now').text(localStorage.getItem('ver'))
}); })
} }
function nextv() { function nextv() {
localStorage.setItem("new-ver-skip", "true"); localStorage.setItem('new-ver-skip', 'true')
window.close(); window.close()
} }
function enc(ver) { function enc(ver) {
var ver = ver.replace(/\s/g, ""); var ver = ver.replace(/\s/g, '')
var ver = ver.replace(/\(/g, "-"); var ver = ver.replace(/\(/g, '-')
var ver = ver.replace(/\)/g, ""); var ver = ver.replace(/\)/g, '')
var ver = ver.replace(/\[/g, "_"); var ver = ver.replace(/\[/g, '_')
var ver = ver.replace(/\]/g, ""); var ver = ver.replace(/\]/g, '')
return ver; return ver
} }
</script> </script>
</body> </body>