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 React, {useEffect, useState} from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import {useTranslation} from 'react-i18next';
|
||||||
import { Card, Grid } from 'semantic-ui-react';
|
import {Card, Grid} from 'semantic-ui-react';
|
||||||
import {
|
import {
|
||||||
Bar,
|
Bar,
|
||||||
BarChart,
|
BarChart,
|
||||||
@ -122,11 +122,11 @@ const Dashboard = () => {
|
|||||||
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
||||||
: new Date();
|
: new Date();
|
||||||
|
|
||||||
// 确保至少显示5天的数据
|
// 确保至少显示7天的数据
|
||||||
const fiveDaysAgo = new Date();
|
const sevenDaysAgo = new Date();
|
||||||
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
|
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
|
||||||
if (minDate > fiveDaysAgo) {
|
if (minDate > sevenDaysAgo) {
|
||||||
minDate = fiveDaysAgo;
|
minDate = sevenDaysAgo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成所有日期
|
// 生成所有日期
|
||||||
@ -164,11 +164,11 @@ const Dashboard = () => {
|
|||||||
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
||||||
: new Date();
|
: new Date();
|
||||||
|
|
||||||
// 确保至少显示5天的数据
|
// 确保至少显示7天的数据
|
||||||
const fiveDaysAgo = new Date();
|
const sevenDaysAgo = new Date();
|
||||||
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
|
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
|
||||||
if (minDate > fiveDaysAgo) {
|
if (minDate > sevenDaysAgo) {
|
||||||
minDate = fiveDaysAgo;
|
minDate = sevenDaysAgo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成所有日期
|
// 生成所有日期
|
||||||
|
Loading…
Reference in New Issue
Block a user