From 54f6e660f1f565e68e38563cf43862bf810de5cb Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Thu, 1 Aug 2024 17:36:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=9F=A5=E5=88=9D=E5=A7=8B=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/LogsTable.js | 8 ++++---- web/src/helpers/utils.js | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/web/src/components/LogsTable.js b/web/src/components/LogsTable.js index 03a7205..b19adbb 100644 --- a/web/src/components/LogsTable.js +++ b/web/src/components/LogsTable.js @@ -1,11 +1,11 @@ import React, { useEffect, useState } from 'react'; import { API, - copy, + copy, getTodayStartTimestamp, isAdmin, showError, showSuccess, - timestamp2string, + timestamp2string } from '../helpers'; import { @@ -419,12 +419,12 @@ const LogsTable = () => { const [logType, setLogType] = useState(0); const isAdminUser = isAdmin(); let now = new Date(); - // 初始化start_timestamp为前一天 + // 初始化start_timestamp为今天0点 const [inputs, setInputs] = useState({ username: '', token_name: '', model_name: '', - start_timestamp: timestamp2string(now.getTime() / 1000 - 86400), + start_timestamp: timestamp2string(getTodayStartTimestamp()), end_timestamp: timestamp2string(now.getTime() / 1000 + 3600), channel: '', }); diff --git a/web/src/helpers/utils.js b/web/src/helpers/utils.js index 321b00a..579c22d 100644 --- a/web/src/helpers/utils.js +++ b/web/src/helpers/utils.js @@ -140,6 +140,12 @@ export function removeTrailingSlash(url) { } } +export function getTodayStartTimestamp() { + var now = new Date(); + now.setHours(0, 0, 0, 0); + return Math.floor(now.getTime() / 1000); +} + export function timestamp2string(timestamp) { let date = new Date(timestamp * 1000); let year = date.getFullYear().toString();