Files
chenwu b02e26f602 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>
2026-06-07 16:27:28 +08:00

28 lines
838 B
JavaScript

const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })
const db = cloud.database()
const _ = db.command
const RESULT_LIMIT = 20
function escapeRegExp(s) {
return String(s).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
}
exports.main = async (event, context) => {
const keyword = String((event && event.keyword) || '').trim()
if (!keyword) return { code: 0, data: [] }
try {
const re = db.RegExp({ regexp: escapeRegExp(keyword), options: 'i' })
const res = await db.collection('users')
.where(_.or([{ nickName: re }, { handle: re }, { location: re }]))
.field({ nickName: true, avatarUrl: true, bio: true, handle: true, location: true })
.limit(RESULT_LIMIT)
.get()
return { code: 0, data: res.data }
} catch (e) {
return { code: -1, message: e.message }
}
}