Skip to content

Commit

Permalink
更新系統
Browse files Browse the repository at this point in the history
  • Loading branch information
gnehs committed Aug 8, 2018
1 parent f415f85 commit d670e40
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ app.get('/upgrade', (req, res) => {
else {
require('simple-git')()
.pull((err, update) => {
if(update && update.summary.changes) {
if (update && update.summary.changes) {
res.send('upgrade')
process.exit()
} else {
res.send('no update')
}
});
}
Expand Down
27 changes: 26 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,11 +872,36 @@ async function show_settings() {
// PokaPlayer 詳細資料
var getinfo = await axios.get('/info/');
var checkupdate = await axios.get(`https://api.github.com/repos/gnehs/PokaPlayer/releases`);
var update = getinfo.data.version != checkupdate.data[0].tag_name ? `新版本已發佈,請立即更新 <a href="${checkupdate.data[0].html_url}" target="_blank">查看更新資訊</a>` : `您的 PokaPlayer 已是最新版本`
var update = getinfo.data.version != checkupdate.data[0].tag_name ? `新版本已發佈,請立即更新 <a href="javascript:void(0)" data-upgrade>更新</a>` : `您的 PokaPlayer 已是最新版本`
var about = `PokaPlayer 是 Synology Audio Ststion 的新朋友! <a href="https://github.com/gnehs/PokaPlayer" target="_blank">GitHub</a>
<p><strong>版本</strong> ${getinfo.data.version} / <strong>開發者</strong> ${getinfo.data.author} / ${update}</p>`
$("#about").html(about)


$("[data-upgrade]").click(function() {
mdui.dialog({
title: '您確定要現在更新嗎',
content: '這將導致您在更新完畢前暫時無法使用 PokaPlayer',
buttons: [{
text: '算ㄌ'
},
{
text: '對啦',
onClick: async function(inst) {
mdui.alert('正在更新');
var update = await axios.get('/upgrade/')
if (update.data == "upgrade") {
mdui.alert('重啟中');
} else {
mdui.alert('更新完畢');
}
}
}
]
});
})


}
//- 播放音樂

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pokaplayer",
"version": "0.4.3",
"version": "0.4.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -31,4 +31,4 @@
"simple-git": "^1.96.0",
"session-file-store": "^1.2.0"
}
}
}

0 comments on commit d670e40

Please sign in to comment.