fix dashboard and inbounds load failure states

This commit is contained in:
Sora39831 2026-04-06 21:51:33 +08:00
parent 537c73c1b2
commit 6131c55882
2 changed files with 34 additions and 6 deletions

View file

@ -19,6 +19,15 @@
<a-spin tip='{{ i18n "loading" }}'></a-spin>
</a-card>
</a-row>
<a-row v-else-if="loadFailed">
<a-col>
<a-alert type="error" show-icon
message="Failed to load inbounds"
description="The current page data was not loaded. Refresh and retry before editing or operating on inbounds."
:style="{ marginTop: '10px' }">
</a-alert>
</a-col>
</a-row>
<a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else>
<a-col>
<a-card size="small" :style="{ padding: '16px' }" hoverable>
@ -749,6 +758,7 @@
isAdmin: {{if .is_admin}}true{{else}}false{{end}},
currentUsername: {{ printf "%q" .current_username }},
clientEmailOptions: [],
loadFailed: false,
},
methods: {
loading(spinning = true) {
@ -759,16 +769,19 @@
const msg = await HttpUtil.get('/panel/api/inbounds/list');
if (!msg.success) {
this.refreshing = false;
return;
this.loadFailed = true;
return false;
}
await this.getLastOnlineMap();
await this.getOnlineUsers();
this.loadFailed = false;
this.setInbounds(msg.obj);
setTimeout(() => {
this.refreshing = false;
}, 500);
return true;
},
async getOnlineUsers() {
const msg = await HttpUtil.post('/panel/api/inbounds/onlines');
@ -1633,9 +1646,11 @@
// Initial data fetch
this.getDBInbounds()
.catch((e) => {
this.loadFailed = true;
console.error(e);
})
.finally(() => {
this.loadingStates.fetched = true;
this.loading(false);
});

View file

@ -19,6 +19,14 @@
<a-spin tip='{{ i18n "loading" }}'></a-spin>
</a-card>
</a-row>
<a-row v-else-if="loadFailed">
<a-col>
<a-alert type="error" show-icon class="mb-10"
message="Failed to load dashboard status"
description="The current page data was not loaded. Refresh and retry before relying on this dashboard.">
</a-alert>
</a-col>
</a-row>
<a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else>
<a-col>
<a-card hoverable>
@ -882,6 +890,7 @@
fetched: false,
spinning: false
},
loadFailed: false,
status: new Status(),
cpuHistory: [], // small live widget history
cpuHistoryLong: [], // aggregated points from backend
@ -905,15 +914,15 @@
try {
const msg = await HttpUtil.get('/panel/api/server/status');
if (msg.success) {
if (!this.loadingStates.fetched) {
this.loadingStates.fetched = true;
}
this.loadFailed = false;
this.setStatus(msg.obj, true);
return true;
}
} catch (e) {
console.error("Failed to get status:", e);
}
this.loadFailed = true;
return false;
},
setStatus(data) {
this.status = new Status(data);
@ -1134,7 +1143,11 @@
}
// Initial status fetch
await this.getStatus();
try {
await this.getStatus();
} finally {
this.loadingStates.fetched = true;
}
// Setup WebSocket for real-time updates
if (window.wsClient) {