1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-09-03 16:19:22 +00:00

Refactor MigrationTool.vue to simplify batch data preparation by removing unnecessary keys object. Update batch payload structure for improved clarity and consistency in data handling during migration.

This commit is contained in:
SunWuyuan 2025-05-11 12:20:24 +08:00
parent 3e78e7f60d
commit 08c6776cd1
No known key found for this signature in database
GPG Key ID: A6A54CF66F56BB64

View File

@ -675,10 +675,8 @@ export default {
//
const batchData = {
keys: {
"classworks-list-main": formattedStudentList,
"classworks-config": configWithoutStudentList,
},
"classworks-list-main": formattedStudentList,
"classworks-config": configWithoutStudentList,
};
//
@ -794,11 +792,10 @@ export default {
//
const batchData = {
keys: {
"classworks-list-main": formattedStudentList,
"classworks-config": configWithoutStudentList,
},
};
}
//
const configResponse = await axios.post(
@ -857,7 +854,7 @@ export default {
for (let i = 0; i < homeworkItems.length; i += batchSize) {
const batch = homeworkItems.slice(i, i + batchSize);
const batchPayload = {
keys: {},
};
//
@ -890,11 +887,11 @@ export default {
}
//
batchPayload.keys[`classworks-data-${dateStr}`] = value;
batchPayload[`classworks-data-${dateStr}`] = value;
}
//
if (Object.keys(batchPayload.keys).length > 0) {
if (Object(batchPayload).length > 0) {
const response = await axios.post(
`${this.targetServerUrl}/${this.machineId}/import/batch-import`,
batchPayload,
@ -907,7 +904,7 @@ export default {
if (response.data) {
if (response.data.successful > 0) {
this.migrationResults.push({
key: `批量数据 (${Object.keys(batchPayload.keys).length}项)`,
key: `批量数据 (${Object(batchPayload).length}项)`,
success: true,
message: `成功迁移 ${response.data.successful} 项数据到服务器`,
});