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 看全部

View File

@@ -137,12 +137,19 @@
<view class="empty-icon">📒</view>
<view class="empty-text">暂无{{types[typeIndex]}}记录</view>
</view>
<!-- 卡片直接铺内容:正文 3 行截断、缩略图最多 2 张;全部文字与图片在「查看详情」弹层里看 -->
<!-- 卡片直接铺内容:正文 3 行截断、缩略图最多 2 张;点卡片任意位置(文字或图片)
打开该条详情弹层,弹层里看全文全图。
注意:绑定只能在这层,卡片内不得再绑 openHistoryDetail —— 子节点再绑一次会先执行自己的
handler 再冒泡到卡片,同 tick 连发 2 次 setData 触发 recursive update detected。
缩略图故意不加 catchtap,让点击冒泡到卡片即打开弹层(放大预览在弹层内做)。 -->
<view
class="history-card"
wx:for="{{history}}"
wx:key="id"
wx:for-index="hi"
data-hi="{{hi}}"
hover-class="history-card-hover"
bindtap="openHistoryDetail"
>
<view class="history-head">
<view class="history-period">{{item.period_key}}</view>
@@ -161,7 +168,6 @@
mode="aspectFill"
></image>
</view>
<view class="tap-hint" data-hi="{{hi}}" hover-class="tap-hint-hover" bindtap="openHistoryDetail">查看详情 ›</view>
</view>
</view>
</block>

View File

@@ -140,7 +140,9 @@
padding: 24rpx;
margin-bottom: 18rpx;
box-shadow: 0 6rpx 20rpx rgba(44, 24, 16, 0.05);
transition: transform .15s ease, box-shadow .15s ease;
}
.history-card-hover { transform: scale(.99); box-shadow: 0 10rpx 24rpx rgba(44, 24, 16, 0.10); }
.history-head {
display: flex;
align-items: center;