Merged
Conversation
Owner
Author
|
目前遠端更新歌曲機制只是簡易版,未來沒意外也不會讓 collect.json 過於肥大 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📄 Step 24 規格書(Loading 畫面+歌曲清單 SWR/ETag/Isolate 更新+封面遠端快取)
1. 階段目標
collect_version(初始 0)、collect_etag、collect_updated_at。collect.json,完成後才進主畫面。collect.json,允許直接進主畫面;背景啟動 Isolate 檢查更新。If-None-Match→ 304 不更新,200 覆寫並更新 etag/version。—
【變更】遠端版本檢查與封面圖片快取:
collect.json的songs[].image由資產路徑改為遠端 URL(png/jpg/webp 皆可)。version.json(只含version數字):https://raw.githubusercontent.com/VagrantPi/idle_hippo_music_resource/refs/heads/main/version.jsonversion≤ 本地collectVersion→ 視為最新不下載;若version> 本地 → 下載collect.json。collect.jsonURL:https://raw.githubusercontent.com/VagrantPi/idle_hippo_music_resource/refs/heads/main/collect.jsoncollect.json後,若 JSON 內含version,collectVersion以該值(或version.json的值)覆寫,不使用+1,避免重複下載。collect.json後,對於每筆歌曲:id檢查本地快取是否已有封面(appdata://images/{id}.{ext})。imageURL 到appdata://images/,檔名為id、沿用副檔名。2. 功能需求
2.1 UI/UX
assets/images/background/Loading.pngChecking updates…、Updating songs…、Retry in {sec}s等2.2 資料結構
{ "karaoke": { "collectVersion": 0, "collectEtag": "", "collectUpdatedAt": 0, "collectPath": "appdata://collect.json" } }2.3 SWR + ETag + Isolate 流程
啟動 App → 顯示 Loading 畫面(至少 1s)。
檢查並入帳離線獎勵。
第一次開啟:同步檢查並更新
collect.json(完成後才進主畫面)。非第一次開啟:
載入本地
collect.json(若無則用 asset 預設)。顯示 Loading 1s 後導向主畫面。
背景以 Isolate 發送帶 ETag 的請求檢查更新:
etag/version。version欄位:以其值覆寫collectVersion;否則維持+1策略。songs:appdata://images/{id}.{ext}不存在 → 下載imageURL 並原子寫入快取。2.4 音樂遊戲入口保護
3. 驗收標準
collectVersion。collectEtag與collectVersion更新(含version時以其為準)。4. 實例化需求測試案例
測試案例 1:首次開啟
collectVersion=0)測試案例 2:非首次開啟
collect.json測試案例 3:離線獎勵
測試案例 4:ETag 304
測試案例 5:ETag 200
collectEtag=def,collectVersion+=1測試案例 6:三次失敗
測試案例 7:音樂遊戲入口錯誤攔截
測試案例 8:封面圖片快取(首次 / 更新)
images/{id}.pngversion提升,且image為 http(s) URLappdata://images/{id}.ext;下次開啟不再下載