mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-01 20:42:50 +08:00
fix: more corner-case audit — partial-failure UX + defensive parsing
Three small reliability fixes from re-auditing: 1. Playlist.vue used Promise.all, so a flaky /detail endpoint would blank out the whole page even though /songs returned just fine. Switch to allSettled and synthesize a stub playlist header from the song list when only detail fails. User can still play the playlist; just loses the description/cover. 2. sourceTabs.readAll: typeof null === 'object' AND typeof [] === 'object', so a corrupted localStorage value (e.g. an array) would be treated as a record and its missing keys would silently fall back. Reject explicitly so the failure mode is "clean defaults" instead of "wrong shape that almost works". 3. Settings.vue loadProfileConfig: a 200 response with empty/wrong body would set profileConfigs[botId] to a falsy/wrong-shape value, leaving the row stuck on "加载中..." (because the v-if uses !profileConfigs[id]). Validate the shape; surface "响应格式异常" so the retry link is reachable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
892d9f7959
commit
221079b89c
3 files changed
+43
-13
No files matched your search
@@ -782,6 +782,13 @@ async function loadProfileConfig(botId: string) {
|
||||
profileLoadError[botId] = null;
|
||||
try {
|
||||
const res = await axios.get(`/api/player/${botId}/profile`);
|
||||
// Defensive: a 200 response with non-object body (empty / proxy
|
||||
// injection / etc.) would otherwise leave the row stuck on
|
||||
// "加载中..." because profileConfigs[botId] would be falsy.
|
||||
if (!res.data || typeof res.data !== 'object' || typeof res.data.avatarEnabled !== 'boolean') {
|
||||
profileLoadError[botId] = '响应格式异常';
|
||||
return;
|
||||
}
|
||||
profileConfigs[botId] = res.data;
|
||||
} catch (err: any) {
|
||||
profileLoadError[botId] = err?.response?.status === 404
|
||||
|
||||
Reference in new issue
Block a user