fix: resolve 'e.reduce is not a function' error in admin settings

- Remove server-side grouping logic from API response
- Return flat array instead of grouped object
- Fix data structure mismatch between API and frontend
- Resolve TypeError when accessing admin settings page
This commit is contained in:
张翔
2026-03-13 12:49:40 +08:00
parent 8c82ce5bad
commit b42677b118
+1 -11
View File
@@ -46,18 +46,8 @@ export async function GET(request: NextRequest) {
.where(whereClause)
.orderBy(siteConfig.key);
const groupedConfigs = configs.reduce((acc, config) => {
const cat = config.category;
if (!acc[cat]) {
acc[cat] = [];
}
acc[cat].push(config);
return acc;
}, {} as Record<string, typeof configs>);
return success({
configs: groupedConfigs,
flat: configs,
configs: configs,
});
} catch (error) {
return handleApiError(error);