feat: enhance profile editing and image upload functionality
- Introduced a utility function to ensure absolute media URLs for user profile images. - Updated the user cache synchronization method to handle profile data more effectively, including avatar, nickname, phone, and MBTI. - Refactored the avatar upload process to utilize the new URL handling function, improving reliability. - Modified the super article editor to focus on image uploads instead of file uploads, enhancing user experience with clearer labeling and prompts. This update aims to streamline user profile management and improve the image upload experience in the application.
This commit is contained in:
@@ -99,49 +99,16 @@ Page({
|
||||
this.setData({ content: `${this.data.content}#链接(https://)` })
|
||||
},
|
||||
|
||||
chooseReferenceFiles() {
|
||||
/** 参考素材:仅从相册/相机选图片并上传(AI 侧按图理解) */
|
||||
chooseReferenceImages() {
|
||||
this.syncAuditMode()
|
||||
if (this.data.auditMode || app.globalData.auditMode) {
|
||||
wx.showToast({ title: '审核模式下不可用', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (typeof wx.chooseMessageFile !== 'function') {
|
||||
wx.showModal({
|
||||
title: '添加参考',
|
||||
content: '当前环境不支持从聊天记录选文件,可从相册选择图片作为参考。',
|
||||
confirmText: '选图片',
|
||||
cancelText: '取消',
|
||||
success: (r) => {
|
||||
if (r.confirm) this._pickReferenceImagesFromAlbum()
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.chooseMessageFile({
|
||||
count: 15,
|
||||
type: 'all',
|
||||
success: (res) => {
|
||||
this.handlePickedFiles(res.tempFiles || [])
|
||||
},
|
||||
fail: (err) => {
|
||||
const em = String((err && err.errMsg) || '')
|
||||
if (/cancel|取消/i.test(em)) return
|
||||
console.warn('[super-article-editor] chooseMessageFile fail', err)
|
||||
wx.showModal({
|
||||
title: '无法打开会话文件',
|
||||
content:
|
||||
'开发者工具常不支持此能力,请用真机重试;或改用相册图片作为参考。',
|
||||
confirmText: '相册图片',
|
||||
cancelText: '取消',
|
||||
success: (r) => {
|
||||
if (r.confirm) this._pickReferenceImagesFromAlbum()
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
this._pickReferenceImagesFromAlbum()
|
||||
},
|
||||
|
||||
/** 相册图片兜底(路径结构与 chooseMessageFile.tempFiles 对齐) */
|
||||
_pickReferenceImagesFromAlbum() {
|
||||
const mapFromChooseMedia = (res) => {
|
||||
const files = res.tempFiles || []
|
||||
@@ -296,7 +263,7 @@ Page({
|
||||
}
|
||||
|
||||
if (this.data.attachedFiles.some((x) => x.uploading)) {
|
||||
wx.showToast({ title: '请等待文件上传完成', icon: 'none' })
|
||||
wx.showToast({ title: '请等待图片上传完成', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -322,7 +289,7 @@ Page({
|
||||
.map((x) => x.url)
|
||||
|
||||
if (!prompt && !referenceText && materialUrls.length === 0 && imageUrls.length === 0) {
|
||||
wx.showToast({ title: '请填写提示词或添加参考文件', icon: 'none' })
|
||||
wx.showToast({ title: '请填写提示词或添加参考图', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user