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
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
</view>
|
||||
<view style="height: {{statusBarHeight + 44}}px;"></view>
|
||||
|
||||
<!-- AI:参考文件 + 提示词 -->
|
||||
<!-- AI:参考图片 + 提示词 -->
|
||||
<view class="card">
|
||||
<text class="section-title">AI 写文章</text>
|
||||
<text class="label">参考文件(可多选)</text>
|
||||
<text class="label">参考图片(可多选)</text>
|
||||
<view class="file-actions">
|
||||
<view class="add-file-btn" bindtap="chooseReferenceFiles">+ 添加文件</view>
|
||||
<view class="add-file-btn" bindtap="chooseReferenceImages">+ 添加图片</view>
|
||||
</view>
|
||||
<view wx:for="{{attachedFiles}}" wx:key="id" class="file-row">
|
||||
<view class="file-main">
|
||||
@@ -25,7 +25,7 @@
|
||||
</view>
|
||||
<text class="file-remove" data-id="{{item.id}}" bindtap="removeAttachedFile">移除</text>
|
||||
</view>
|
||||
<text class="hint">可选图片、TXT/MD/JSON 等文本;PDF/Office 将作为附件上传,服务端尽量抽取纯文本。单文件不超 30MB。会话文件请在真机微信内选取;开发者工具若无效可改用相册图片。</text>
|
||||
<text class="hint">从相册或相机添加参考图,可多选(单次最多 9 张),上传后参与 AI 生成。单张建议不超 30MB。</text>
|
||||
|
||||
<text class="label">提示词</text>
|
||||
<view class="textarea-wrap">
|
||||
|
||||
Reference in New Issue
Block a user