diff options
| author | BigCoke233 <hi@guhub.cn> | 2020-04-15 12:00:52 +0800 |
|---|---|---|
| committer | BigCoke233 <hi@guhub.cn> | 2020-04-15 12:00:52 +0800 |
| commit | ae0351105cebf8a3787d8ebb454a25f80dbe0e6d (patch) | |
| tree | 2c3095a61f5a4f36605724fad6de2736107b4950 /assets | |
| parent | 01b8ec4b5b509a5355b4dd3ca3b914f029e5ee77 (diff) | |
:angel: Add: 自动检测更新
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/css/setting.miracles.css | 4 | ||||
| -rw-r--r-- | assets/js/update.miracles.js | 41 |
2 files changed, 45 insertions, 0 deletions
diff --git a/assets/css/setting.miracles.css b/assets/css/setting.miracles.css index e89430d..7d293d6 100644 --- a/assets/css/setting.miracles.css +++ b/assets/css/setting.miracles.css @@ -75,6 +75,10 @@ hr { font-size: 1.06em
}
+.waiting {
+ color: rgb(230,230,230)
+}
+
@-webkit-keyframes slideDown {
0%{
bottom: -100px;
diff --git a/assets/js/update.miracles.js b/assets/js/update.miracles.js new file mode 100644 index 0000000..da7e21e --- /dev/null +++ b/assets/js/update.miracles.js @@ -0,0 +1,41 @@ +(function($){ + var api = "https://api.github.com/repos/BigCoke233/miracles/releases"; + $.ajax({ + url: api, + type: "GET", + dataType: "json", + success:function(data){ + var latest = data[0]['tag_name']; + var assets_url = data[0]['assets_url']; + + if(version==latest){ + $("#miracles-update").html(",你已经是最新版了!"); + } + else if(version<latest){ + $("#miracles-update").html(",有可下载的新版本("+latest+")"); + $.ajax({ + url: assets_url, + type: "GET", + dataType: "json", + success:function(assets_data){ + var downlink = assets_data[0]['browser_download_url']; + $("#miracles-update").append(',<a href="'+downlink+'" class="miracles-update-down">点击下载最新版</a>。'); + } + }); + } + else if(version>latest){ + $("#miracles-update").html(",看起来你是在使用开发版。"); + } + else { + $("#miracles-update").html(",哇哦,你个 BigHack,居然召唤了根本不可能的错误。"); + } + console.log("Miracles 最新发行版:"+latest); + $("#miracles-update").removeClass("waiting"); + }, + error:function(){ + $("#miracles-update").html("最新版本获取失败,刷新试试?"); + $("#miracles-update").removeClass("waiting").css('color', 'red'); + + } + }); +})(jQuery);
\ No newline at end of file |
