chore:
This commit is contained in:
@@ -80,32 +80,11 @@ export default {
|
||||
count: 9,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
success: (res) => {
|
||||
that.hideToolsPanel()
|
||||
for (const p of res.tempFilePaths) {
|
||||
const pending = {
|
||||
id: ++that.messageId,
|
||||
role: 'user',
|
||||
type: 'image',
|
||||
content: '',
|
||||
imageUrl: p,
|
||||
uploading: true,
|
||||
uploadError: null,
|
||||
uploaded: null,
|
||||
timestamp: Date.now()
|
||||
}
|
||||
that.$emit('image-selected', pending)
|
||||
try {
|
||||
const uploaded = await uploadImage(p)
|
||||
that.$set(pending, 'uploading', false)
|
||||
that.$set(pending, 'uploaded', uploaded)
|
||||
that.$set(pending, 'imageUrl', uploaded.url)
|
||||
} catch (e) {
|
||||
that.$set(pending, 'uploading', false)
|
||||
that.$set(pending, 'uploadError', e.message || '上传失败')
|
||||
uni.showToast({ title: '图片上传失败: ' + (e.message || ''), icon: 'none' })
|
||||
}
|
||||
}
|
||||
// 新交互: 选图后不直接进聊天区, 交给父组件作为输入框附件预览,
|
||||
// 用户可继续输入文字, 点发送时图文一起发出
|
||||
that.$emit('image-picked', res.tempFilePaths || [])
|
||||
},
|
||||
fail: (err) => {
|
||||
if (err.errMsg && !err.errMsg.includes('cancel')) {
|
||||
|
||||
Reference in New Issue
Block a user