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