提交开发分支未提交代码并修正配置
This commit is contained in:
@@ -604,15 +604,10 @@ const handleEditProfile = () => {
|
||||
|
||||
const beforeUploadAvatar: UploadProps['beforeUpload'] = file => {
|
||||
const isImage = file.type.startsWith('image/')
|
||||
const isLt20M = file.size / 1024 / 1024 < 20
|
||||
|
||||
if (!isImage) {
|
||||
message.error('只能上传图片文件')
|
||||
}
|
||||
if (!isLt20M) {
|
||||
message.error('图片大小不能超过 20MB')
|
||||
}
|
||||
return isImage && isLt20M
|
||||
return isImage
|
||||
}
|
||||
|
||||
/** handleAvatarUpload is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
@@ -626,6 +621,7 @@ const handleAvatarUpload = async (options: any) => {
|
||||
const task = createChunkUploadTask({
|
||||
file: file as File,
|
||||
scene: 'profile-avatar',
|
||||
concurrency: 3,
|
||||
api: {
|
||||
initUpload: fileApi.initAvatarChunkUpload,
|
||||
uploadChunk: fileApi.uploadAvatarChunk,
|
||||
@@ -684,18 +680,37 @@ const handleDeleteAvatar = () => {
|
||||
}
|
||||
|
||||
/** handleWechatQrUpload uploads a user profile QR image without changing the avatar. */
|
||||
const handleWechatQrUpload = async (options: any) => {
|
||||
const { file, onSuccess, onError } = options
|
||||
const handleWechatQrUpload: UploadProps['customRequest'] = async (options) => {
|
||||
const { file, onSuccess, onError, onProgress } = options
|
||||
|
||||
qrUploadPending.value = true
|
||||
const task = createChunkUploadTask({
|
||||
file: file as File,
|
||||
scene: 'profile-wechat-qr',
|
||||
concurrency: 3,
|
||||
api: {
|
||||
initUpload: fileApi.initProfileImageChunkUpload,
|
||||
uploadChunk: fileApi.uploadProfileImageChunk,
|
||||
completeUpload: fileApi.completeProfileImageChunkUpload,
|
||||
cancelUpload: fileApi.cancelProfileImageChunkUpload
|
||||
},
|
||||
onProgress: (percent) => {
|
||||
onProgress?.({ percent })
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
const response = await fileApi.uploadProfileImage(file as File)
|
||||
const { response } = await task.promise
|
||||
editForm.wechatQrCode = response as unknown as string
|
||||
onSuccess?.({ url: response })
|
||||
message.success('微信二维码上传成功')
|
||||
} catch (error) {
|
||||
console.error('微信二维码上传失败:', error)
|
||||
message.error((error as Error)?.message || '微信二维码上传失败')
|
||||
onError?.(error)
|
||||
const errorMessage = (error as Error)?.message || '微信二维码上传失败'
|
||||
if (errorMessage !== '上传已取消' && errorMessage !== 'canceled') {
|
||||
console.error('微信二维码上传失败:', error)
|
||||
message.error(errorMessage)
|
||||
onError?.(error as Error)
|
||||
}
|
||||
} finally {
|
||||
qrUploadPending.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user