2025-09-30 16:31:14 +08:00
|
|
|
|
2025-10-07 10:57:49 +08:00
|
|
|
import debugCenter from '@/api/debugCenter/debugCenter';
|
|
|
|
|
const uploadConfig = {
|
|
|
|
|
670: {
|
|
|
|
|
api: debugCenter.uploadBoot, // 670对应接口
|
|
|
|
|
requiredParams: ['deviceIds', 'file']
|
|
|
|
|
},
|
|
|
|
|
6170: {
|
|
|
|
|
api: debugCenter.deviceUploadLogo,
|
|
|
|
|
requiredParams: ['deviceIds', 'file',]
|
|
|
|
|
},
|
|
|
|
|
default: {
|
|
|
|
|
api: debugCenter.uploadBoot,
|
|
|
|
|
requiredParams: ['deviceIds', 'file']
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
function handleParams(deviceType, deviceIds, file) {
|
|
|
|
|
const formattedIds = Array.isArray(deviceIds) ? deviceIds : [deviceIds];
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formattedIds.forEach(id => formData.append('deviceIds', id));
|
|
|
|
|
formData.append('file', file);
|
|
|
|
|
return formData;
|
2025-09-30 16:31:14 +08:00
|
|
|
}
|
2025-10-07 10:57:49 +08:00
|
|
|
export function uploadLogo(deviceType, deviceIds, file) {
|
|
|
|
|
const currentConfig = uploadConfig[deviceType] || uploadConfig.default;
|
|
|
|
|
const formData = handleParams(deviceType, deviceIds, file);
|
|
|
|
|
return currentConfig.api(formData);
|
|
|
|
|
}
|
|
|
|
|
export default { uploadLogo };
|