feat: 对接 templateDetail 页面后端接口

- 创建 hooks/use-error.ts 统一错误处理
- 创建 hooks/use-template-detail.ts 获取模板详情
- 创建 hooks/use-template-generations.ts 获取模板生成记录
- 更新 hooks 使用 handleError 统一错误处理
- 优化 SearchResultsGrid 组件,复用 TemplateGeneration 类型
- 删除不必要的类型转换和重复代码

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
imeepos
2026-01-16 11:56:38 +08:00
parent fb719c6ea2
commit ae120f24d3
9 changed files with 487 additions and 92 deletions

10
hooks/use-error.ts Normal file
View File

@@ -0,0 +1,10 @@
import { type ApiError } from '@/lib/types'
export async function handleError<T>(cb: () => Promise<T>) {
try {
const data = await cb()
return { data, error: null }
} catch (e) {
return { data: null, error: e as ApiError }
}
}