修复小程序上传图片预览

This commit is contained in:
2026-07-21 19:48:31 +08:00
parent e3f5ad1ba1
commit a84646ea60
4 changed files with 40 additions and 8 deletions
+16
View File
@@ -107,6 +107,21 @@ function uploadObjectFile(filePath) {
})
}
function resolveUploadedImagePreviewUrl(uploadResult, fallbackFilePath) {
const localPath = String(fallbackFilePath || '').trim()
if (localPath) {
return localPath
}
if (!uploadResult || typeof uploadResult !== 'object') {
return ''
}
const primaryUrl = String(uploadResult.primaryUrl || '').trim()
if (primaryUrl) {
return primaryUrl
}
return String(uploadResult.fileUrl || '').trim()
}
function uploadProfileImage(filePath) {
return uploadFile({
url: '/user/upload-profile-image',
@@ -131,6 +146,7 @@ module.exports = {
chooseImageFilePaths,
chooseImageFilePath,
uploadObjectFile,
resolveUploadedImagePreviewUrl,
uploadAvatar,
uploadProfileImage
}