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){
|
||||
|
||||
@@ -16,6 +16,21 @@
|
||||
|
||||
<label for="file_music">音楽ファイル:</label>
|
||||
<input type="file" name="file_music" accept=".ogg,.mp3,.wav" required>
|
||||
|
||||
<label for="song_type">曲のタイプ:</label>
|
||||
<select name="song_type" required>
|
||||
<option value="01 Pop">01 Pop</option>
|
||||
<option value="02 Anime">02 Anime</option>
|
||||
<option value="03 Vocaloid">03 Vocaloid</option>
|
||||
<option value="04 Children and Folk">04 Children and Folk</option>
|
||||
<option value="05 Variety">05 Variety</option>
|
||||
<option value="06 Classical">06 Classical</option>
|
||||
<option value="07 Game Music">07 Game Music</option>
|
||||
<option value="08 Live Festival Mode">08 Live Festival Mode</option>
|
||||
<option value="09 Namco Original">09 Namco Original</option>
|
||||
<option value="10 Taiko Towers">10 Taiko Towers</option>
|
||||
<option value="11 Dan Dojo">11 Dan Dojo</option>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<button type="button" onclick="uploadFiles()">今すぐ投稿! (1分ほどかかる場合があります)</button>
|
||||
|
||||
Reference in New Issue
Block a user