feat: 增加群组用户列表获取功能
This commit is contained in:
29
packages/client/src/api/user.ts
Normal file
29
packages/client/src/api/user.ts
Normal 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()),
|
||||
});
|
||||
};
|
||||
@@ -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());
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user