feat: 增加群组用户列表获取功能

This commit is contained in:
dayjoy
2025-09-11 16:46:54 +08:00
parent c782dea322
commit 0d4a938c00
4 changed files with 103 additions and 26 deletions

View File

@@ -0,0 +1,29 @@
import api from "@/api/index.ts";
import {getGroupId} from "@/utils/auth.ts";
export type UserInfo = {
userId: number;
nickname: string;
avatarUrl: string;
gender: 'MALE' | 'FEMALE' | 'UNKNOWN';
nimToken: string; // NetEase Cloud Communication token
nimAccountId: string; // NetEase Cloud Communication account ID
createdAt: string;
updatedAt: string;
}
/**
* 获取当前用户的信息
*/
export const getUserInfo = async (): Promise<UserInfo> => {
return await api.post<UserInfo>('https://egret.byteawake.com/api/user/info');
};
/**
* 获取群组内所有用户的信息
*/
export const getGroupUsers = async (): Promise<UserInfo[]> => {
return await api.post<UserInfo[]>('https://egret.byteawake.com/api/group/members', {
groupId: Number(getGroupId()),
});
};

View File

@@ -70,11 +70,5 @@ export const handleAuthTokenAndGroupIdFromUrl = (): void => {
if (tokenFromUrl && groupIdFromUrl) {
saveAuthToken(tokenFromUrl);
saveGroupId(groupIdFromUrl);
// 从URL中移除authToken参数
const url = new URL(window.location.href);
url.searchParams.delete('authToken');
url.searchParams.delete('groupId');
window.history.replaceState({}, '', url.toString());
}
};