feat: change prototype seed.ts and run-code.tsx

This commit is contained in:
fly6516 2025-05-08 11:05:25 +08:00
parent 16ec2d3730
commit 614552bfc6
2 changed files with 43 additions and 2 deletions

View File

@ -51,6 +51,28 @@ const editorLanguageConfigData: Prisma.EditorLanguageConfigCreateInput[] = [
},
];
const testcaseDataConfigData = [
{
label: "l1",
value: "[2,4,3]",
index: 0,
config: {
type: "STRING",
pattern: "^\\[(\\d+,)*\\d+\\]$",
},
},
{
label: "l2",
value: "[5,6,4]",
index: 1,
config: {
type: "STRING",
pattern: "^\\[(\\d+,)*\\d+\\]$",
},
},
];
const userData: Prisma.UserCreateInput[] = [
{
name: "cfngc4594",
@ -1100,6 +1122,25 @@ export async function main() {
for (const u of userData) {
await prisma.user.create({ data: u });
}
// 插入 TestcaseData 和其配置
for (const item of testcaseDataConfigData) {
const testcaseData = await prisma.testcaseData.create({
data: {
label: item.label,
value: item.value,
index: item.index,
},
});
await prisma.testcaseDataConfig.create({
data: {
testcaseDataId: testcaseData.id,
type: item.config.type,
pattern: item.config.pattern,
},
});
}
}
main();
main();

View File

@ -9,7 +9,7 @@ import {
import { cn } from "@/lib/utils";
import { useState } from "react";
import { Session } from "next-auth";
import { judge } from "@/actions/judge";
import { judge } from "@/actions/randomjudge";
import { useTranslations } from "next-intl";
import { Button } from "@/components/ui/button";
import { useProblem } from "@/hooks/use-problem";