WuYongJie 63ec6b7dfb fix: 修复排行榜按钮消失、tag排序和输入框浅色模式问题
1. 排行榜悬浮窗关闭后小按钮消失问题
   - 修复面板居中模式关闭时按钮位置错误
   - 保存并恢复按钮的居中状态

2. 首页tag按钮按素材数量排序
   - 添加按素材数量降序排序逻辑

3. 上传弹窗输入框浅色模式文字不可见
   - 添加 text-slate-900 确保浅色模式下文字可见
   - 添加 placeholder 样式确保占位符正确显示
2025-12-14 21:41:29 +08:00

39 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { NextResponse } from 'next/server'
import { formatFieldOptionValues, getFieldPoolRecords, syncFieldPoolFromTemplates } from '@/lib/field-pool'
type FieldPoolRecord = {
key: string
label: string
filterDisplayName?: string | null
options: Array<{ value: string }>
isFilterEnabled?: boolean
filterOrder?: number | null
}
export async function GET(request: Request) {
try {
await syncFieldPoolFromTemplates()
const fields = (await getFieldPoolRecords()) as FieldPoolRecord[]
// 检查是否需要返回所有字段(用于上传表单)
const url = new URL(request.url)
const includeAll = url.searchParams.get('includeAll') === 'true'
// 如果 includeAll=true,返回所有字段;否则只返回 isFilterEnabled 的字段
const filteredFields = includeAll ? fields : fields.filter((field) => field.isFilterEnabled)
const payload = filteredFields.map((field: FieldPoolRecord) => ({
fieldKey: field.key,
fieldLabel: field.filterDisplayName || field.label,
fieldDefaultLabel: field.label,
filterOrder: field.filterOrder ?? 0,
options: formatFieldOptionValues(field.options),
}))
return NextResponse.json(payload)
} catch (error) {
console.error('Error fetching template categories:', error)
return NextResponse.json({ error: '获取模板分类失败' }, { status: 500 })
}
}