1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-07-01 16:49:22 +00:00

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.

This commit is contained in:
SunWuyuan 2025-05-11 13:49:49 +08:00
parent 08c6776cd1
commit c79a850868
No known key found for this signature in database
GPG Key ID: A6A54CF66F56BB64

View File

@ -792,10 +792,9 @@ export default {
//
const batchData = {
"classworks-list-main": formattedStudentList,
"classworks-config": configWithoutStudentList,
}
"classworks-list-main": formattedStudentList,
"classworks-config": configWithoutStudentList,
};
//
const configResponse = await axios.post(
@ -853,9 +852,7 @@ export default {
const batchSize = 100;
for (let i = 0; i < homeworkItems.length; i += batchSize) {
const batch = homeworkItems.slice(i, i + batchSize);
const batchPayload = {
};
const batchPayload = {};
//
for (const item of batch) {
@ -891,7 +888,7 @@ export default {
}
//
if (Object(batchPayload).length > 0) {
if (Object.keys(batchPayload).length > 0) {
const response = await axios.post(
`${this.targetServerUrl}/${this.machineId}/import/batch-import`,
batchPayload,
@ -904,7 +901,7 @@ export default {
if (response.data) {
if (response.data.successful > 0) {
this.migrationResults.push({
key: `批量数据 (${Object(batchPayload).length}项)`,
key: `批量数据 (${Object.keys(batchPayload).length}项)`,
success: true,
message: `成功迁移 ${response.data.successful} 项数据到服务器`,
});