diff --git a/.trae/documents/Remove Delete Option and Redirect Upload.md b/.trae/documents/Remove Delete Option and Redirect Upload.md new file mode 100644 index 0000000..d2f3b78 --- /dev/null +++ b/.trae/documents/Remove Delete Option and Redirect Upload.md @@ -0,0 +1,9 @@ +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. diff --git a/app.py b/app.py index 4b12cde..0af8fcc 100644 --- a/app.py +++ b/app.py @@ -911,19 +911,8 @@ def upload_file(): return flask.jsonify({'success': True}) @app.route("/api/delete", methods=["POST"]) -@limiter.limit("1 per day") def delete(): - 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 "成功しました。" + return flask.jsonify({ "success": False, "reason": "Deletion is disabled" }), 403 if __name__ == '__main__': import argparse diff --git a/public/src/js/songselect.js b/public/src/js/songselect.js index 1497dce..edec6bc 100644 --- a/public/src/js/songselect.js +++ b/public/src/js/songselect.js @@ -310,12 +310,6 @@ class SongSelect{ iconName: "download", iconFill: "#e7cbe1", letterSpacing: 4 - }, { - text: "削除", - fill: "silver", - iconName: "trash", - iconFill: "#111111", - letterSpacing: 4 }] this.optionsList = [strings.none, strings.auto, strings.netplay] @@ -954,7 +948,7 @@ class SongSelect{ } else if (currentSong.action === "upload") { this.playSound("se_don"); setTimeout(() => { - window.location.href = "/upload/"; + window.location.href = "https://zizhipu.taiko.asia"; }, 100); } else if (currentSong.action === "keijiban") { this.playSound("se_don");