Pinia Store,用于管理用户所属的群组列表、活跃群组状态、群组邀请以及群组成员操作。
- Source:
Methods
(inner) addNewGroup(newGroup) → {void}
向群组列表中添加一个新创建的群组。
Parameters:
Name | Type | Description |
---|---|---|
newGroup |
object | 新创建的群组对象。 |
- Source:
Returns:
- Type
- void
(inner) clearActiveGroup() → {void}
清除当前活跃群组的状态,通常在切换到私聊会话时调用。
- Source:
Returns:
- Type
- void
(inner) disbandGroup() → {Promise.<void>}
解散当前活跃的群组。
成功后从群组列表中移除该群组,并尝试激活列表中的下一个群组。
- Source:
Throws:
-
如果解散群组失败,会打印错误信息并显示提示。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) fetchGroupMembers() → {Promise.<void>}
获取当前活跃群组的成员列表。
- Source:
Throws:
-
如果获取成员列表失败,会打印错误信息。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) getGroupInvitations() → {Promise.<void>}
从后端 API 获取用户收到的所有群组邀请,并更新 `groupInvitations` 状态。
同时更新 `unreadGroupInvitation` 的数量。
- Source:
Throws:
-
如果获取群组邀请失败,会打印错误信息。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) handleKickGroupMember(memberId) → {Promise.<void>}
将指定成员从当前活跃群组中踢出。
Parameters:
Name | Type | Description |
---|---|---|
memberId |
string | 要踢出的成员的用户 ID。 |
- Source:
Throws:
-
如果踢出成员失败,会打印错误信息。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) handleNewRequest(newRequestData) → {void}
处理新的实时群组邀请。
将新邀请添加到 `groupInvitations` 列表的开头,增加未读计数,并发送桌面通知。
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
newRequestData |
object | 新的群组邀请数据。
Properties
|
- Source:
Returns:
- Type
- void
(inner) handleRequestAction(groupId, action, invitationId) → {Promise.<void>}
处理群组邀请的接受或拒绝操作。
成功后从邀请列表中移除该邀请,更新未读计数。如果接受,则添加到群组列表。
Parameters:
Name | Type | Description |
---|---|---|
groupId |
string | 邀请所属的群组 ID。 |
action |
'accept' | 'decline' | 对邀请执行的操作('accept' 或 'decline')。 |
invitationId |
string | 邀请的 ID。 |
- Source:
Throws:
-
如果 API 调用失败,会打印错误信息并显示操作失败的提示。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) setActiveGroup(group) → {void}
设置当前活跃的群组,并更新相关状态。
Parameters:
Name | Type | Description |
---|---|---|
group |
object | 要设置为活跃状态的群组对象。 |
- Source:
Returns:
- Type
- void
(inner) setGroups() → {Promise.<void>}
从后端 API 获取当前用户的所有群组列表,并更新 `groups` 状态。
- Source:
Throws:
-
如果获取群组列表失败,会打印错误信息。
- Type
- Error
Returns:
- Type
- Promise.<void>
(inner) updateGroup(groupName, groupDescription) → {void}
更新本地活跃群组的名称和描述。
Parameters:
Name | Type | Description |
---|---|---|
groupName |
string | 群组的新名称。 |
groupDescription |
string | 群组的新描述。 |
- Source:
Returns:
- Type
- void
(inner) useGroupStore() → {Object}
Pinia Store,用于管理用户在应用程序中的群组相关状态和操作。
包含群组列表、活跃群组、群组邀请和成员管理等功能。
Properties:
Name | Type | Description |
---|---|---|
groups |
Ref.<Array.<object>> | 用户所属的群组列表。 |
activeGroup |
Ref.<(object|null)> | 当前活跃的群组对象。 |
activeGroupId |
Ref.<(string|null)> | 当前活跃群组的 ID。 |
isGroupActive |
Ref.<boolean> | 当前是否活跃在群组(而非私聊)会话中。 |
groupInvitations |
Ref.<Array.<object>> | 用户收到的群组邀请列表。 |
unreadGroupInvitation |
Ref.<(number|null)> | 未读群组邀请的数量。 |
groupMembers |
Ref.<Array.<object>> | 当前活跃群组的成员列表。 |
setGroups |
function | 从后端获取并设置用户群组列表。 |
setActiveGroup |
function | 设置当前活跃的群组。 |
getGroupInvitations |
function | 从后端获取并更新群组邀请列表。 |
handleRequestAction |
function | 处理群组邀请(接受或拒绝)。 |
handleNewRequest |
function | 处理新的实时群组邀请,并发送通知。 |
handleKickGroupMember |
function | 将指定成员从当前活跃群组中踢出。 |
fetchGroupMembers |
function | 获取当前活跃群组的成员列表。 |
clearActiveGroup |
function | 清除当前活跃群组的状态。 |
addNewGroup |
function | 向群组列表中添加一个新创建的群组。 |
updateGroup |
function | 更新本地活跃群组的名称和描述。 |
disbandGroup |
function | 解散当前活跃的群组。 |
- Source:
Returns:
- Type
- Object