@arcblock/ux 2.13.7 → 2.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,7 +64,6 @@ export type UserAddress = {
64
64
  };
65
65
 
66
66
  export type User = UserPublicInfo & {
67
- role: string;
68
67
  email?: string;
69
68
  phone?: string;
70
69
  sourceProvider?: string;
@@ -76,7 +75,7 @@ export type User = UserPublicInfo & {
76
75
  didSpace?: Record<string, any>;
77
76
  connectedAccounts?: any[];
78
77
  locale?: string;
79
- url: string;
78
+ url?: string;
80
79
  inviter?: string;
81
80
  emailVerified?: boolean;
82
81
  phoneVerified?: boolean;
@@ -109,7 +108,8 @@ export enum InfoType {
109
108
 
110
109
  // 定义UserCard属性接口
111
110
  export interface UserCardProps {
112
- user: User;
111
+ user?: User;
112
+ did?: string;
113
113
  cardType?: CardType;
114
114
  infoType?: InfoType;
115
115
  avatarSize?: number;
@@ -121,7 +121,7 @@ export interface UserCardProps {
121
121
  popupAvatarProps?: Partial<AvatarProps>;
122
122
 
123
123
  // 弹出层相关属性
124
- tooltipProps?: Omit<TooltipProps, 'title'>;
124
+ tooltipProps?: Partial<TooltipProps>;
125
125
 
126
126
  // 样式相关属性
127
127
  sx?: SxProps<Theme>;
@@ -131,10 +131,17 @@ export interface UserCardProps {
131
131
  shortenLabelProps?: Partial<ShortenLabelProps>;
132
132
  popupShortenLabelProps?: Partial<ShortenLabelProps>;
133
133
 
134
+ // 自定义渲染字段
135
+ renderFields?: string[];
136
+ popupRenderFields?: string[];
137
+
134
138
  // 右上角内容相关属性
135
139
  renderTopRightContent?: () => React.ReactNode;
136
140
  topRightMaxWidth?: number;
137
141
 
138
142
  // 自定义内容渲染函数
139
143
  renderCustomContent?: () => React.ReactNode;
144
+
145
+ // 头像点击事件
146
+ onAvatarClick?: (user: User, e?: React.MouseEvent<HTMLDivElement>) => void;
140
147
  }
@@ -1,5 +1,16 @@
1
+ import { toTypeInfo } from '@arcblock/did';
2
+ import { types } from '@ocap/mcrypto';
3
+ import { BlockletSDK } from '@blocklet/js-sdk';
1
4
  import { User } from './types';
2
5
 
6
+ let client: BlockletSDK | null = null;
7
+ try {
8
+ client = new BlockletSDK();
9
+ } catch (error) {
10
+ console.error('Failed to initialize BlockletSDK:', error);
11
+ client = null;
12
+ }
13
+
3
14
  // 创建仅显示名称首字母的头像
4
15
  // eslint-disable-next-line import/prefer-default-export
5
16
  export function createNameOnlyAvatar(user: User) {
@@ -20,3 +31,25 @@ export function createNameOnlyAvatar(user: User) {
20
31
 
21
32
  return content;
22
33
  }
34
+
35
+ export function isUserDid(did: string) {
36
+ if (!did || typeof did !== 'string') return false;
37
+ try {
38
+ const didInfo = toTypeInfo(did);
39
+ return didInfo.role !== undefined && didInfo.role !== types.RoleType.ROLE_APPLICATION;
40
+ } catch (error) {
41
+ console.error('Failed to check if did is user did:', error);
42
+ return false;
43
+ }
44
+ }
45
+
46
+ export async function getUserByDid(did: string): Promise<User | null> {
47
+ if (!client) return null;
48
+ try {
49
+ const user = await client.user.getUserPublicInfo({ did });
50
+ return user as User;
51
+ } catch (error) {
52
+ console.error('Failed to get user by did:', error);
53
+ return null;
54
+ }
55
+ }