- 删除未使用的空组件目录、死代码导出(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>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { api } from '../../utils/api'
|
|
import { getAvatarGradient, formatTime } from '../../utils/format'
|
|
|
|
Page({
|
|
data: { statusBarHeight: 0, list: [] as any[] },
|
|
|
|
onLoad() {
|
|
const info = wx.getSystemInfoSync()
|
|
this.setData({ statusBarHeight: info.statusBarHeight })
|
|
this.loadNotifications()
|
|
},
|
|
|
|
async loadNotifications() {
|
|
try {
|
|
const list = await api.getNotifications()
|
|
const enriched = (list || []).map((n: any) => ({
|
|
...n,
|
|
gradient: getAvatarGradient(n.fromId || ''),
|
|
timeText: formatTime(n.createdAt),
|
|
}))
|
|
this.setData({ list: enriched })
|
|
} catch {}
|
|
},
|
|
|
|
onItemTap(e: WechatMiniprogram.CustomEvent) {
|
|
const item = e.currentTarget.dataset.item as any
|
|
if (item?.postId) wx.navigateTo({ url: `/pages/post-detail/post-detail?id=${item.postId}` })
|
|
},
|
|
|
|
onReadAll() {
|
|
api.markAllRead().catch(() => {})
|
|
const list = this.data.list.map((n: any) => ({ ...n, isRead: true }))
|
|
this.setData({ list })
|
|
},
|
|
|
|
onBack() { wx.navigateBack() },
|
|
})
|