同步操作将从 lantianyu/歪fChat桌面端后端 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/register
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
phone | String | 是 | 手机号 |
password | String | 是 | 密码 |
nick | String | 是 | 昵称 |
注册成功返回
{
status: 200,
msg: '注册成功',
data: {
token,
_id,
phone,
nick,
imgUrl,
sex,
birthday,
start,
sign
}
}
该用户已注册
{
status: 400,
msg: '该用户已注册'
}
服务器错误
{
status: 404,
msg: '注册失败'
}
参数缺省
{
"status": 405,
"msg": "参数错误",
"data": [
{
"type": "field",
"msg": "手机号不合法",
"path": "phone",
"location": "body"
},
{
"type": "field",
"msg": "手机号不能为空",
"path": "phone",
"location": "body"
},
{
"type": "field",
"msg": "密码不能为空",
"path": "password",
"location": "body"
},
{
"type": "field",
"msg": "昵称不能为空",
"path": "nick",
"location": "body"
}
]
}
/login
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
phone | String | 是 | 手机号 |
password | String | 是 | 密码 |
登陆成功
{
status: 200,
msg: '登录成功',
data: {
token,
_id,
phone,
nick,
imgUrl,
sex,
birthday,
start,
sign
}
}
该用户不存在
{
status: 400,
msg: '该用户不存在'
}
密码错误
{
status: 401,
msg: '密码错误'
}
服务器错误
{
status: 404,
msg: '登录失败'
}
请求url:/home/user
请求方式:get
请求参数:
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
_id | String | 是 | 用户id(自己的) |
urlId | String | 是 | 用户主页id |
friendState
:
friendState
= 0,好友申请中(发送方)friendState
= 1,已添加好友friendState
= 2,未添加好友friendState
= 3,用户自己主页friendState
= 4,申请方(接收方)示例代码
{
status: 200,
data: {
user,
friendState: 0
}
}
服务器错误 加载失败
{
status: 404,
msg: '加载失败'
}
/tabbar/message/userinfo
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
_id | String | 是 | 用户id(自己的) |
success
{
"status": 200,
"data": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
}
}
error
{
status: 404,
data: '服务器错误'
}
/upload/user
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
file | File | 是 | 文件对象(name名: file) |
_id | String | 是 | 用户id(自己的) |
success
{
res_code: 0,
name: 文件名,
url: 文件路径
}
error
{
res_code: 404,
msg: '服务器错误'
}
/update/user
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
_id | String | 是 | 用户id(自己的) |
nick | String | 是 | 昵称 |
sex | String | 是 | 性别 |
birthday | String | 否 | 密码(xxxx-xx-xx) |
sign | String | 否 | 个性签名 |
imgUrl | String | 否 | 头像图片 |
success
{
status: 200,
msg: '保存成功',
start
}
error
{
status: 404,
msg: '保存失败'
}
参数缺省
{
"status": 405,
"msg": "参数错误",
"data": [
{
"type": "field",
"msg": "_id参数不能为空",
"path": "_id",
"location": "body"
},
{
"type": "field",
"msg": "昵称不能为空",
"path": "nick",
"location": "body"
},
{
"type": "field",
"msg": "性别不能为空",
"path": "sex",
"location": "body"
},
{
"type": "field",
"msg": "性别必须为未知/男/女",
"path": "sex",
"location": "body"
}
]
}
/search
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
keyword | String | 是 | 关键字 |
关键字空
{
status: 400,
msg: '关键字为空, 暂无数据',
data: [],
result: false
}
暂无数据
{
status: 400,
msg: '暂无数据',
result: false
}
服务器错误
{
status: 404,
msg: '服务器错误'
result: false
}
success
{
"status": 200,
"data": {
"friendList": [
{
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg",
"sign": "能失去的从来不属于我"
}
],
"groupList": [
{
"_id": "65552471a63c59f4e6755e44",
"groupName": "wifi群",
"imgUrl": "/group_pic.png"
}
]
}
}
/friend/add
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id(自己的) |
friendId | String | 是 | 好友id(对方的) |
参数缺省
{
"status": 405,
"msg": "参数错误",
"data": [
{
"type": "field",
"msg": "userId参数不能为空",
"path": "userId",
"location": "body"
},
{
"type": "field",
"msg": "friendId参数不能为空",
"path": "friendId",
"location": "body"
}
]
}
success
{
status: 200,
msg: '申请中'
}
error
{
status: 404,
msg: '申请失败,请重试'
}
只返回好友状态state为1的 => 已为好友
/contacts/friend
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id(自己的) |
success
{
"status": 200,
"data": [
{
"_id": "65623e9fde6678fd1d5a0061",
"userId": "64eec06fa61f50ab31295296",
"friendId": {
"_id": "65151e1dcf14fef88682e039",
"nick": "ces4",
"imgUrl": "/user_pic1.jpeg",
"sign": "这个人很高冷, 暂时没有留下什么"
},
"time": "2023-11-25T18:36:15.748Z",
"state": 1,
"__v": 0
},
{
"_id": "65623ec9de6678fd1d5a008e",
"userId": "64eec06fa61f50ab31295296",
"friendId": {
"_id": "65151e2ccf14fef88682e03c",
"nick": "ces5",
"imgUrl": "/user_pic1.jpeg",
"sign": "这个人很高冷, 暂时没有留下什么"
},
"time": "2023-11-25T18:36:57.664Z",
"state": 1,
"__v": 0
},
{
"_id": "65624244de6678fd1d5a02d9",
"userId": "64eec06fa61f50ab31295296",
"friendId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png",
"sign": "这个人很高冷, 暂时没有留下什么"
},
"time": "2023-11-25T18:51:48.855Z",
"state": 1,
"__v": 0
}
]
}
error
{
status: 404,
msg: '请求失败'
}
/del/friend
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id(自己的) |
friendId | String | 是 | 好友id(对方的) |
success
{
status: 200,
msg: '删除成功'
}
error
{
status: 404,
msg: '删除失败'
}
/get/friend/noagree
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id(自己的) |
success
{
"status": 200,
"data": [
{
"_id": "656d9c576a6427f7d143529e",
"userId": "64eec06fa61f50ab31295296",
"friendId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"time": "2023-12-04T09:31:03.791Z",
"state": 0,
"__v": 0
}
]
}
error
{
status: 404,
msg: '服务器错误'
}
/friend/agree
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id(自己的) |
friendId | String | 是 | 好友id(对方的) |
参数缺省
{
"status": 405,
"msg": "参数错误",
"data": [
{
"type": "field",
"msg": "userId参数不能为空",
"path": "userId",
"location": "body"
},
{
"type": "field",
"msg": "friendId参数不能为空",
"path": "friendId",
"location": "body"
}
]
}
success
{
status: 200,
msg: '添加成功'
}
error
{
status: 404,
msg: '添加失败'
}
/friend/refuse
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id(自己的) |
friendId | String | 是 | 好友id(对方的) |
参数缺省
{
"status": 405,
"msg": "参数错误",
"data": [
{
"type": "field",
"msg": "userId参数不能为空",
"path": "userId",
"location": "body"
},
{
"type": "field",
"msg": "friendId参数不能为空",
"path": "friendId",
"location": "body"
}
]
}
success
{
status: 200,
msg: '已拒绝'
}
error
{
status: 404,
msg: '服务器错误'
}
/create/group
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id(自己的) |
groupName | String | 是 | 群名 |
sign | String | 是 | 群简介 |
imgUrl | String | 否 | 群头像(url地址) |
参数缺省
{
"status": 405,
"msg": "参数错误",
"data": [
{
"type": "field",
"msg": "userId参数不能为空",
"path": "userId",
"location": "body"
},
{
"type": "field",
"msg": "群名不能为空",
"path": "groupName",
"location": "body"
},
{
"type": "field",
"msg": "群简介不能为空",
"path": "sign",
"location": "body"
}
]
}
success
{
status: 200,
msg: '创建成功'
}
error
{
status: 404,
msg: '创建失败'
}
/upload/group
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
file | File | 是 | 文件对象(name:file) |
success
{
res_code: 0,
name: 文件名,
url: 文件路径
}
/home/group
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
groupId | String | 是 | 群id |
userId | String | 是 | 用户id(自己的) |
success
{
"status": 200,
"data": {
"group": {
"_id": "65552471a63c59f4e6755e44",
"userId": "64eec06fa61f50ab31295296",
"groupName": "wifi群",
"groupNumber": 1700078705941,
"sign": "test",
"imgUrl": "/group_pic.png",
"creatTime": "2023年11月16日",
"__v": 0
},
"groupUser": [
{
"_id": "65552471a63c59f4e6755e46",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg",
"sex": "男",
"birthday": "2003-06-26"
},
"state": 1,
"__v": 0
},
{
"_id": "65562496c99b878403209080",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png",
"sex": "男",
"birthday": "2003-06-26"
},
"time": "2023-11-16T14:17:58.333Z",
"state": 1,
"__v": 0
},
{
"_id": "65623ecbde6678fd1d5a009c",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "65151e2ccf14fef88682e03c",
"nick": "ces5",
"imgUrl": "/user_pic1.jpeg",
"sex": "未知",
"birthday": ""
},
"time": "2023-11-25T18:36:59.533Z",
"state": 1,
"__v": 0
}
],
"statis": {
"maleNum": 2,
"femaleNum": 0,
"is00sBornNum": 2
}
},
"state": 1
}
state
:0 => 群聊申请中
state
:1 => 已经加入该群
state
:2 => 未加入该群
error
{
status: 404,
data: '服务器错误'
}
/get/groupUser
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
groupId | String | 是 | 群id |
success
{
"status": 200,
"data": {
"groupUser": [
{
"_id": "65552471a63c59f4e6755e46",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"state": 1,
"__v": 0
},
{
"_id": "65562496c99b878403209080",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"time": "2023-11-16T14:17:58.333Z",
"state": 1,
"__v": 0
},
{
"_id": "65623ecbde6678fd1d5a009c",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "65151e2ccf14fef88682e03c",
"nick": "ces5",
"imgUrl": "/user_pic1.jpeg"
},
"time": "2023-11-25T18:36:59.533Z",
"state": 1,
"__v": 0
}
],
"groupCreateUserId": "64eec06fa61f50ab31295296"
}
}
error
{
status: 404,
msg: '服务器错误'
}
/login
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
groupId | String | 是 | 群id |
userId | String | 是 | 用户id(自己的) |
参数缺省
{
"status": 405,
"msg": "参数错误",
"data": [
{
"type": "field",
"msg": "groupId参数不能为空",
"path": "groupId",
"location": "body"
},
{
"type": "field",
"msg": "userId参数不能为空",
"path": "userId",
"location": "body"
}
]
}
success
{
status: 200,
msg: '已发送'
}
error
{
status: 404,
msg: '申请失败'
}
/group/refuse
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
phone | String | 是 | 手机号 |
password | String | 是 | 密码 |
success
{
status: 200,
msg: '已拒绝'
}
error
{
status: 404,
msg: '服务器错误'
}
/contacts/group
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id(自己的) |
success
{
"status": 200,
"data": [
{
"_id": "65552471a63c59f4e6755e46",
"groupId": {
"_id": "65552471a63c59f4e6755e44",
"groupName": "wifi群",
"imgUrl": "/group_pic.png"
},
"userId": "64eec06fa61f50ab31295296",
"state": 1,
"__v": 0
},
{
"_id": "655a4bfac4c28d775a763a0e",
"groupId": {
"_id": "655a4bfac4c28d775a763a0c",
"groupName": "group2",
"imgUrl": "/group_pic.png"
},
"userId": "64eec06fa61f50ab31295296",
"state": 1,
"__v": 0
},
{
"_id": "655e945ef968f563f1ec6b2e",
"groupId": {
"_id": "655e945ef968f563f1ec6b2c",
"groupName": "1",
"imgUrl": "/group_pic.png"
},
"userId": "64eec06fa61f50ab31295296",
"state": 1,
"__v": 0
}
]
}
error
{
status: 404,
msg: '请求失败'
}
/get/update/group
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
groupId | String | 是 | 群id |
groupLeaderId | String | 是 | 群主id |
success
{
"status": 200,
"data": {
"groupInfo": {
"_id": "65552471a63c59f4e6755e44",
"groupName": "wifi群",
"sign": "test",
"imgUrl": "/group_pic.png"
},
"groupUserList": [
{
"_id": "65562496c99b878403209080",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"time": "2023-11-16T14:17:58.333Z",
"state": 1,
"__v": 0
},
{
"_id": "65623ecbde6678fd1d5a009c",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "65151e2ccf14fef88682e03c",
"nick": "ces5",
"imgUrl": "/user_pic1.jpeg"
},
"time": "2023-11-25T18:36:59.533Z",
"state": 1,
"__v": 0
}
]
}
}
error
{
status: 404,
msg: '服务器错误'
}
/update/groupInfo
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
_id | String | 是 | 群id |
groupName | String | 是 | 群名 |
sign | String | 是 | 群简介 |
imgUrl | String | 否 | 群头像 |
success
{
status: 200,
msg: '修改成功'
}
error
{
status: 404,
msg: '修改失败'
}
/del/groupUser
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
groupId | String | 是 | 群id |
success
{
status: 200,
msg: '已退出'
}
error
{
status: 404,
msg: '移除失败'
}
1、群主退群(解散该群)
2、群成员退群(删除该成员) => 用上面的 No.23/del/groupUser
这个接口
/del/group
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
groupId | String | 是 | 群id |
success
{
status: 200,
msg: '已解散'
}
error
{
status: 404,
msg: 'error'
}
/get/group/noagree
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
success
{
"status": 200,
"data": [
{
"_id": "656dac826a6427f7d1435313",
"groupId": {
"_id": "65552471a63c59f4e6755e44",
"groupName": "wifi群",
"imgUrl": "/group_pic.png"
},
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"time": "2023-12-04T10:40:02.156Z",
"__v": 0
}
]
}
error
{
status: 404,
data: '服务器错误'
}
/group/agree
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
groupId | String | 是 | 群id |
success
{
status: 200,
msg: '添加成功'
}
error
{
status: 404,
msg: '添加失败'
}
/space/upload/photos
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
File | File | 是 | 文件对象,最多可以上传9张图片,后端没有作文件类型校验,请前端处理(name:photos) |
success
{ res_code: 200, url: 文件url }
error
{ res_code: 500, msg: 'error' }
/space/add
post
textDesc 和 photos有一个不能为空
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
textDesc | String | 否 | 动态文字信息 |
photos | File | 否 | 照片url(传入数组对象,请使用JSON.stringify 转为字符串 |
success
{
status: 200,
msg: '发布成功'
}
error
{
status: 404,
msg: '发布失败'
}
/space/get
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
success
{
"status": 200,
"data": [
{
"_id": "656235cb6e8c66289e155057",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"textDesc": "WebRTC 的诞生,就是基于浏览器的多媒体即时通信,对于在 Web 端实现会议这个需求而言,它简直天生自带光环。而且 WebRTC 能够实现:实时双向音视频、主流浏览器支持、开发者容易入手、使用范围广且技术开源成熟等条件,且具有毫秒级的延迟特性。",
"photos": [
"/1700935111845-fan.jpg"
],
"time": "2023-11-26 1:58",
"isLike": false,
"likeList": [],
"commentList": [],
"replyList": []
},
{
"_id": "656235a26e8c66289e155037",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"textDesc": "测试",
"photos": [
"/1700935073298-é»é¼ ç¼.jpg"
],
"time": "2023-11-26 1:57",
"isLike": false,
"likeList": [],
"commentList": [],
"replyList": []
},
{
"_id": "650026f0ad11720336726630",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"textDesc": "过去的回忆",
"photos": [
"/1694508782089-he.jpeg",
"/1694508782092-me.jpeg"
],
"time": "2023-9-12 16:53",
"isLike": false,
"likeList": [],
"commentList": [
{
"_id": "6505e73a6406b9caf54f9233",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"spaceId": "650026f0ad11720336726630",
"type": 0,
"textarea": "lovefan",
"fromId": "64fb10adad117203367263fb",
"toId": "64fb10adad117203367263fb",
"time": "2023-9-17 1:34",
"__v": 0
},
{
"_id": "6505ef786406b9caf54f957d",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"spaceId": "650026f0ad11720336726630",
"type": 0,
"textarea": "想你了",
"fromId": "64fb10adad117203367263fb",
"toId": "64fb10adad117203367263fb",
"time": "2023-9-17 2:10",
"__v": 0
}
],
"replyList": [
[],
[
{
"_id": "6505f0246406b9caf54f9716",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"spaceId": "650026f0ad11720336726630",
"spaceCommentId": "6505ef786406b9caf54f957d",
"type": 1,
"textarea": "xxx",
"fromId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"toId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"time": "2023-9-17 2:12",
"__v": 0
}
]
]
}
]
}
error
{
status: 404,
msg: '服务器错误'
}
/space/del
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
_id | String | 是 | 该条动态id |
success
{
status: 200,
msg: '删除成功'
}
error
{
status: 404,
msg: '删除失败'
}
/space/details
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
success
{
"status": 200,
"data": {
"spaces": [
{
"_id": "656242bdde6678fd1d5a046c",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"textDesc": "123",
"photos": [
"/1700938428030-fan.jpg"
],
"time": "2023-11-26 2:53",
"__v": 0
}
],
"user": {
"_id": "64eec06fa61f50ab31295296",
"WaiFCode": "WaiFCode_15583251761",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
}
}
}
error
{
status: 404,
msg: 'error'
}
/space/like
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
spaceId | String | 是 | 动态id |
userId | String | 是 | 用户id |
success
{
status: 200,
msg: 'success'
}
error
{
status: 404,
msg: '服务器错误'
}
/space/comment/add/:type
post
评论类型(0 => 自己评论, 1 => 回复评论)
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
spaceId | String | 是 | 空间动态id |
textarea | String | 是 | 评论文字内容 |
fromId | String | 是 | 发送方id(主动发评论的人) |
toId | String | 是 | 回复者id(收到评论的人),如果 type 为0, fromId 和 toId 都是用户自己 |
spaceCommentId | String | 是 | 要回复评论的那条id |
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
type | Number | 是 | 评论类型(0 => 自己评论, 1 => 回复评论) |
success
{
status: 200,
msg: 'success'
}
error
{
status: 404,
msg: 'error'
}
/space/comment/del/:type
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
_id | String | 是 | 动态id |
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
type | String | 是 | 评论类型(0 => 自己评论, 1 => 回复评论) |
success
{
status: 200,
msg: '删除成功'
}
error
{
status: 404,
msg: '服务器错误'
}
/space/del
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
_id | String | 是 | 动态id |
success
{
status: 200,
msg: '删除成功'
}
error
{
status: 404,
msg: '删除失败'
}
/message/friend
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
friendId | String | 是 | 好友id |
pageNum | Number | 是 | 页数(聊天记录采取分页查询的方式,每页20条数据) |
与该用户还不是好友
{
status: 202,
data: {
"friendNick": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f"
}
},
msg: '您与ta还不是好友哦'
}
暂无更多
{
"status": 201,
"data": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f"
},
"msg": "暂无更多"
}
success
{
"status": 200,
"data": {
"friendNick": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f"
},
"messageList": [
{
"_id": "65669a890b61d69dd01c256a",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"friendId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"message": "# Hello 歪fChat Editor",
"msgType": 5,
"time": "Wed Nov 29 2023 09:57:29 GMT+0800 (中国标准时间)",
"state": 1,
"__v": 0
},
{
"_id": "65669a900b61d69dd01c256d",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"friendId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"message": "{\"fileName\":\"index.js\",\"size\":1192,\"fileSuffixName\":\"js\",\"url\":\"/adc960a0c14c9a143ca0266005633c53.js\"}",
"msgType": 3,
"time": "Wed Nov 29 2023 09:57:36 GMT+0800 (中国标准时间)",
"state": 1,
"__v": 0
},
{
"_id": "65669a979a2f15e8b4a0a4ff",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"friendId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"message": "{\"url\":\"/1701223063717-fan.jpg\",\"height\":110.92592592592594}",
"msgType": 1,
"time": "Wed Nov 29 2023 09:57:43 GMT+0800 (中国标准时间)",
"state": 1,
"__v": 0
},
{
"_id": "6566a2029a2f15e8b4a0a5e0",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"friendId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"message": "Hh",
"msgType": 0,
"time": "Wed Nov 29 2023 10:29:22 GMT+0800 (中国标准时间)",
"state": 1,
"__v": 0
},
{
"_id": "6566a20a9a2f15e8b4a0a5eb",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"friendId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"message": "a",
"msgType": 0,
"time": "Wed Nov 29 2023 10:29:30 GMT+0800 (中国标准时间)",
"state": 1,
"__v": 0
},
{
"_id": "6566a2bd9a2f15e8b4a0a630",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"friendId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"message": "12",
"msgType": 0,
"time": "Wed Nov 29 2023 10:32:29 GMT+0800 (中国标准时间)",
"state": 1,
"__v": 0
},
{
"_id": "6566a2c09a2f15e8b4a0a633",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"friendId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"message": "<img src=\"./gif/17.gif\" width=\"65\" height=\"65\">",
"msgType": 4,
"time": "Wed Nov 29 2023 10:32:32 GMT+0800 (中国标准时间)",
"state": 1,
"__v": 0
},
{
"_id": "656dcf867594f2bfc3e9e46f",
"userId": {
"_id": "64fb10adad117203367263fb",
"nick": "臭粑卡皮巴拉",
"imgUrl": "/user2.png"
},
"friendId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"message": "{\"url\":\"/1701695366668-é»é¼ ç¼.jpg\",\"height\":112.0607787274454}",
"msgType": 1,
"time": "Mon Dec 04 2023 21:09:26 GMT+0800 (中国标准时间)",
"state": 0,
"__v": 0
}
]
}
}
error
{
status: 404,
msg: '服务器错误'
}
/message/group
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
groupId | String | 是 | 群id |
pageNum | Number | 是 | pageNum当前页码,从1开始 |
未加入该群
{
"status": 202,
"data": {
"_id": "65552471a63c59f4e6755e44",
"groupName": "wifi群"
},
"msg": "您还未加入该群哦"
}
success
{
"status": 200,
"data": {
"groupNick": {
"_id": "65552471a63c59f4e6755e44",
"groupName": "wifi群"
},
"messageList": [
{
"_id": "65626a027171e3582f99bc25",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"message": "1",
"msgType": 0,
"time": "Sun Nov 26 2023 05:41:22 GMT+0800 (中国标准时间)",
"__v": 0
},
{
"_id": "65626a027171e3582f99bc30",
"groupId": "65552471a63c59f4e6755e44",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"message": "1",
"msgType": 0,
"time": "Sun Nov 26 2023 05:41:22 GMT+0800 (中国标准时间)",
"__v": 0
}
]
}
}
暂无更多
{
status: 201,
"data": {
"_id": "65552471a63c59f4e6755e44",
"groupName": "wifi群"
},
msg: '暂无更多'
}
error
{
status: 404,
msg: '服务器错误'
}
/chat/private/photo
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
File | File | 是 | 文件对象,name:photo |
success
{res_code: 200, name: 文件名, url: 文件路径}
error
{ res_code: 500, msg: 'error' }
/chat/group/photo
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
File | File | 是 | 文件对象 |
success
{ res_code: 200, name: 文件名, url: 文件路径 }
/chat/file/:type
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
type | String | 是 | 类型(private或group) |
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
blob | Blob | 是 | 文件切割,blob对象 |
error
{
status: 404,
msg: '上传失败'
}
success
{
status: 200,
msg: '上传成功'
}
/merge/:type
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
type | String | 是 | 类型(private或group) |
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
fileHash | String | 是 | 文件Hash |
fileName | String | 是 | 文件名 |
size | Number | 是 | 文件切片大小 |
success
{
status: 200,
msg: '合并成功',
url: 文件路径
}
error
{
status: 401,
msg: '合并失败,请重新上传'
}
/verify/:type
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
type | String | 是 | 类型(private或group) |
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
fileHash | String | 是 | 文件hash |
fileName | String | 是 | 文件名 |
success:文件不需要重新上传
{
status: 200,
data: {
shouldUpload: false, // 不需要重新上传
url: 文件路径
}
}
success:文件需要重新上传
{
status: 200,
data: {
shouldUpload: true, // 重新上传
existChunks: chunkPaths // 数组,存放已经上传过的部分切片(若没有上传过就是空)
}
}
error
{
status: 404,
data: {
shouldUpload: true,
msg: '上传失败'
}
}
/message/list
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
success
{
"status": 200,
"data": [
{
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg",
"lastMsg": {
"_id": "656dcf867594f2bfc3e9e46f",
"message": "{\"url\":\"/1701695366668-é»é¼ ç¼.jpg\",\"height\":112.0607787274454}",
"msgType": 1,
"time": "Mon Dec 04 2023 21:09:26 GMT+0800 (中国标准时间)"
},
"type": "friendChat"
},
{
"_id": "65552471a63c59f4e6755e44",
"groupName": "wifi群",
"imgUrl": "/group_pic.png",
"lastMsg": {
"message": "?",
"msgType": 0,
"time": "Mon Nov 27 2023 17:33:29 GMT+0800 (中国标准时间)"
},
"type": "groupChat",
"unreadMsgCount": 0
}
]
}
error
{
status: 404,
msg: '服务器错误'
}
/message/read/:type
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
phone | String | 是 | 类型(值为friend 或group ) |
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
id | String | 是 | 如果type为friend 就是好友id,如果是group 就是群id |
success
{
status: 200,
msg: '已读'
}
error
{
status: 404,
msg: '服务器错误'
}
/notes/add
post
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
userId | String | 是 | 用户id |
text | String | 是 | 便签内容 |
color | String | 是 | 便签颜色 |
time | String | 是 | 发布时间(xxxx-xx-xx) |
success
status: 200,
msg: '已发布',
_id: 便签id
}
error
{
status: 404,
msg: '服务器错误'
}
/notes/get
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
pageNum | Number | 是 | 当前分页数(每页12条) |
success
{
"status": 200,
"data": [
{
"_id": "6514522318f60a765cf4593f",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"text": "...",
"color": "#fbdc7c",
"time": "Thu Sep 28 2023 00:02:43 GMT+0800 (中国标准时间)",
"__v": 0
},
{
"_id": "64f85897dc7c6cf85d756b24",
"userId": {
"_id": "64eec06fa61f50ab31295296",
"nick": "wifi歪f",
"imgUrl": "/user_pic1.jpeg"
},
"text": "test",
"color": "#fff5a8",
"time": "Wed Sep 06 2023 18:46:47 GMT+0800 (中国标准时间)",
"__v": 0
}
]
}
error
{
status: 404,
data: '服务器错误'
}
/notes/del
get
参数名 | 类型 | 是否必填 | 描述 |
---|---|---|---|
_id | String | 是 | 便签id |
success
{
status: 200,
msg: '删除成功'
}
error
{
status: 404,
msg: '删除失败, 请稍后再试'
}
login
事件用户登陆后触发,前端传递的参数为:userId
socket.emit('login', socket.id)
private_chat
事件私聊事件,用户发送完消息后,前端通过该事件通知后端,后端接收到后返回给前端两个事件。前端传递的参数为:dataMsg, uId, fId
dataMsg:参考前端ts类型
type MessageType = {
fromId?: string;
toId?: string;
userId: {
_id: string;
nick: string;
imgUrl: string;
},
groupInfo?: {
_id: string;
groupName: string;
imgUrl: string;
};
/*
msgType: 0 => 文字消息,
1 => 图片消息,
2 => 视频消息,
3 => 文件消息,
4 => 单个emoji(变成大的emoji),
5 => markdown,
6 => 语音通话,
7 => 视频通话,
8 => 屏幕共享
*/
time: string | Date;
msgType: number;
message: string;
loading?: boolean; // 临时图片loading
progressNum?: number; // 进度条数字
uid?: number; // 临时图片uid
}
uId:发送方id
fId:接受方id
socket.to(users[fId]).emit('private_chat', data) // 未读好友消息
socket.to(users[fId]).emit('unread_message', uId)
data:
let data = {
userId: dataMsg.userId,
msgType: dataMsg.msgType, // msgType 消息类型(0:文字(包括表情包),1:图片)
message: dataMsg.message,
time: new Date(),
fromId: uId, // 发送方id
toId: fId // 接收方id
}
join_group
事件用户通过群聊发送消息,必须先触发join_group
事件,传递gId
群id,将该好友加入到不同的群聊房间
group_chat
事件用户群聊事件,通过该事件,用户b可以获取到用户a发送的信息,前提是必须有join_group
事件,接收参数dataMsg, uId, gId
。
dataMsg同私聊事件的dataMsg
uId是发送者id
gId是发送到哪个群的id(群id)
socket.to(gId).emit('group_chat', data)
socket.to(gId).emit('unread_message', gId)
返回的data:
let data = {
userId: dataMsg.userId, // 发消息好友信息
groupInfo: {
_id: info._id,
groupName: info.groupName,
imgUrl: info.imgUrl
}, // 群聊信息
msgType: dataMsg.msgType, // msgType 消息类型(0:文字(包括表情包),1:图片)
message: dataMsg.message,
time: new Date(),
fromId: uId,
toId: gId
}
init_apply_notice
初始化申请消息通知事件在tabbar(h5)端,在侧边栏中(桌面端应用),初始化消息通知数,传递userId给后端
socket.emit('init_apply_notice', { friendNoticeNum, groupNoticeNum })
// friendNoticeNum 好友消息数
// groupNoticeNum 群消息数
apply_notice
好友、群申请通知事件参数同5
apply_notice
,前端需要接收该事件
socket.to(users[userId]).emit('apply_notice', { friendNoticeNum, groupNoticeNum })
agree_apply
同意好友/群申请事件前端需要传递给接收者id(toId),接收者id就是用户a给用户b发送好友/群聊申请,那么用户b的id就是接收者id
socket.to(users[toId]).emit('agree_apply')
logout
退出登陆事件前端需要向后端传递userId
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。