优化 新启动首次加载

This commit is contained in:
Chen committed 2025-12-04 20:23:18 +08:00
1 parent c215de731e
commit b2c3ecc5ba
3 files changed
+85 -33

No files matched your search

+24 -24
View File
@@ -41,6 +41,30 @@ router.post('/',
})
);
/**
* 更新偏好设置(必须在 /:id 之前,否则会被 /:id 匹配)
* PUT /api/library/preferences
* Body: { preferences }
*/
router.put('/preferences', asyncHandler(async (req, res) => {
const result = libraryService.updatePreferences(req.body);
res.json({ success: true, data: result });
}));
/**
* 更新主题(必须在 /:id 之前)
* PUT /api/library/theme
* Body: { theme }
*/
router.put('/theme',
validateRequired(['theme']),
asyncHandler(async (req, res) => {
const { theme } = req.body;
const result = libraryService.updateTheme(theme);
res.json({ success: true, data: result });
})
);
/**
* 更新素材库
* PUT /api/library/:id
@@ -72,30 +96,6 @@ router.post('/:id/set-current', asyncHandler(async (req, res) => {
res.json({ success: true, data: result });
}));
/**
* 更新偏好设置
* PUT /api/library/preferences
* Body: { preferences }
*/
router.put('/preferences', asyncHandler(async (req, res) => {
const result = libraryService.updatePreferences(req.body);
res.json({ success: true, data: result });
}));
/**
* 更新主题
* PUT /api/library/theme
* Body: { theme }
*/
router.put('/theme',
validateRequired(['theme']),
asyncHandler(async (req, res) => {
const { theme } = req.body;
const result = libraryService.updateTheme(theme);
res.json({ success: true, data: result });
})
);
/**
* 获取素材库统计
* GET /api/library/:id/stats