提交开发分支未提交代码并修正配置
This commit is contained in:
@@ -550,7 +550,7 @@
|
||||
*/
|
||||
import { computed, h, onMounted, reactive, ref } from 'vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import type { FormInstance, UploadProps } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import DraftActions from '@/components/DraftActions.vue'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
@@ -578,6 +578,7 @@ import type { IdType } from '@/utils/id'
|
||||
import { sameId } from '@/utils/id'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { createChunkUploadTask } from '@/utils/chunk-upload'
|
||||
import { useAdminViewport } from '@/composables/useAdminViewport'
|
||||
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
|
||||
import AdminMobileFab from '@/components/admin/AdminMobileFab.vue'
|
||||
@@ -888,30 +889,44 @@ const handlePhoneInput = () => {
|
||||
/** beforeUploadWechatQr validates QR image files before upload. */
|
||||
const beforeUploadWechatQr = (file: File) => {
|
||||
const isImage = file.type.startsWith('image/')
|
||||
const isLt10M = file.size / 1024 / 1024 < 10
|
||||
if (!isImage) {
|
||||
message.error('只能上传图片文件')
|
||||
}
|
||||
if (!isLt10M) {
|
||||
message.error('图片大小不能超过 10MB')
|
||||
}
|
||||
return isImage && isLt10M
|
||||
return isImage
|
||||
}
|
||||
|
||||
/** handleWechatQrUpload uploads a QR image through admin object storage and stores the signed URL. */
|
||||
const handleWechatQrUpload = async (options: any) => {
|
||||
const { file, onSuccess, onError } = options
|
||||
const handleWechatQrUpload: UploadProps['customRequest'] = async (options) => {
|
||||
const { file, onSuccess, onError, onProgress } = options
|
||||
wechatQrUploading.value = true
|
||||
const task = createChunkUploadTask({
|
||||
file: file as File,
|
||||
scene: 'admin-user-wechat-qr',
|
||||
concurrency: 3,
|
||||
api: {
|
||||
initUpload: adminFileApi.initChunkUpload,
|
||||
uploadChunk: adminFileApi.uploadChunk,
|
||||
completeUpload: adminFileApi.completeChunkUpload,
|
||||
cancelUpload: adminFileApi.cancelChunkUpload
|
||||
},
|
||||
onProgress: (percent) => {
|
||||
onProgress?.({ percent })
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
const uploaded = await adminFileApi.uploadFile(file as File)
|
||||
const { response: uploaded } = await task.promise
|
||||
const signedUrl = await adminFileApi.getSignedUrl(uploaded.id)
|
||||
formState.wechatQrCode = signedUrl as unknown as string
|
||||
onSuccess?.(uploaded)
|
||||
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 {
|
||||
wechatQrUploading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user