feat: add support for ForcePeakCutEnabled configuration in NetworkChart

This commit is contained in:
hamster1963 2025-02-20 15:29:14 +08:00
parent 579b4f8ef4
commit 674d348ed7
2 changed files with 5 additions and 6 deletions

View File

@ -94,8 +94,10 @@ export const NetworkChartClient = React.memo(function NetworkChart({
const customBackgroundImage = (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined const customBackgroundImage = (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined
const forcePeakCutEnabled = (window.ForcePeakCutEnabled as boolean) ?? false
const [activeChart, setActiveChart] = React.useState(defaultChart) const [activeChart, setActiveChart] = React.useState(defaultChart)
const [isPeakEnabled, setIsPeakEnabled] = React.useState(false) const [isPeakEnabled, setIsPeakEnabled] = React.useState(forcePeakCutEnabled)
const handleButtonClick = useCallback( const handleButtonClick = useCallback(
(chart: string) => { (chart: string) => {
@ -281,11 +283,7 @@ export const NetworkChartClient = React.memo(function NetworkChart({
// 根据时间跨度调整显示间隔 // 根据时间跨度调整显示间隔
if (hours <= 12) { if (hours <= 12) {
// 12小时内每60分钟显示一个刻度 // 12小时内每60分钟显示一个刻度
return ( return index === 0 || index === array.length - 1 || new Date(item.created_at).getMinutes() % 60 === 0
index === 0 ||
index === array.length - 1 ||
new Date(item.created_at).getMinutes() % 60 === 0
)
} }
// 超过12小时每2小时显示一个刻度 // 超过12小时每2小时显示一个刻度
const date = new Date(item.created_at) const date = new Date(item.created_at)

View File

@ -7,6 +7,7 @@ declare global {
ForceShowServices: boolean ForceShowServices: boolean
ForceCardInline: boolean ForceCardInline: boolean
ForceShowMap: boolean ForceShowMap: boolean
ForcePeakCutEnabled: boolean
} }
} }