feat: 删除不再使用的数据库和环境相关的工具函数

This commit is contained in:
雨霖铃
2026-01-29 17:27:18 +08:00
parent 92026ee7fa
commit ed5e90f0fc
5 changed files with 5 additions and 84 deletions
+4 -30
View File
@@ -1,16 +1,9 @@
import { useEffect, useState, useRef, useCallback } from 'react';
import { useEffect, useState, useCallback } from 'react';
import CopyButton from './CopyButton';
/**
* 时间戳显示和执行组件
*
* 功能特性:
* 1. 实时显示当前时间戳(毫秒/秒)
* 2. 支持毫秒和秒单位切换
* 3. 支持启动/停止时间戳自动更新
* 4. 提供复制时间戳功能
* 5. 响应式设计和良好的可访问性
*
* @component
* @example
* ```jsx
@@ -29,9 +22,6 @@ export function TimestampExecution() {
/** @type {[boolean, function]} 时间戳是否正在自动更新 */
const [isRunningTimestamp, setIsRunningTimestamp] = useState(true);
/** @type {React.RefObject<NodeJS.Timeout | null>} 定时器引用,用于清理 */
const timerRef = useRef(null);
/**
* 计算显示的时间戳值
* @type {number}
@@ -40,10 +30,6 @@ export function TimestampExecution() {
? currentTimestamp
: Math.floor(currentTimestamp / 1000);
/**
* 计算单位文本
* @type {string}
*/
const unitText = showMilliseconds ? '毫秒' : '秒';
/**
@@ -51,32 +37,21 @@ export function TimestampExecution() {
* 根据 isRunningTimestamp 和 showMilliseconds 控制定时器的启停和间隔
*/
useEffect(() => {
// 清除之前的定时器
if (timerRef.current) {
clearInterval(timerRef.current);
timerRef.current = null;
}
let timer: number;
// 如果需要运行,创建新的定时器
if (isRunningTimestamp) {
const interval = showMilliseconds ? 100 : 1000;
timerRef.current = setInterval(() => {
timer = window.setInterval(() => {
setCurrentTimestamp(Math.floor(Date.now()));
}, interval);
}
// 清理函数
return () => {
if (timerRef.current) {
clearInterval(timerRef.current);
timerRef.current = null;
}
};
return () => clearInterval(timer);
}, [isRunningTimestamp, showMilliseconds]);
/**
* 切换时间戳显示单位(毫秒/秒)
* @type {function(): void}
*/
const toggleUnit = useCallback(() => {
setShowMilliseconds((prev) => !prev);
@@ -84,7 +59,6 @@ export function TimestampExecution() {
/**
* 切换时间戳自动更新状态(启动/停止)
* @type {function(): void}
*/
const toggleTimestamp = useCallback(() => {
setIsRunningTimestamp((prev) => !prev);