perf: 性能优化与代码质量改进

- 添加4个数据库索引提升查询性能
- 启用ESLint并配置React支持
- 修复ESLint错误(未使用的导入和状态)
- 简化Toast组件UI样式
- 移除重复文件(server.js.backup)
- 清理.gitignore中的.next目录

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Developer
2026-03-19 09:26:04 +08:00
co-authored by Claude Opus 4.6
parent 1e478c2eaa
commit 3975bbed73
116 changed files with 1827 additions and 209 deletions
+2 -1
View File
@@ -157,9 +157,9 @@ export default function Home() {
} else {
const newRecord = await createRecord(data);
setRecords(prev => [...prev, newRecord]);
showToast('记录已添加', { tone: 'success' });
}
closeModal();
loadData();
} catch (err) {
setFormError(err.message);
showToast(err.message, { tone: 'error' });
@@ -183,6 +183,7 @@ export default function Home() {
setRecords(prev => prev.filter(r => r.id !== editingRecord.id));
closeModal();
showToast('记录已删除', { tone: 'success' });
loadData();
} catch (err) {
setFormError(err.message);
showToast(err.message, { tone: 'error' });
+1 -1
View File
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { useRouter } from 'next/router';
import { login, register, isLoggedIn } from '../lib/api';
import { login, isLoggedIn } from '../lib/api';
import AppShell from '../components/AppShell';
import { Icon } from '../components/icons';
import { useToast } from '../components/ToastProvider';
-4
View File
@@ -36,7 +36,6 @@ export default function Stats() {
const [categoryType, setCategoryType] = useState('expense');
const [selectedCategories, setSelectedCategories] = useState([]);
const [trendLoading, setTrendLoading] = useState(true);
const [categoryLoading, setCategoryLoading] = useState(true);
const trendChartRef = useRef(null);
const trendChartInstance = useRef(null);
@@ -67,15 +66,12 @@ export default function Stats() {
};
const loadCategoryData = async () => {
setCategoryLoading(true);
try {
const category = await getCategoryStats(getMonthStr(currentMonth), categoryType);
setCategoryData(category);
} catch (err) {
console.error(err);
showToast(err.message, { tone: 'error' });
} finally {
setCategoryLoading(false);
}
};