fix: 解决概览页多磁盘刷新问题 (#1640)

This commit is contained in:
ssongliu 2023-07-13 14:11:18 +08:00 committed by GitHub
parent d01a964534
commit ef948bca76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -239,6 +239,7 @@ const isSafety = ref();
const chartOption = ref('network');
let timer: NodeJS.Timer | null = null;
let isInit = ref<boolean>(true);
let isStatusInit = ref<boolean>(true);
let isActive = ref(true);
const ioReadBytes = ref<Array<number>>([]);
@ -355,7 +356,8 @@ const onLoadBaseInfo = async (isInit: boolean, range: string) => {
baseInfo.value = res.data;
currentInfo.value = baseInfo.value.currentInfo;
await onLoadCurrentInfo();
statuRef.value.acceptParams(currentInfo.value, baseInfo.value);
isStatusInit.value = false;
statuRef.value.acceptParams(currentInfo.value, baseInfo.value, isStatusInit.value);
appRef.value.acceptParams();
if (isInit) {
timer = setInterval(async () => {
@ -421,7 +423,7 @@ const onLoadCurrentInfo = async () => {
}
loadData();
currentInfo.value = res.data;
statuRef.value.acceptParams(currentInfo.value, baseInfo.value);
statuRef.value.acceptParams(currentInfo.value, baseInfo.value, isStatusInit.value);
};
function loadUpTime(uptime: number) {

View File

@ -201,7 +201,7 @@ const currentInfo = ref<Dashboard.CurrentInfo>({
shotTime: new Date(),
});
const acceptParams = (current: Dashboard.CurrentInfo, base: Dashboard.BaseInfo): void => {
const acceptParams = (current: Dashboard.CurrentInfo, base: Dashboard.BaseInfo, isInit: boolean): void => {
currentInfo.value = current;
baseInfo.value = base;
freshChart('cpu', 'CPU', formatNumber(currentInfo.value.cpuUsedPercent));
@ -215,7 +215,7 @@ const acceptParams = (current: Dashboard.CurrentInfo, base: Dashboard.BaseInfo):
freshChart('disk' + i, itemPath, formatNumber(currentInfo.value.diskData[i].usedPercent));
}
if (currentInfo.value.diskData.length > 5) {
showMore.value = false;
showMore.value = isInit ? false : showMore.value || false;
}
});
};