Compare commits
1 Commits
6d7be5c45c
...
recorded-v
| Author | SHA1 | Date | |
|---|---|---|---|
| f4d75068ba |
@@ -1,9 +0,0 @@
|
|||||||
I will implement the requested changes to remove the delete functionality and redirect the upload interface while keeping the upload API intact.
|
|
||||||
|
|
||||||
### 1. Frontend: Song Selection Menu (`public/src/js/songselect.js`)
|
|
||||||
* **Remove Delete Button**: I will remove the "Delete" (削除) button configuration from the `difficultyMenu` buttons array (around lines 313-319). This removes the option from the UI.
|
|
||||||
* **Redirect Upload Action**: I will modify the handler for the "upload" action (around lines 954-958). Instead of redirecting to the local `/upload/` page, it will redirect to `https://zizhipu.taiko.asia`.
|
|
||||||
|
|
||||||
### 2. Backend: API Security (`app.py`)
|
|
||||||
* **Disable Delete API**: I will modify the `/api/delete` route to return a 403 Forbidden error (or simply pass), ensuring that songs cannot be deleted even if someone calls the API directly.
|
|
||||||
* **Keep Upload API**: The `/api/upload` route will remain unchanged, preserving the ability to upload songs via API as requested.
|
|
||||||
13
app.py
13
app.py
@@ -911,8 +911,19 @@ def upload_file():
|
|||||||
return flask.jsonify({'success': True})
|
return flask.jsonify({'success': True})
|
||||||
|
|
||||||
@app.route("/api/delete", methods=["POST"])
|
@app.route("/api/delete", methods=["POST"])
|
||||||
|
@limiter.limit("1 per day")
|
||||||
def delete():
|
def delete():
|
||||||
return flask.jsonify({ "success": False, "reason": "Deletion is disabled" }), 403
|
id = flask.request.get_json().get('id')
|
||||||
|
client["taiko"]["songs"].delete_one({ "id": id })
|
||||||
|
|
||||||
|
parent_dir = pathlib.Path(os.getenv("TAIKO_WEB_SONGS_DIR", "public/songs"))
|
||||||
|
target_dir = parent_dir / id
|
||||||
|
if not (target_dir.resolve().parents and parent_dir.resolve() in target_dir.resolve().parents):
|
||||||
|
return flask.jsonify({ "success": False, "reason": "PARENT IS NOT ALLOWED" })
|
||||||
|
|
||||||
|
shutil.rmtree(target_dir)
|
||||||
|
|
||||||
|
return "成功しました。"
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ var assets = {
|
|||||||
"js": [
|
"js": [
|
||||||
"lib/md5.min.js",
|
"lib/md5.min.js",
|
||||||
"lib/fuzzysort.js",
|
"lib/fuzzysort.js",
|
||||||
|
"cookie.js",
|
||||||
"loadsong.js",
|
"loadsong.js",
|
||||||
"parseosu.js",
|
"parseosu.js",
|
||||||
"titlescreen.js",
|
"titlescreen.js",
|
||||||
|
|||||||
41
public/src/js/cookie.js
Normal file
41
public/src/js/cookie.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
var cookie = {
|
||||||
|
get: function(name){
|
||||||
|
var pairs = document.cookie ? document.cookie.split("; ") : []
|
||||||
|
for(var i = 0; i < pairs.length; i++){
|
||||||
|
var idx = pairs[i].indexOf("=")
|
||||||
|
var key = idx > -1 ? pairs[i].slice(0, idx) : pairs[i]
|
||||||
|
if(key === name){
|
||||||
|
var val = idx > -1 ? pairs[i].slice(idx + 1) : ""
|
||||||
|
try{
|
||||||
|
return decodeURIComponent(val)
|
||||||
|
}catch(e){
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
set: function(name, value, maxAge){
|
||||||
|
var v = typeof value === "string" ? value : String(value)
|
||||||
|
document.cookie = name + "=" + encodeURIComponent(v) + ";path=/" + (maxAge ? ";max-age=" + maxAge : "")
|
||||||
|
},
|
||||||
|
getJSON: function(name){
|
||||||
|
var v = this.get(name)
|
||||||
|
if(!v){
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
return JSON.parse(v)
|
||||||
|
}catch(e){
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updateJSON: function(name, updater, maxAge){
|
||||||
|
var obj = this.getJSON(name)
|
||||||
|
var next = updater && updater(obj) || obj
|
||||||
|
try{
|
||||||
|
this.set(name, JSON.stringify(next), maxAge)
|
||||||
|
}catch(e){}
|
||||||
|
return next
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
class ImportSongs{
|
class ImportSongs{
|
||||||
constructor(...args){
|
constructor(...args){
|
||||||
this.init(...args)
|
this.init(...args)
|
||||||
}
|
}
|
||||||
@@ -322,10 +322,6 @@ class ImportSongs{
|
|||||||
songTitle = songTitle.slice(0, uraPos)
|
songTitle = songTitle.slice(0, uraPos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(id === "cn" && !meta["titlecn"] && meta.titlezh){
|
|
||||||
titleLang.cn = meta.titlezh
|
|
||||||
titleLangAdded = true
|
|
||||||
}
|
|
||||||
if(meta["title" + id]){
|
if(meta["title" + id]){
|
||||||
titleLang[id] = meta["title" + id]
|
titleLang[id] = meta["title" + id]
|
||||||
titleLangAdded = true
|
titleLangAdded = true
|
||||||
@@ -333,10 +329,6 @@ class ImportSongs{
|
|||||||
titleLang[id] = this.songTitle[songTitle][id] + ura
|
titleLang[id] = this.songTitle[songTitle][id] + ura
|
||||||
titleLangAdded = true
|
titleLangAdded = true
|
||||||
}
|
}
|
||||||
if(id === "cn" && !meta["subtitlecn"] && meta.subtitlezh){
|
|
||||||
subtitleLang.cn = meta.subtitlezh
|
|
||||||
subtitleLangAdded = true
|
|
||||||
}
|
|
||||||
if(meta["subtitle" + id]){
|
if(meta["subtitle" + id]){
|
||||||
subtitleLang[id] = meta["subtitle" + id]
|
subtitleLang[id] = meta["subtitle" + id]
|
||||||
subtitleLangAdded = true
|
subtitleLangAdded = true
|
||||||
|
|||||||
@@ -949,6 +949,21 @@ class Scoresheet{
|
|||||||
this.showWarning = {name: "scoreSaveFailed"}
|
this.showWarning = {name: "scoreSaveFailed"}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
var key = "taiko_best_records"
|
||||||
|
var obj = cookie.getJSON(key)
|
||||||
|
if(!(hash in obj)){
|
||||||
|
obj[hash] = {}
|
||||||
|
}
|
||||||
|
var prev = obj[hash][difficulty]
|
||||||
|
var total = this.resultsObj.good + this.resultsObj.ok + this.resultsObj.bad
|
||||||
|
var acc = total > 0 ? Math.round(((this.resultsObj.good + this.resultsObj.ok) / total) * 1000) / 10 : 0
|
||||||
|
var combo = this.resultsObj.maxCombo || 0
|
||||||
|
var points = this.resultsObj.points || 0
|
||||||
|
var update = !prev || points > prev.score || (points === prev.score && (acc > prev.accuracy || combo > prev.combo))
|
||||||
|
if(update){
|
||||||
|
obj[hash][difficulty] = {score: points, accuracy: acc, combo: combo, updatedAt: Date.now()}
|
||||||
|
try{ cookie.set(key, JSON.stringify(obj), 31536000) }catch(e){}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.scoreSaved = true
|
this.scoreSaved = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,6 +310,12 @@ class SongSelect{
|
|||||||
iconName: "download",
|
iconName: "download",
|
||||||
iconFill: "#e7cbe1",
|
iconFill: "#e7cbe1",
|
||||||
letterSpacing: 4
|
letterSpacing: 4
|
||||||
|
}, {
|
||||||
|
text: "削除",
|
||||||
|
fill: "silver",
|
||||||
|
iconName: "trash",
|
||||||
|
iconFill: "#111111",
|
||||||
|
letterSpacing: 4
|
||||||
}]
|
}]
|
||||||
this.optionsList = [strings.none, strings.auto, strings.netplay]
|
this.optionsList = [strings.none, strings.auto, strings.netplay]
|
||||||
|
|
||||||
@@ -948,7 +954,7 @@ class SongSelect{
|
|||||||
} else if (currentSong.action === "upload") {
|
} else if (currentSong.action === "upload") {
|
||||||
this.playSound("se_don");
|
this.playSound("se_don");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = "https://zizhipu.taiko.asia";
|
window.location.href = "/upload/";
|
||||||
}, 100);
|
}, 100);
|
||||||
} else if (currentSong.action === "keijiban") {
|
} else if (currentSong.action === "keijiban") {
|
||||||
this.playSound("se_don");
|
this.playSound("se_don");
|
||||||
@@ -1983,6 +1989,37 @@ class SongSelect{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var recAll = cookie.getJSON("taiko_best_records")
|
||||||
|
var bySong = recAll[currentSong.hash] || null
|
||||||
|
var diffName = currentUra ? "ura" : this.difficultyId[i]
|
||||||
|
var rec = bySong && bySong[diffName] || null
|
||||||
|
var elapsedMS2 = Math.max(this.state.screenMS, this.state.moveMS, this.state.mouseMoveMS)
|
||||||
|
var cycle = Math.floor(((ms - elapsedMS2) % 6000) / 2000)
|
||||||
|
var label = ""
|
||||||
|
if(rec){
|
||||||
|
if(cycle === 0){
|
||||||
|
label = (strings.bestAccuracy || "良率") + " " + (Math.round(rec.accuracy * 10) / 10) + "%"
|
||||||
|
}else if(cycle === 1){
|
||||||
|
label = (strings.bestCombo || "连打数") + " " + rec.combo
|
||||||
|
}else{
|
||||||
|
label = (strings.bestScore || "总分") + " " + rec.score
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
label = (strings.none || "无")
|
||||||
|
}
|
||||||
|
this.draw.verticalText({
|
||||||
|
ctx: ctx,
|
||||||
|
text: label,
|
||||||
|
x: _x,
|
||||||
|
y: songSel ? _y + 220 : _y + 265,
|
||||||
|
width: songSel ? 44 : 56,
|
||||||
|
height: songSel ? 120 : 135,
|
||||||
|
fill: currentUra ? "#fff" : "#000",
|
||||||
|
outline: currentUra ? "#003C52" : false,
|
||||||
|
outlineSize: currentUra ? this.songAsset.letterBorder : 0,
|
||||||
|
fontSize: songSel ? 22 : 24,
|
||||||
|
fontFamily: this.font
|
||||||
|
})
|
||||||
}
|
}
|
||||||
var currentDiff = this.selectedDiff - this.diffOptions.length
|
var currentDiff = this.selectedDiff - this.diffOptions.length
|
||||||
if(this.selectedDiff === 4 + this.diffOptions.length){
|
if(this.selectedDiff === 4 + this.diffOptions.length){
|
||||||
@@ -3107,15 +3144,6 @@ class SongSelect{
|
|||||||
|
|
||||||
getLocalTitle(title, titleLang){
|
getLocalTitle(title, titleLang){
|
||||||
if(titleLang){
|
if(titleLang){
|
||||||
if(strings.id === "cn"){
|
|
||||||
if(titleLang.cn){
|
|
||||||
return titleLang.cn
|
|
||||||
}
|
|
||||||
if(titleLang.ja){
|
|
||||||
return titleLang.ja
|
|
||||||
}
|
|
||||||
return title
|
|
||||||
}
|
|
||||||
for(var id in titleLang){
|
for(var id in titleLang){
|
||||||
if(id === "en" && strings.preferEn && !(strings.id in titleLang) && titleLang.en || id === strings.id && titleLang[id]){
|
if(id === "en" && strings.preferEn && !(strings.id in titleLang) && titleLang.en || id === strings.id && titleLang[id]){
|
||||||
return titleLang[id]
|
return titleLang[id]
|
||||||
|
|||||||
@@ -67,6 +67,27 @@ var translations = {
|
|||||||
tw: "選擇難度",
|
tw: "選擇難度",
|
||||||
ko: "난이도 선택"
|
ko: "난이도 선택"
|
||||||
},
|
},
|
||||||
|
bestAccuracy: {
|
||||||
|
ja: "良率",
|
||||||
|
en: "Accuracy",
|
||||||
|
cn: "良率",
|
||||||
|
tw: "良率",
|
||||||
|
ko: "정확도"
|
||||||
|
},
|
||||||
|
bestCombo: {
|
||||||
|
ja: "連打数",
|
||||||
|
en: "Max Combo",
|
||||||
|
cn: "连打数",
|
||||||
|
tw: "連打數",
|
||||||
|
ko: "최대 콤보"
|
||||||
|
},
|
||||||
|
bestScore: {
|
||||||
|
ja: "総得点",
|
||||||
|
en: "Score",
|
||||||
|
cn: "总分",
|
||||||
|
tw: "總分",
|
||||||
|
ko: "총점"
|
||||||
|
},
|
||||||
back: {
|
back: {
|
||||||
ja: "もどる",
|
ja: "もどる",
|
||||||
en: "Back",
|
en: "Back",
|
||||||
|
|||||||
@@ -29,9 +29,9 @@
|
|||||||
<div id="screen" class="pattern-bg"></div>
|
<div id="screen" class="pattern-bg"></div>
|
||||||
<div data-nosnippet id="version">
|
<div data-nosnippet id="version">
|
||||||
{% if version.version and version.commit_short and version.commit %}
|
{% if version.version and version.commit_short and version.commit %}
|
||||||
<a href="{{version.url}}commit/{{version.commit}}" target="_blank" rel="noopener" id="version-link" class="stroke-sub" alt="vLightNova 1.0.0">vLightNova 1.0.0</a>
|
<a href="{{version.url}}commit/{{version.commit}}" target="_blank" rel="noopener" id="version-link" class="stroke-sub" alt="taiko-web ver.{{version.version}} ({{version.commit_short}})">taiko-web ver.{{version.version}} ({{version.commit_short}})</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a target="_blank" rel="noopener" id="version-link" class="stroke-sub" alt="vLightNova 1.0.0">vLightNova 1.0.0</a>
|
<a target="_blank" rel="noopener" id="version-link" class="stroke-sub" alt="taiko-web vRAINBOW-BETA4">taiko-web vRAINBOW-BETA4</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<script src="src/js/browsersupport.js?{{version.commit_short}}"></script>
|
<script src="src/js/browsersupport.js?{{version.commit_short}}"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user