perf: 性能优化与代码质量改进
- 简化ToastProvider组件,移除未使用导入 - 简化Stats页面代码 - 添加React ESLint配置 - 添加数据库索引和API参数验证 - 清理重复文件server.js.backup - 移除前端未使用的UI代码和复杂样式 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
3975bbed73
commit
63c97ab31a
@@ -1,5 +1,3 @@
|
||||
import { getRecords, getStats, getCategories, getRecurringBills } from './api';
|
||||
|
||||
// 全局 SWR 配置
|
||||
export const swrConfig = {
|
||||
refreshInterval: 0, // 默认不自动刷新
|
||||
@@ -11,11 +9,3 @@ export const swrConfig = {
|
||||
console.error('SWR Error:', error);
|
||||
},
|
||||
};
|
||||
|
||||
// 数据获取器映射
|
||||
export const fetchers = {
|
||||
records: (month, type) => getRecords(month, type),
|
||||
stats: (month) => getStats(month),
|
||||
categories: () => getCategories(),
|
||||
recurring: () => getRecurringBills(),
|
||||
};
|
||||
|
||||
@@ -7,6 +7,13 @@ export const formatMonth = (date) =>
|
||||
|
||||
export const formatMoney = (num) => (num || 0).toFixed(2);
|
||||
|
||||
// Format date as 'YYYY-MM-DD'
|
||||
export const formatDate = (date) =>
|
||||
`${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
|
||||
// Get current time string 'HH:MM'
|
||||
export const getCurrentTimeStr = () => new Date().toTimeString().slice(0, 5);
|
||||
|
||||
// Parse date-time string 'YYYY-MM-DD HH:MM' into date and time parts
|
||||
export const parseDateTime = (dateTimeStr) => {
|
||||
if (!dateTimeStr) return { datePart: '', timePart: '00:00' };
|
||||
|
||||
Reference in New Issue
Block a user