3.0 KiB
3.0 KiB
Implementation Plan
1. Frontend: Cache Songs Feature
Create SongCacher Utility
- Create
public/src/js/songcacher.jscontaining theSongCacherclass. - Implement methods:
cacheAll(): Iterates all songs inassets.songsand fetches their assets.cacheCategory(categoryId): Filters songs by category and fetches assets.cacheSong(songId): Fetches assets for a single song.
- Use
loader.ajax(orfetch) to download files (main.tja, music file, etc.) so they are cached by the browser/service worker.
Update Assets & Settings
- Modify
public/src/js/assets.jsto includesongcacher.jsin the load list. - Modify
public/src/js/settings.js:- Add a "Cache Songs" option to the settings menu.
- Use a selection interface (e.g.,
selectorsubmenu) allowing users to choose "All", "Category", or "Single Song". - Trigger
SongCachermethods based on selection.
2. Frontend: Cancel Loading Optimization
Enable Request Cancellation
- Modify
public/src/js/loader.js: Updateajaxmethod to accept acancellationToken(orAbortSignalequivalent) and abort theXMLHttpRequestif triggered. - Modify
public/src/js/abstractfile.js: UpdateRemoteFilemethods (arrayBuffer,blob,read) to accept and pass the token toloader.ajax. - Modify
public/src/js/soundbuffer.js: Updateloadmethod to accept and pass the token.
Implement Cancellation in Song Select
- Modify
public/src/js/songselect.js:- In
startPreview, create a new cancellation token. - Store the current token.
- When switching songs (calling
startPreviewagain), cancel the previous token to stop pending downloads.
- In
3. Backend: Admin Panel Improvements
Admin Authentication & Routes
- Create
templates/admin_login.htmlfor the password-only login. - Modify
app.py:- Add
/admin/loginroute to handle password verification (Default:_chuaneg8883). - Set a session variable (e.g.,
admin_logged_in) upon success. - Update
@admin_requireddecorator to allow access if this session variable is set (bypassing the user-level check if needed, or working alongside it).
- Add
Admin Features (Stats & Management)
- Modify
app.py:- In
route_api_scores_save, increment aplay_countfield in thedb.songscollection for the played song.
- In
- Create
templates/admin_stats.html(or updateadmin_songs.html) to display:- User statistics.
- Song statistics (including the new
play_count).
4. Backend: New Category
- Modify
tools/categories.json: Add a new category entry for "Custom Charts" (自制谱面).
5. Localization
- Modify
public/src/js/strings.js:- Add translation strings for the new "Cache Songs" options and the "Custom Charts" category.
- Ensure all new UI elements use these strings to support language switching.
6. Git Operations
- Create and checkout new branch
Utra-Ver. - Commit all changes.
- Push to remote repository (User:
AnthonyDuan, Pass:_chuaneg8883).