Guard dashboard profile switches and tighten chart axis padding

This commit is contained in:
jxxghp
2026-06-29 09:36:18 +08:00
parent 2aae0f08ad
commit 21d4f9fd73
4 changed files with 11 additions and 10 deletions
+8 -4
View File
@@ -134,6 +134,8 @@ let dashboardGridContentResizeFrame: number | null = null
let dashboardGridResizeRefreshFrame: number | null = null let dashboardGridResizeRefreshFrame: number | null = null
let dashboardRevealFrame: number | null = null let dashboardRevealFrame: number | null = null
let isDashboardRevealPending = false let isDashboardRevealPending = false
// 标记最近一次响应式档位切换,避免快速缩放时较早的异步配置覆盖最新档位。
let dashboardLayoutProfileSwitchId = 0
// 是否正在手动缩放组件,避免自动测高抢回用户拖动中的高度。 // 是否正在手动缩放组件,避免自动测高抢回用户拖动中的高度。
const isDashboardGridResizing = ref(false) const isDashboardGridResizing = ref(false)
@@ -1337,13 +1339,15 @@ watch(
const nextProfile = resolveDashboardLayoutProfile() const nextProfile = resolveDashboardLayoutProfile()
if (nextProfile === dashboardLayoutProfile.value) return if (nextProfile === dashboardLayoutProfile.value) return
if (dashboardGrid.value && !isSyncingDashboardGrid.value && !isDashboardGridLayoutResetPending.value) { // GridStack 可能已先完成列数压缩;档位切换只读取目标配置,不能保存当前自动重排结果。
persistDashboardGridLayout(false) const profileSwitchId = ++dashboardLayoutProfileSwitchId
}
dashboardLayoutProfile.value = nextProfile dashboardLayoutProfile.value = nextProfile
const profileConfig = await loadDashboardProfileConfig(nextProfile) const profileConfig = await loadDashboardProfileConfig(nextProfile)
if (profileSwitchId !== dashboardLayoutProfileSwitchId || dashboardLayoutProfile.value !== nextProfile) return
const legacyEnable = profileConfig?.enabled === undefined ? await loadLegacyDashboardEnableConfig() : undefined const legacyEnable = profileConfig?.enabled === undefined ? await loadLegacyDashboardEnableConfig() : undefined
if (profileSwitchId !== dashboardLayoutProfileSwitchId || dashboardLayoutProfile.value !== nextProfile) return
dashboardGridLayout.value = profileConfig?.items ?? {} dashboardGridLayout.value = profileConfig?.items ?? {}
enableConfig.value = mergeDashboardEnableConfig(profileConfig?.enabled ?? legacyEnable) enableConfig.value = mergeDashboardEnableConfig(profileConfig?.enabled ?? legacyEnable)
if (profileConfig?.enabled === undefined && legacyEnable !== undefined) { if (profileConfig?.enabled === undefined && legacyEnable !== undefined) {
+1 -2
View File
@@ -94,7 +94,7 @@ const chartOptions = controlledComputed(
}, },
padding: { padding: {
top: -10, top: -10,
left: 8, left: 0,
right: 5, right: 5,
bottom: 5, bottom: 5,
}, },
@@ -136,7 +136,6 @@ const chartOptions = controlledComputed(
yaxis: { yaxis: {
labels: { labels: {
show: true, show: true,
minWidth: 32,
formatter: (value: number) => `${Math.round(value)}%`, formatter: (value: number) => `${Math.round(value)}%`,
style: { style: {
colors: axisLabelColor, colors: axisLabelColor,
+1 -2
View File
@@ -101,7 +101,7 @@ const chartOptions = controlledComputed(
}, },
padding: { padding: {
top: -10, top: -10,
left: 8, left: 0,
right: 5, right: 5,
bottom: 5, bottom: 5,
}, },
@@ -143,7 +143,6 @@ const chartOptions = controlledComputed(
yaxis: { yaxis: {
labels: { labels: {
show: true, show: true,
minWidth: 40,
formatter: (value: number) => formatDashboardFileSize(value, 0, totalMemory.value || value), formatter: (value: number) => formatDashboardFileSize(value, 0, totalMemory.value || value),
style: { style: {
colors: axisLabelColor, colors: axisLabelColor,
+1 -2
View File
@@ -97,7 +97,7 @@ const chartOptions = controlledComputed(
}, },
padding: { padding: {
top: -10, top: -10,
left: 8, left: 0,
right: 5, right: 5,
bottom: 5, bottom: 5,
}, },
@@ -145,7 +145,6 @@ const chartOptions = controlledComputed(
yaxis: { yaxis: {
labels: { labels: {
show: true, show: true,
minWidth: 52,
formatter: (value: number) => formatter: (value: number) =>
`${formatDashboardFileSize(value, value >= 1024 ** 2 ? 1 : 0, networkChartMax.value)}/s`, `${formatDashboardFileSize(value, value >= 1024 ** 2 ? 1 : 0, networkChartMax.value)}/s`,
style: { style: {