优化
This commit is contained in:
19
client/shared/hooks/model/useUserInfo.ts
Normal file
19
client/shared/hooks/model/useUserInfo.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { getCachedUserInfo } from '../../cache/cache';
|
||||
import type { UserBaseInfo } from '../../model/user';
|
||||
import { useAsync } from '../useAsync';
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
export function useCachedUserInfo(
|
||||
userId: string,
|
||||
refetch = false
|
||||
): UserBaseInfo | Record<string, never> {
|
||||
const { value: userInfo = {} } = useAsync(async () => {
|
||||
const users = getCachedUserInfo(userId, refetch);
|
||||
|
||||
return users;
|
||||
}, [userId, refetch]);
|
||||
|
||||
return userInfo ?? {};
|
||||
}
|
||||
Reference in New Issue
Block a user