@blueking/bk-user-display-name
Version:
多租户环境用于显示用户名称的组件
39 lines (38 loc) • 1.1 kB
TypeScript
interface ConfigOptions {
tenantId: string;
apiBaseUrl: string;
cacheDuration?: number;
emptyText?: string;
}
interface User {
display_name: string;
bk_username: string;
}
interface UserResponse {
data?: User;
[key: string]: any;
}
interface UsersResponse {
data: User[];
}
interface UserCacheItem {
data: UserResponse;
timestamp: number;
}
declare class BkUserDisplayName extends HTMLElement {
static userCache: Map<string, UserCacheItem>;
static cacheDuration: number;
static pendingRequests: Map<string, Promise<UserResponse>>;
static apiBaseUrl: string;
static tenantId: string;
static emptyText: string;
static observedAttributes: string[];
static configure(config: ConfigOptions): void;
constructor();
fetchUser(id: string): Promise<UserResponse>;
fetchUsers(ids: string[]): Promise<UsersResponse>;
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
updateDisplay(): Promise<void>;
getDisplayName(): Promise<string>;
}
export default BkUserDisplayName;