feat(type): 新增歌曲类型模型与校验;/api/songs 支持按类型过滤;上传页增加类型选择;歌曲选择页支持左右切换类型并显示标签;README 补充说明
This commit is contained in:
@@ -386,6 +386,32 @@ class SongSelect{
|
||||
}
|
||||
|
||||
this.songSelect = document.getElementById("song-select")
|
||||
this.songTypes = [
|
||||
"01 Pop",
|
||||
"02 Anime",
|
||||
"03 Vocaloid",
|
||||
"04 Children and Folk",
|
||||
"05 Variety",
|
||||
"06 Classical",
|
||||
"07 Game Music",
|
||||
"08 Live Festival Mode",
|
||||
"09 Namco Original",
|
||||
"10 Taiko Towers",
|
||||
"11 Dan Dojo",
|
||||
]
|
||||
this.songTypeIndex = Math.max(0, Math.min(this.songTypes.length - 1, +(localStorage.getItem("songTypeIndex") || 0)))
|
||||
this.typeLabel = document.createElement("div")
|
||||
this.typeLabel.style.position = "absolute"
|
||||
this.typeLabel.style.top = "8px"
|
||||
this.typeLabel.style.left = "12px"
|
||||
this.typeLabel.style.padding = "4px 8px"
|
||||
this.typeLabel.style.background = "rgba(0,0,0,0.5)"
|
||||
this.typeLabel.style.color = "#fff"
|
||||
this.typeLabel.style.borderRadius = "6px"
|
||||
this.typeLabel.style.fontSize = "14px"
|
||||
this.typeLabel.style.zIndex = "10"
|
||||
this.songSelect.appendChild(this.typeLabel)
|
||||
this.updateTypeLabel()
|
||||
var cat = this.songs[this.selectedSong].originalCategory
|
||||
this.drawBackground(cat)
|
||||
|
||||
@@ -536,24 +562,20 @@ class SongSelect{
|
||||
this.toSession()
|
||||
}else if(name === "left"){
|
||||
if(shift){
|
||||
if(!repeat){
|
||||
this.categoryJump(-1)
|
||||
}
|
||||
if(!repeat){ this.changeType(-1) }
|
||||
}else{
|
||||
this.moveToSong(-1)
|
||||
}
|
||||
}else if(name === "right"){
|
||||
if(shift){
|
||||
if(!repeat){
|
||||
this.categoryJump(1)
|
||||
}
|
||||
if(!repeat){ this.changeType(1) }
|
||||
}else{
|
||||
this.moveToSong(1)
|
||||
}
|
||||
}else if(name === "jump_left" && !repeat){
|
||||
this.categoryJump(-1)
|
||||
this.changeType(-1)
|
||||
}else if(name === "jump_right" && !repeat){
|
||||
this.categoryJump(1)
|
||||
this.changeType(1)
|
||||
}else if(name === "mute" || name === "ctrlGamepad"){
|
||||
this.endPreview(true)
|
||||
this.playBgm(false)
|
||||
@@ -597,6 +619,23 @@ class SongSelect{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateTypeLabel(){
|
||||
this.setAltText(this.typeLabel, this.songTypes[this.songTypeIndex])
|
||||
}
|
||||
|
||||
changeType(delta){
|
||||
this.songTypeIndex = (this.songTypeIndex + delta + this.songTypes.length) % this.songTypes.length
|
||||
localStorage.setItem("songTypeIndex", this.songTypeIndex)
|
||||
this.updateTypeLabel()
|
||||
var type = encodeURIComponent(this.songTypes[this.songTypeIndex])
|
||||
loader.ajax("api/songs?type=" + type).then(resp => {
|
||||
var songs = JSON.parse(resp)
|
||||
assets.songsDefault = songs
|
||||
assets.songs = assets.songsDefault
|
||||
new SongSelect(false, false, this.touchEnabled)
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
mouseDown(event){
|
||||
if(event.target === this.selectable || event.target.parentNode === this.selectable){
|
||||
|
||||
Reference in New Issue
Block a user