About update-check #141

This commit is contained in:
cutls 2019-10-20 20:04:00 +09:00
parent 4f858cf7d6
commit b3ca402842
5 changed files with 61 additions and 8 deletions

View File

@ -715,3 +715,41 @@ window.onload = function () {
function asReadEnd() {
postMessage(["asReadComp", ""], "*")
}
function checkupd(){
var ver = localStorage.getItem("ver");
var start = "https://thedesk.top/ver.json";
fetch(start, {
method: 'GET'
}).then(function (response) {
return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
}).then(function (mess) {
console.table(mess);
if (mess) {
var platform = localStorage.getItem("platform");
if (platform == "darwin") {
var newest = mess.desk_mac;
} else {
var newest = mess.desk;
}
if (newest == ver) {
Swal.fire({
type: 'info',
title: lang.lang_setting_noupd,
html: ver
})
} else if (ver.indexOf("beta") != -1 || winstore) {
Swal.fire({
type: 'info',
title: lang.lang_setting_thisisbeta,
html: ver
})
} else {
localStorage.removeItem("new-ver-skip")
location.href="index.html"
}
}
});
}

View File

@ -249,5 +249,7 @@
"lang_setting_notftest": " Notification test ",
"lang_setting_notftestprof": "Your icon is shown.",
"lang_setting_exportwarn": "Only important data will be exported. You must keep this data secure.",
"lang_setting_importwarn": "All data will be deleted."
"lang_setting_importwarn": "All data will be deleted.",
"lang_setting_noupd": "No available update",
"lang_setting_thisisbeta": "This is beta version. You have to update manually."
}

View File

@ -249,5 +249,7 @@
"lang_setting_notftest": "通知テスト",
"lang_setting_notftestprof": "アイコンはあなたのアカウントのものです。",
"lang_setting_exportwarn": "重要なデータのみエクスポートされます。エクスポートされたデータは外部に公開しないでください。全ての認証データが含まれています。",
"lang_setting_importwarn": "全てのデータがリセットされます。"
"lang_setting_importwarn": "全てのデータがリセットされます。",
"lang_setting_noupd": "お使いのTheDeskは最新です",
"lang_setting_thisisbeta": "お使いのTheDeskはベータ版のため、アップデートは手動で行う必要があります。"
}

View File

@ -4,10 +4,13 @@ if (process.argv.indexOf("--automatic") === -1) {
if (input) {
ver = input;
}
var basefile="../../"
//var basefile="../../"
} else {
var basefile="./"
//var basefile="./"
}
//const { app } = require('electron');
const path = require('path');
const basefile = path.join(__dirname, "../../")
function main(ver, basefile) {
const fs = require("fs");
const execSync = require("child_process").execSync;
@ -23,6 +26,7 @@ function main(ver, basefile) {
const pages = ["acct.html", "index.html", "setting.html", "update.html", "setting.vue.js"];
let langstr = "";
let refKey = [];
const enJson=JSON.parse(fs.readFileSync(basefile + "view/make/language/en/main.json", "utf8"))
for (let n = 0; n < langs.length; n++) {
let lang = langs[n];
let targetDir = basefile + "view/" + lang;
@ -30,7 +34,15 @@ function main(ver, basefile) {
fs.mkdirSync(targetDir);
}
langstr = langstr + "<a onclick=\"changelang('" + lang + '\')" class="pointer" style="margin:4px;border: 1px solid var(--color); padding: 3px">' + langsh[n] + "</a>";
fs.writeFileSync(basefile + "view/" + lang + "/main.js", fs.readFileSync(basefile + "view/make/language/" + lang + "/main.json", "utf8").replace(/^{/, "var lang = {"));
let mainJson=JSON.parse(fs.readFileSync(basefile + "view/make/language/" + lang + "/main.json", "utf8"))
if(lang != "en"){
Object.keys(enJson).forEach(function(key) {
if(!mainJson[key]){
mainJson[key]=enJson[key]
}
});
}
fs.writeFileSync(basefile + "view/" + lang + "/main.js", JSON.stringify(mainJson).replace(/^{/, "var lang = {"));
}
for (let i = 0; i < samples.length; i++) {
let sample = samples[i];

View File

@ -511,12 +511,11 @@
style="width:100%; max-width:500px;"><img src="../../img/desk_full.svg" class="left" width="25"
style="padding-top:5px;">Main author: Cutls@cutls.com</a>
<br>
TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/@@gitHash@@">@@gitHash@@</a><br>
TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/@@gitHash@@">@@gitHash@@</a> - <a onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';"
class="pointer">@@checkup@@</a><br>
<br>
Kyash<br>
<img src="../../img/kyash.png" width="100"><br>
<a onclick="localStorage.removeItem('new-ver-skip'); location.href='index.html';"
class="pointer">@@checkup@@</a><br>
<a href="https://status.cutls.com/">
<img src="https://status.cutls.com/badge-service?site=thedesk.top">
</a><br>