mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 01:06:37 +08:00
feat: update date range to display at least 7 days of data in Dashboard
This commit is contained in:
parent
10aba11f18
commit
517f6ad211
@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Card, Grid } from 'semantic-ui-react';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import {useTranslation} from 'react-i18next';
|
||||
import {Card, Grid} from 'semantic-ui-react';
|
||||
import {
|
||||
Bar,
|
||||
BarChart,
|
||||
@ -122,11 +122,11 @@ const Dashboard = () => {
|
||||
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
||||
: new Date();
|
||||
|
||||
// 确保至少显示5天的数据
|
||||
const fiveDaysAgo = new Date();
|
||||
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
|
||||
if (minDate > fiveDaysAgo) {
|
||||
minDate = fiveDaysAgo;
|
||||
// 确保至少显示7天的数据
|
||||
const sevenDaysAgo = new Date();
|
||||
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
|
||||
if (minDate > sevenDaysAgo) {
|
||||
minDate = sevenDaysAgo;
|
||||
}
|
||||
|
||||
// 生成所有日期
|
||||
@ -164,11 +164,11 @@ const Dashboard = () => {
|
||||
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
||||
: new Date();
|
||||
|
||||
// 确保至少显示5天的数据
|
||||
const fiveDaysAgo = new Date();
|
||||
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
|
||||
if (minDate > fiveDaysAgo) {
|
||||
minDate = fiveDaysAgo;
|
||||
// 确保至少显示7天的数据
|
||||
const sevenDaysAgo = new Date();
|
||||
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
|
||||
if (minDate > sevenDaysAgo) {
|
||||
minDate = sevenDaysAgo;
|
||||
}
|
||||
|
||||
// 生成所有日期
|
||||
|
Loading…
Reference in New Issue
Block a user