- 删除未使用的空组件目录、死代码导出(clearAuth/calcDistance/COLORS/ AVATAR_GRADIENTS/Message/TabBarItem/deletePost/uploadImage/getFileURL/ _initLogin),确保程序仍可正常运行 - 新增 8 个云函数并补全对应页面逻辑:getMessages/sendMessage(私信聊天)、 getHotTopics/searchPosts/searchUsers(搜索)、getStory(故事,复用 posts 集合)、getNotifications/markAllRead(基于点赞评论聚合的通知系统) - 在 cloudbaserc.json 中注册全部新云函数,并通过 --deployMode zip 完成部署 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
583 B
JavaScript
20 lines
583 B
JavaScript
const cloud = require('wx-server-sdk')
|
|
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })
|
|
const db = cloud.database()
|
|
|
|
// 与 getNotifications 配套:把"已读截止时间"写到用户文档上,
|
|
// 之后凡是早于该时间的通知都视为已读
|
|
exports.main = async (event, context) => {
|
|
const { OPENID } = cloud.getWXContext()
|
|
|
|
try {
|
|
await db.collection('users')
|
|
.where({ openid: OPENID })
|
|
.update({ data: { lastReadNotificationsAt: db.serverDate() } })
|
|
|
|
return { code: 0, data: null }
|
|
} catch (e) {
|
|
return { code: -1, message: e.message }
|
|
}
|
|
}
|