Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  偵錯模式下的版本號改為 commit hash
  偵錯模式下永遠顯示同步按鈕
  修正若干語法和細節錯誤
  修正 git 指令順序
  修正一個檢測當前分支時的錯誤
  修正 git 在切換 branch 時的錯誤
  大量寫法改進
  • Loading branch information
lekoOwO committed Aug 12, 2018
2 parents 81e92e2 + f3a9eca commit 37bed11
Show file tree
Hide file tree
Showing 7 changed files with 692 additions and 699 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ app.get('/info', (req, res) => {
}
})

if (config.PokaPlayer.debug) app.get('/debug', (req, res) => {
res.send('true')
app.get('/debug', async(req, res) => {
res.send(config.PokaPlayer.debug ? (await git.raw(['rev-parse', '--short', 'HEAD'])).slice(0,-1) : 'false')
})

// get song
Expand Down
35 changes: 18 additions & 17 deletions js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ function getBackground() {
}
//- 取得封面
function getCover(type, info, artist_name, album_artist_name) {
let url;
if (type == "album") {
var q = ''
let q = ''
q += info ? `&album_name=${encodeURIComponent(info)}` : ``
q += artist_name ? `&artist_name=${encodeURIComponent(artist_name)}` : ``
q += album_artist_name ? `&album_artist_name=${encodeURIComponent(album_artist_name)}` : `&album_artist_name=`
var url = `/cover/album/` + pp_encode(q)
url = `/cover/album/` + ppEncode(q)
} else {
var url = `/cover/${encodeURIComponent(type)}/${encodeURIComponent(info)}`
url = `/cover/${encodeURIComponent(type)}/${encodeURIComponent(info)}`
}
if (window.localStorage["imgRes"] == "true")
return getBackground()
Expand All @@ -24,27 +25,27 @@ function getCover(type, info, artist_name, album_artist_name) {

//- 取得歌詞
async function getLrc(artist, title) {
var PARAMS_JSON = [
let PARAMS_JSON = [
{ key: "additional", "value": "full_lyrics" },
{ key: "limit", "value": 1 }
]
if (artist) PARAMS_JSON.push({ key: "artist", "value": artist })
if (title) PARAMS_JSON.push({ key: "title", "value": title })
var lrc = await getAPI("AudioStation/lyrics_search.cgi", "SYNO.AudioStation.LyricsSearch", "searchlyrics", PARAMS_JSON, 2)
let lrc = await getAPI("AudioStation/lyrics_search.cgi", "SYNO.AudioStation.LyricsSearch", "searchlyrics", PARAMS_JSON, 2)
return lrc.data

}
async function getLrcByID(id) {
var lrc = await getAPI("AudioStation/lyrics.cgi", "SYNO.AudioStation.Lyrics", "getlyrics", [{ key: "id", "value": id }], 2)
let lrc = await getAPI("AudioStation/lyrics.cgi", "SYNO.AudioStation.Lyrics", "getlyrics", [{ key: "id", "value": id }], 2)
return lrc.data
}


//- 取得歌曲連結
function getSong(song) {
var id = song.id
var res = window.localStorage["musicRes"]
var bitrate = song.additional.song_audio.bitrate / 1000
let id = song.id
let res = window.localStorage["musicRes"]
let bitrate = song.additional.song_audio.bitrate / 1000
if (res == "wav" && bitrate > 320)
res = "wav"
else
Expand All @@ -54,7 +55,7 @@ function getSong(song) {

//- 取得專輯歌曲
async function getAlbumSong(album_name, album_artist_name, artist_name) {
var PARAMS_JSON = [
let PARAMS_JSON = [
{ key: "additional", "value": "song_tag,song_audio,song_rating" },
{ key: "library", "value": "shared" },
{ key: "limit", "value": 100000 },
Expand All @@ -64,36 +65,36 @@ async function getAlbumSong(album_name, album_artist_name, artist_name) {
if (album_name) PARAMS_JSON.push({ key: "album", "value": album_name })
if (album_artist_name) PARAMS_JSON.push({ key: "album_artist", "value": album_artist_name })
if (artist_name) PARAMS_JSON.push({ key: "artist", "value": artist_name })
var info = await getAPI("AudioStation/song.cgi", "SYNO.AudioStation.Song", "list", PARAMS_JSON, 3)
let info = await getAPI("AudioStation/song.cgi", "SYNO.AudioStation.Song", "list", PARAMS_JSON, 3)
return info
}
//- 取得搜尋結果
async function searchAll(keyword) {
var PARAMS_JSON = [
let PARAMS_JSON = [
{ key: "additional", "value": "song_tag,song_audio,song_rating" },
{ key: "library", "value": "shared" },
{ key: "limit", "value": 1000 },
{ key: "sort_by", "value": "title" },
{ key: "sort_direction", "value": "ASC" },
{ key: "keyword", "value": keyword },
]
var result = await getAPI("AudioStation/search.cgi", "SYNO.AudioStation.Search", "list", PARAMS_JSON, 1)
let result = await getAPI("AudioStation/search.cgi", "SYNO.AudioStation.Search", "list", PARAMS_JSON, 1)
return result.data
}
//- API 請求
async function getAPI(CGI_PATH, API_NAME, METHOD, PARAMS_JSON = [], VERSION = 1) {
var PARAMS = ''
let PARAMS = ''
for (i = 0; i < PARAMS_JSON.length; i++) { 
var PARAMS = PARAMS + '&' + PARAMS_JSON[i].key + '=' + encodeURIComponent(PARAMS_JSON[i].value)
PARAMS += '&' + PARAMS_JSON[i].key + '=' + encodeURIComponent(PARAMS_JSON[i].value)
}
var req_json = {
let req_json = {
"CGI_PATH": CGI_PATH,
"API_NAME": API_NAME,
"METHOD": METHOD,
"VERSION": VERSION,
"PARAMS": PARAMS
}
req_json = JSON.stringify(req_json)
const response = await axios.get('/api/' + pp_encode(req_json));
const response = await axios.get('/api/' + ppEncode(req_json));
return response.data
}
4 changes: 2 additions & 2 deletions js/color-theme.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(function() {
$(() => {
// 檢查有沒有設定顏色
if (!window.localStorage["mdui-theme-primary"])
window.localStorage["mdui-theme-primary"] = "indigo"
Expand All @@ -12,6 +12,6 @@ $(function() {
$('body').addClass("mdui-theme-layout-dark")

// 設定狀態欄顏色
var metaThemeColor = document.querySelector("meta[name=theme-color]");
let metaThemeColor = document.querySelector("meta[name=theme-color]");
metaThemeColor.setAttribute("content", $('header>div:first-child').css("background-color"));
});
Loading

0 comments on commit 37bed11

Please sign in to comment.