feat: preserve testcase generator state across modal open/close

This commit is contained in:
2026-05-19 04:17:49 -06:00
parent f57c2c4137
commit 60851e3255

View File

@@ -140,7 +140,6 @@ const languageOptions = [
{ label: LANGUAGE_SHOW_VALUE["C++"], value: "C++" }, { label: LANGUAGE_SHOW_VALUE["C++"], value: "C++" },
] ]
async function getProblemDetail() { async function getProblemDetail() {
if (!props.problemID) { if (!props.problemID) {
toggleReady(true) toggleReady(true)
@@ -419,7 +418,10 @@ async function generateMermaid() {
const showGeneratorModal = ref(false) const showGeneratorModal = ref(false)
function handleTestcasesGenerated(testCaseId: string, testCaseScore: Testcase[]) { function handleTestcasesGenerated(
testCaseId: string,
testCaseScore: Testcase[],
) {
problem.value.test_case_id = testCaseId problem.value.test_case_id = testCaseId
problem.value.test_case_score = testCaseScore problem.value.test_case_score = testCaseScore
showGeneratorModal.value = false showGeneratorModal.value = false
@@ -646,16 +648,20 @@ watch(
<h2 class="title">测试用例区域</h2> <h2 class="title">测试用例区域</h2>
<n-flex align="center" style="margin-bottom: 12px"> <n-flex align="center" style="margin-bottom: 12px">
<n-button type="success" @click="showGeneratorModal = true"> <div>
生成测试用例 <n-button type="success" @click="showGeneratorModal = true">
</n-button> 直接生成
<n-upload </n-button>
:show-file-list="false" </div>
accept=".zip" <div>
:custom-request="handleUploadTestcases" <n-upload
> :show-file-list="false"
<n-button type="info">上传测试用例</n-button> accept=".zip"
</n-upload> :custom-request="handleUploadTestcases"
>
<n-button type="info">手动上传</n-button>
</n-upload>
</div>
</n-flex> </n-flex>
<n-modal <n-modal
@@ -666,7 +672,6 @@ watch(
:mask-closable="false" :mask-closable="false"
> >
<TestcaseGenerator <TestcaseGenerator
v-if="showGeneratorModal"
:answers="problem.answers" :answers="problem.answers"
@uploaded="handleTestcasesGenerated" @uploaded="handleTestcasesGenerated"
/> />