import { request } from '../api/request' ; export enum GroupPanelType { TEXT = 0 , GROUP = 1 , PLUGIN = 2 } export interface GroupMember { role : string ; userId : string ; } export interface GroupPanel { id : string ; name : string ; parentId ? : string ; type : GroupPanelType ; provider ? : string ; pluginPanelName ? : string ; meta ? : Record < string , unknown > ; } export interface GroupInfo { _id : string ; name : string ; avatar ? : string ; owner : string ; members : GroupMember [ ] ; panels : GroupPanel [ ] ; } /**
 * 访客级别获取群组信息
 */ export interface GroupBasicInfo { name : string ; avatar ? : string ; owner : string ; memberCount : GroupMember [ ] ; } export interface GroupInvite { code : string ; groupId : string ; creator : string ; expiredAt ? : string ; } param name param panels export async function createGroup ( name , panels ) { const { data } = await request . post ( '/api/group/createGroup' , { name , panels } ) ; return data ; } /**
 * 获取群组基本信息
 */ export async function getGroupBasicInfo ( groupId ) { const { data } = await request . get ( '/api/group/getGroupBasicInfo' , { params : { groupId } } ) ; return data ; } param groupId param fieldName param fieldValue type AllowedModifyField = 'name' | 'avatar' | 'panels' | 'roles' ; export async function modifyGroupField ( groupId , fieldName , fieldValue ) { await request . post ( '/api/group/updateGroupField' , { groupId , fieldName , fieldValue } ) ; } param groupId export async function quitGroup ( groupId ) { await request . post ( '/api/group/quitGroup' , { groupId } ) ; } param groupId export async function createGroupInviteCode ( groupId ) { const { data } = await request . post ( '/api/group/invite/createGroupInvite' , { groupId } ) ; return data ; } param inviteCode export async function findGroupInviteByCode ( inviteCode ) { const { data } = await request . get ( '/api/group/invite/findInviteByCode' , { params : { code : inviteCode } } ) ; return data ; } /**
 * 使用群组邀请
 * 即通过群组邀请加入群组
 */ export async function applyGroupInvite ( inviteCode ) { await request . post ( '/api/group/invite/applyInvite' , { code : inviteCode } ) ; } /**
 * 创建群组面板
 */ export async function createGroupPanel ( groupId , options ) { await request . post ( '/api/group/createGroupPanel' , { ... options , groupId } ) ; } /**
 * 创建群组面板
 */ export async function modifyGroupPanel ( groupId , panelId , options ) { await request . post ( '/api/group/modifyGroupPanel' , { ... options , groupId , panelId } ) ; } param groupId param panelId export async function deleteGroupPanel ( groupId , panelId ) { await request . post ( '/api/group/deleteGroupPanel' , { groupId , panelId } ) ; }