chore: 清理冗余代码并补全私信/搜索/故事/通知功能

- 删除未使用的空组件目录、死代码导出(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>
This commit is contained in:
2026-06-07 16:27:28 +08:00
parent 3d21a9d297
commit b02e26f602
27 changed files with 457 additions and 102 deletions

View File

@@ -1,4 +1,4 @@
import { Post, UserProfile, NearbyUser, Pet } from '../types/index'
import { Post, UserProfile, NearbyUser, Pet, Comment } from '../types/index'
type CloudResult<T> = { result: { code: number; data: T; message?: string } }
@@ -31,9 +31,6 @@ export const api = {
petId?: string
}) => call<Post>('createPost', params),
deletePost: (postId: string) =>
call<void>('deletePost', { postId }),
likePost: (postId: string) =>
call<{ liked: boolean; count: number }>('likePost', { postId }),
@@ -58,11 +55,11 @@ export const api = {
getFollowList: (type: 'following' | 'followers', userId?: string) =>
call<UserProfile[]>('getFollowList', { type, userId }),
getMessages: (page = 0) =>
call<{ list: any[]; unreadCount: number }>('getMessages', { page }),
getMessages: (peerId: string, page = 0) =>
call<{ list: any[]; unreadCount: number }>('getMessages', { peerId, page }),
sendMessage: (toId: string, content: string, type = 'text') =>
call<void>('sendMessage', { toId, content, type }),
call<{ _id: string }>('sendMessage', { toId, content, type }),
updatePet: (pet: Partial<Pet> & { _id?: string }) =>
call<Pet>('updatePet', { pet }),
@@ -70,15 +67,21 @@ export const api = {
deletePet: (petId: string) =>
call<void>('deletePet', { petId }),
uploadImage: async (filePath: string): Promise<string> => {
const ext = filePath.split('.').pop() || 'jpg'
const cloudPath = `posts/${Date.now()}_${Math.random().toString(36).slice(2)}.${ext}`
const res = await wx.cloud.uploadFile({ cloudPath, filePath })
return res.fileID
},
getHotTopics: () =>
call<{ tag: string; count: number }[]>('getHotTopics'),
getFileURL: async (fileID: string): Promise<string> => {
const res = await wx.cloud.getTempFileURL({ fileList: [fileID] })
return res.fileList[0]?.tempFileURL || fileID
},
searchPosts: (keyword: string) =>
call<Post[]>('searchPosts', { keyword }),
searchUsers: (keyword: string) =>
call<UserProfile[]>('searchUsers', { keyword }),
getStory: (id: string) =>
call<any[]>('getStory', { id }),
getNotifications: () =>
call<any[]>('getNotifications'),
markAllRead: () =>
call<void>('markAllRead'),
}