Skip to content

Commit c79a850

Browse files
committed
Refactor batch data preparation in MigrationTool.vue to enhance clarity by removing unnecessary object initialization. Update key checks for batch payload to improve data handling consistency during migration.
1 parent 08c6776 commit c79a850

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/components/MigrationTool.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,9 @@ export default {
792792
793793
// 准备批量导入数据
794794
const batchData = {
795-
"classworks-list-main": formattedStudentList,
796-
"classworks-config": configWithoutStudentList,
797-
}
798-
795+
"classworks-list-main": formattedStudentList,
796+
"classworks-config": configWithoutStudentList,
797+
};
799798
800799
// 批量导入配置数据
801800
const configResponse = await axios.post(
@@ -853,9 +852,7 @@ export default {
853852
const batchSize = 100;
854853
for (let i = 0; i < homeworkItems.length; i += batchSize) {
855854
const batch = homeworkItems.slice(i, i + batchSize);
856-
const batchPayload = {
857-
858-
};
855+
const batchPayload = {};
859856
860857
// 准备批量数据
861858
for (const item of batch) {
@@ -891,7 +888,7 @@ export default {
891888
}
892889
893890
// 发送批量请求
894-
if (Object(batchPayload).length > 0) {
891+
if (Object.keys(batchPayload).length > 0) {
895892
const response = await axios.post(
896893
`${this.targetServerUrl}/${this.machineId}/import/batch-import`,
897894
batchPayload,
@@ -904,7 +901,7 @@ export default {
904901
if (response.data) {
905902
if (response.data.successful > 0) {
906903
this.migrationResults.push({
907-
key: `批量数据 (${Object(batchPayload).length}项)`,
904+
key: `批量数据 (${Object.keys(batchPayload).length}项)`,
908905
success: true,
909906
message: `成功迁移 ${response.data.successful} 项数据到服务器`,
910907
});

0 commit comments

Comments
 (0)