优化:监控页面加载时先显示所有用户网站初始状态,再检测网络状态实时更新
This commit is contained in:
Binary file not shown.
@@ -149,22 +149,36 @@ createApp({
|
||||
try {
|
||||
const usersRes = await axios.get('/api/users');
|
||||
const websitesRes = await axios.get('/api/websites');
|
||||
const latestDetectionsRes = await axios.get('/api/detections/latest');
|
||||
const networkRes = await axios.get('/api/websites/check-network');
|
||||
|
||||
const usersData = usersRes.data;
|
||||
const allWebsites = websitesRes.data;
|
||||
const latestDetections = latestDetectionsRes.data;
|
||||
const networkStatus = networkRes.data;
|
||||
|
||||
let onlineCount = 0, offlineCount = 0, unknownCount = 0, totalWebsites = allWebsites.length;
|
||||
|
||||
dashboardData.value = usersData.map(user => {
|
||||
const userWebsites = allWebsites.filter(w => w.user_id === user.id);
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
websites: userWebsites.map(w => {
|
||||
websites: userWebsites.map(w => ({
|
||||
...w,
|
||||
networkStatus: 'unknown',
|
||||
loginStatus: 'unknown',
|
||||
lastCheckTime: '-'
|
||||
}))
|
||||
};
|
||||
});
|
||||
|
||||
const latestDetectionsRes = await axios.get('/api/detections/latest');
|
||||
const networkRes = await axios.get('/api/websites/check-network');
|
||||
|
||||
const latestDetections = latestDetectionsRes.data;
|
||||
const networkStatus = networkRes.data;
|
||||
|
||||
let onlineCount = 0, offlineCount = 0, unknownCount = 0, totalWebsites = allWebsites.length;
|
||||
|
||||
dashboardData.value = dashboardData.value.map(user => {
|
||||
return {
|
||||
...user,
|
||||
websites: user.websites.map(w => {
|
||||
const detection = latestDetections[w.id];
|
||||
const net = networkStatus[w.id];
|
||||
let loginStatus = 'unknown';
|
||||
|
||||
Reference in New Issue
Block a user