feat: add word import and class type display controls
Build Docker Package / docker-package (push) Successful in 6m34s
Build Docker Package / docker-package (push) Successful in 6m34s
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { NextRequest } from "next/server";
|
||||
import { listWords } from "@/lib/db";
|
||||
import { buildWordExcel } from "@/lib/word-excel";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
const grade = searchParams.get("grade") ?? undefined;
|
||||
const classTypeId = Number(searchParams.get("classTypeId"));
|
||||
const words = listWords({
|
||||
grade,
|
||||
classTypeId: Number.isFinite(classTypeId) && classTypeId > 0 ? classTypeId : undefined,
|
||||
});
|
||||
const workbook = buildWordExcel(words);
|
||||
|
||||
return new Response(workbook, {
|
||||
headers: {
|
||||
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"Content-Disposition": `attachment; filename="${encodeURIComponent("词库导入表格")}.xlsx"`,
|
||||
"Cache-Control": "no-store",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user