Pinia Store,用于管理用户的好友列表、好友请求以及相关操作。
- Source:
Methods
(inner) addNewFriend(newFriend) → {void}
将新的好友添加到本地 `friendList`。
在添加前会检查好友是否已存在,避免重复。
Parameters:
Name | Type | Description |
---|---|---|
newFriend |
object | 新添加的好友对象。 |
- Source:
Returns:
- Type
- void
(inner) clearUnreadRequestCount() → {void}
将未读好友请求计数重置为 0。
- Source:
Returns:
- Type
- void
(inner) deleteFriend(friendId) → {Promise.<void>}
根据好友 ID 从后端删除好友,并更新本地 `friendList`。
Parameters:
Name | Type | Description |
---|---|---|
friendId |
string | 要删除的好友的 ID。 |
- Source:
Throws:
-
如果删除好友失败,会打印错误信息。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) getIncomingRequests() → {Promise.<void>}
从后端 API 获取当前用户收到的好友请求列表,并更新 `friendRequestList`。
同时更新 `unreadRequestCount` 为当前请求列表的长度。
- Source:
Throws:
-
如果获取请求列表失败,会打印错误信息。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) getList() → {Promise.<void>}
从后端 API 获取当前用户的好友列表,并更新 `friendList` 状态。
- Source:
Throws:
-
如果获取好友列表失败,会打印错误信息。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) handleNewRequest(newRequestData) → {void}
处理新的实时好友请求。
将新请求添加到 `friendRequestList` 的最前面,增加未读计数,并发送桌面通知。
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
newRequestData |
object | 新的好友请求数据。
Properties
|
- Source:
Returns:
- Type
- void
(inner) useFriendStore() → {Object}
Pinia Store,用于管理用户的好友关系,包括好友列表、好友请求和未读请求计数。
Properties:
Name | Type | Description |
---|---|---|
friendList |
Ref.<Array.<object>> | 当前用户的好友列表。 |
friendRequestList |
Ref.<Array.<object>> | 当前用户收到的好友请求列表。 |
unreadRequestCount |
Ref.<number> | 未处理的好友请求数量。 |
getList |
function | 从后端获取并更新好友列表。 |
getIncomingRequests |
function | 从后端获取并更新收到的好友请求列表,并更新未读请求计数。 |
clearUnreadRequestCount |
function | 清除未读好友请求计数。 |
handleNewRequest |
function | 处理新的实时好友请求,将其添加到列表中并发送通知。 |
addNewFriend |
function | 将新朋友添加到好友列表。 |
deleteFriend |
function | 从后端删除好友并更新本地列表。 |
- Source:
Returns:
- Type
- Object