fix: 修复分页和缓存相关bug
- 前端: 移除无限滚动,改为一次性加载全部数据 - 前端: monthly-records接口添加limit=1000参数 - 前端: 修复edit-modal.js中loadListData调用参数 - 后端: 修复stats.js中getCached函数Promise处理 - 后端: 修复records.js各接口正确传递limit参数 - 后端: 修复partner-records SQL参数数量问题 - 统一版本号强制浏览器刷新缓存 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
df3a9daa65
commit
9126348d1b
@@ -51,7 +51,9 @@ function queryPagedRecords(userId, year, month, options) {
|
||||
// 接单列表
|
||||
router.get('/orders', (req, res) => {
|
||||
const result = queryPagedRecords(req.user.id, req.query.year, req.query.month, {
|
||||
category: '接单'
|
||||
category: '接单',
|
||||
page: req.query.page,
|
||||
limit: req.query.limit
|
||||
});
|
||||
res.json(result);
|
||||
});
|
||||
@@ -60,7 +62,9 @@ router.get('/orders', (req, res) => {
|
||||
router.get('/other-income', (req, res) => {
|
||||
const result = queryPagedRecords(req.user.id, req.query.year, req.query.month, {
|
||||
type: 'income',
|
||||
excludeCategories: ['接单', '派单']
|
||||
excludeCategories: ['接单', '派单'],
|
||||
page: req.query.page,
|
||||
limit: req.query.limit
|
||||
});
|
||||
res.json(result);
|
||||
});
|
||||
@@ -69,7 +73,9 @@ router.get('/other-income', (req, res) => {
|
||||
router.get('/red-envelope', (req, res) => {
|
||||
const result = queryPagedRecords(req.user.id, req.query.year, req.query.month, {
|
||||
type: 'income',
|
||||
category: '红包收入'
|
||||
category: '红包收入',
|
||||
page: req.query.page,
|
||||
limit: req.query.limit
|
||||
});
|
||||
res.json(result);
|
||||
});
|
||||
@@ -78,7 +84,9 @@ router.get('/red-envelope', (req, res) => {
|
||||
router.get('/milk-tea', (req, res) => {
|
||||
const result = queryPagedRecords(req.user.id, req.query.year, req.query.month, {
|
||||
type: 'income',
|
||||
category: '奶茶'
|
||||
category: '奶茶',
|
||||
page: req.query.page,
|
||||
limit: req.query.limit
|
||||
});
|
||||
res.json(result);
|
||||
});
|
||||
@@ -86,7 +94,9 @@ router.get('/milk-tea', (req, res) => {
|
||||
// 派单列表
|
||||
router.get('/dispatches', (req, res) => {
|
||||
const result = queryPagedRecords(req.user.id, req.query.year, req.query.month, {
|
||||
category: '派单'
|
||||
category: '派单',
|
||||
page: req.query.page,
|
||||
limit: req.query.limit
|
||||
});
|
||||
res.json(result);
|
||||
});
|
||||
|
||||
@@ -22,12 +22,12 @@ function getCached(key, fetchFn) {
|
||||
const firstKey = statsCache.keys().next().value;
|
||||
statsCache.delete(firstKey);
|
||||
}
|
||||
return fetchFn().then(data => {
|
||||
return Promise.resolve(fetchFn()).then(data => {
|
||||
statsCache.set(key, { data, ts: Date.now() });
|
||||
return data;
|
||||
}).catch(err => {
|
||||
console.error('Cache fetch error:', err.message);
|
||||
return fetchFn(); // fallback to direct fetch
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user