feat(api): 重构图片地址管理与上传机制

- 替换开发环境API基础URL为本地服务地址
- 实现签名URL本地缓存机制,解决微信按URL缓存图片导致重复下载问题
- 添加缓存清理功能,包括过期清理和按需删除特定缓存项
- 集成阿里云OSS上传功能,支持直传减少服务器带宽占用
- 优化头像地址处理逻辑,统一使用签名缓存避免地址频繁变化
- 移除过时的OSS上传示例文件oss-upload.js
- 更新课程页面实现跳转第三方小程序功能
- 调整打卡记录图片地址获取方式,统一使用新的签名缓存逻辑
- 优化图片上传流程,增加压缩处理和批量上传支持
- 完善认证模块中的缓存清理逻辑,切换账号时清除相关图片缓存
- 添加后端环境变量配置模板和代理文档说明
This commit is contained in:
王宏豪
2026-09-23 17:46:40 +08:00
parent ca21b1b9dc
commit ba2d9245ef
11 changed files with 448 additions and 290 deletions

View File

@@ -185,7 +185,7 @@ Page({
myChecked: !!res.my_checked,
myStatus: res.my_status || '',
myRecord: res.my_record || null,
myThumbs: ((res.my_record && res.my_record.attachments) || []).map((p) => api.planFileUrl(p)),
myThumbs: api.attachmentThumbs(res.my_record),
unassignedCount: res.unassigned_count || 0,
isTeacher,
myGroup: res.my_group || '',
@@ -239,11 +239,10 @@ Page({
url: '/api/v1/plan/group',
data: { type, group_name: groupName, period_key: this.data.periodKey }
}).then((res) => {
// 附件相对路径转完整 URL(列表已不渲染缩略图,allThumbs 全量留给详情弹层)
const members = (res.members || []).map((m) => {
const all = (((m.record || {}).attachments) || []).map((p) => api.planFileUrl(p));
return { ...m, allThumbs: all };
});
// 附件转展示地址(列表已不渲染缩略图,allThumbs 全量留给详情弹层)
// 注意走 attachmentThumbs 而不是自己 map:后端返回的签名 URL 在 attachment_urls 里,
// 而 attachments 必须保持规范相对路径(提交打卡时会被原样回写)
const members = (res.members || []).map((m) => ({ ...m, allThumbs: api.attachmentThumbs(m.record) }));
this.setData({
loading: false,
periodKey: res.period_key || this.data.periodKey,
@@ -284,7 +283,7 @@ Page({
data: { type, page: 1, size: 20 }
}).then((res) => {
const history = (res.list || []).map((item) => {
const all = (item.attachments || []).map((p) => api.planFileUrl(p));
const all = api.attachmentThumbs(item);
return {
...item,
// 卡片里只铺前 2 张缩略图,弹层用 allThumbs 看全部