@lark-apaas/client-toolkit 1.1.26-alpha.3 → 1.1.27-dataloom-test.0
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.
- package/lib/components/AppContainer/safety.js +16 -16
- package/lib/components/User/UserDisplay.d.ts +3 -2
- package/lib/components/User/UserDisplay.js +22 -21
- package/lib/components/User/index.d.ts +1 -1
- package/lib/utils/requestManager.d.ts +2 -0
- package/lib/utils/requestManager.js +26 -0
- package/lib/utils/userProfileCache.d.ts +12 -0
- package/lib/utils/userProfileCache.js +26 -0
- package/package.json +2 -2
|
@@ -44,7 +44,7 @@ const Component = ()=>{
|
|
|
44
44
|
/*#__PURE__*/ jsx(SheetTrigger, {
|
|
45
45
|
asChild: true,
|
|
46
46
|
children: /*#__PURE__*/ jsxs("div", {
|
|
47
|
-
className: "fixed right-
|
|
47
|
+
className: "fixed right-[12px] bottom-[80px] inline-flex items-center gap-x-1 border-solid border-[#ffffff1a] border px-[10px] py-[6px] bg-[#1f2329e5] backdrop-blur-[5px] shadow-[0px_6px_12px_0px_#41444a0a,0px_8px_24px_8px_#41444a0a] rounded-md text-[#ebebeb)] font-['PingFang_SC'] text-xs leading-[20px] tracking-[0px] z-[10000000]",
|
|
48
48
|
onClick: ()=>{
|
|
49
49
|
setOpen(true);
|
|
50
50
|
},
|
|
@@ -64,10 +64,10 @@ const Component = ()=>{
|
|
|
64
64
|
side: "bottom",
|
|
65
65
|
className: "z-[10000001] border-none bg-transparent outline-0!",
|
|
66
66
|
children: /*#__PURE__*/ jsxs("div", {
|
|
67
|
-
className: "flex flex-col bg-white overflow-hidden rounded-t-
|
|
67
|
+
className: "flex flex-col bg-white overflow-hidden rounded-t-[16px] relative",
|
|
68
68
|
children: [
|
|
69
69
|
/*#__PURE__*/ jsx(X, {
|
|
70
|
-
className: "absolute top-
|
|
70
|
+
className: "absolute top-[8px] left-[16px] size-[24px] text-[#2B2F36]",
|
|
71
71
|
onClick: ()=>setOpen(false)
|
|
72
72
|
}),
|
|
73
73
|
/*#__PURE__*/ jsx("img", {
|
|
@@ -79,7 +79,7 @@ const Component = ()=>{
|
|
|
79
79
|
}
|
|
80
80
|
}),
|
|
81
81
|
/*#__PURE__*/ jsxs("div", {
|
|
82
|
-
className: "flex flex-col w-full justify-center items-end gap-y-
|
|
82
|
+
className: "flex flex-col w-full justify-center items-end gap-y-[16px] border-solid border-[#ffffff0d] border px-[20px] pt-[16px] pb-[48px] shadow-(--shadow-2xs,0px_2px_8px_2px_var(--shadow-2xs-1-color,#1f232905),0px_2px_8px_2px_var(--shadow-2xs-1-color,#1f232905),0px_2px_4px_0px_var(--shadow-2xs-1-color,#1f232905)) rounded-t-[12px] text-[#a6a6a6] font-['PingFang_SC'] text-[12px] leading-[20px] tracking-[0px]",
|
|
83
83
|
children: [
|
|
84
84
|
/*#__PURE__*/ jsxs("div", {
|
|
85
85
|
className: "self-stretch shrink-0 flex flex-col items-start gap-y-[4px]",
|
|
@@ -89,7 +89,7 @@ const Component = ()=>{
|
|
|
89
89
|
children: [
|
|
90
90
|
/*#__PURE__*/ jsx("img", {
|
|
91
91
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/icon_company_outlined.svg",
|
|
92
|
-
className: "shrink-0 w-
|
|
92
|
+
className: "shrink-0 w-[14px] h-[14px]"
|
|
93
93
|
}),
|
|
94
94
|
/*#__PURE__*/ jsxs("p", {
|
|
95
95
|
className: "shrink-0 min-w-[96px] m-0! text-[#646A73] text-sm",
|
|
@@ -105,7 +105,7 @@ const Component = ()=>{
|
|
|
105
105
|
children: [
|
|
106
106
|
/*#__PURE__*/ jsx("img", {
|
|
107
107
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/icon_efficiency-ai_outlined.svg",
|
|
108
|
-
className: "shrink-0 w-
|
|
108
|
+
className: "shrink-0 w-[14px] h-[14px]"
|
|
109
109
|
}),
|
|
110
110
|
/*#__PURE__*/ jsx("p", {
|
|
111
111
|
className: "shrink-0 min-w-[163px] m-0! text-[#646A73] text-sm",
|
|
@@ -116,10 +116,10 @@ const Component = ()=>{
|
|
|
116
116
|
]
|
|
117
117
|
}),
|
|
118
118
|
/*#__PURE__*/ jsxs("div", {
|
|
119
|
-
className: "self-stretch shrink-0 flex items-start gap-x-
|
|
119
|
+
className: "self-stretch shrink-0 flex items-start gap-x-[16px]",
|
|
120
120
|
children: [
|
|
121
121
|
/*#__PURE__*/ jsx("div", {
|
|
122
|
-
className: "flex-1 flex rounded-[99px] items-center justify-center border-[0.5px] border-[#D0D3D6] bg-white text-[#1F2329] cursor-pointer text-lg py-
|
|
122
|
+
className: "flex-1 flex rounded-[99px] items-center justify-center border-[0.5px] border-[#D0D3D6] bg-white text-[#1F2329] cursor-pointer text-lg py-[12px]",
|
|
123
123
|
onClick: (e)=>{
|
|
124
124
|
e.stopPropagation();
|
|
125
125
|
e.preventDefault();
|
|
@@ -130,7 +130,7 @@ const Component = ()=>{
|
|
|
130
130
|
children: "不再展示"
|
|
131
131
|
}),
|
|
132
132
|
/*#__PURE__*/ jsx("div", {
|
|
133
|
-
className: "flex-1 flex rounded-[99px] items-center justify-center border-[0.5px] border-black bg-black text-white cursor-pointer text-lg py-
|
|
133
|
+
className: "flex-1 flex rounded-[99px] items-center justify-center border-[0.5px] border-black bg-black text-white cursor-pointer text-lg py-[12px]",
|
|
134
134
|
onClick: ()=>{
|
|
135
135
|
window.open('https://miaoda.feishu.cn/landing', '_blank');
|
|
136
136
|
},
|
|
@@ -152,7 +152,7 @@ const Component = ()=>{
|
|
|
152
152
|
/*#__PURE__*/ jsx(PopoverTrigger, {
|
|
153
153
|
asChild: true,
|
|
154
154
|
children: /*#__PURE__*/ jsxs("div", {
|
|
155
|
-
className: "fixed right-
|
|
155
|
+
className: "fixed right-[12px] bottom-[12px] inline-flex items-center gap-x-1 border-solid border-[#ffffff1a] border px-[10px] py-[6px] bg-[#1f2329e5] backdrop-blur-[5px] shadow-[0px_6px_12px_0px_#41444a0a,0px_8px_24px_8px_#41444a0a] rounded-[6px] text-[#ebebeb)] font-['PingFang_SC'] text-xs leading-[20px] tracking-[0px] z-[10000000] cursor-pointer",
|
|
156
156
|
onMouseEnter: ()=>{
|
|
157
157
|
clearTimeout(timeoutRef.current);
|
|
158
158
|
setOpen(true);
|
|
@@ -173,7 +173,7 @@ const Component = ()=>{
|
|
|
173
173
|
})
|
|
174
174
|
}),
|
|
175
175
|
/*#__PURE__*/ jsx(PopoverContent, {
|
|
176
|
-
className: "overflow-hidden p-0 m-0 border-0 rounded-[12px]!",
|
|
176
|
+
className: "overflow-hidden p-0 m-0 border-0 rounded-[12px]! w-[286px]",
|
|
177
177
|
style: {
|
|
178
178
|
boxShadow: '0 6px 12px 0 #41444a0a, 0 8px 24px 0 #41444a0a'
|
|
179
179
|
},
|
|
@@ -188,18 +188,18 @@ const Component = ()=>{
|
|
|
188
188
|
timeoutRef.current = setTimeout(()=>setOpen(false), 100);
|
|
189
189
|
},
|
|
190
190
|
children: /*#__PURE__*/ jsxs("div", {
|
|
191
|
-
className: "flex flex-col bg-[#
|
|
191
|
+
className: "flex flex-col bg-[#1A1A1A]",
|
|
192
192
|
children: [
|
|
193
193
|
/*#__PURE__*/ jsx("img", {
|
|
194
194
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover.png",
|
|
195
195
|
alt: "",
|
|
196
|
-
className: "w-
|
|
196
|
+
className: "w-[286px] h-[128px] cursor-pointer",
|
|
197
197
|
onClick: ()=>{
|
|
198
198
|
window.open('https://miaoda.feishu.cn/landing', '_blank');
|
|
199
199
|
}
|
|
200
200
|
}),
|
|
201
201
|
/*#__PURE__*/ jsxs("div", {
|
|
202
|
-
className: "flex flex-col justify-center items-end gap-y-[12px] border-solid border-[#ffffff0d] border pl-[14px] pr-[15px] pt-[11px] pb-[15px] w-[286px] shadow-(--shadow-2xs,0px_2px_8px_2px_var(--shadow-2xs-1-color,#1f232905),0px_2px_8px_2px_var(--shadow-2xs-1-color,#1f232905),0px_2px_4px_0px_var(--shadow-2xs-1-color,#1f232905)) rounded-t-[12px] text-[#a6a6a6] font-['PingFang_SC'] text-[12px] leading-[20px] tracking-[0px]",
|
|
202
|
+
className: "flex flex-col justify-center items-end gap-y-[12px] border-solid border-[#ffffff0d] border pl-[14px] pr-[15px] pt-[11px] pb-[15px] w-[286px] shadow-(--shadow-2xs,0px_2px_8px_2px_var(--shadow-2xs-1-color,#1f232905),0px_2px_8px_2px_var(--shadow-2xs-1-color,#1f232905),0px_2px_4px_0px_var(--shadow-2xs-1-color,#1f232905)) rounded-t-[12px] text-[#a6a6a6] font-['PingFang_SC'] text-[12px] leading-[20px] tracking-[0px] bg-[#1f2021]",
|
|
203
203
|
children: [
|
|
204
204
|
/*#__PURE__*/ jsxs("div", {
|
|
205
205
|
className: "self-stretch shrink-0 flex flex-col items-start gap-y-[4px]",
|
|
@@ -236,10 +236,10 @@ const Component = ()=>{
|
|
|
236
236
|
]
|
|
237
237
|
}),
|
|
238
238
|
/*#__PURE__*/ jsxs("div", {
|
|
239
|
-
className: "self-stretch shrink-0 flex items-start gap-x-[8px]",
|
|
239
|
+
className: "w-full self-stretch shrink-0 flex items-start gap-x-[8px]",
|
|
240
240
|
children: [
|
|
241
241
|
/*#__PURE__*/ jsx("div", {
|
|
242
|
-
className: "flex-1 flex rounded-lg
|
|
242
|
+
className: "flex-1 flex rounded-lg items-center justify-center h-[34px] border-[0.5px] border-solid border-[#ffffff1c] hover:border-[#ffffff33] bg-[#ffffff08] hover:bg-[#ffffff14] cursor-pointer text-[#ebebeb]",
|
|
243
243
|
"data-custom-element": "safety-close",
|
|
244
244
|
onClick: (e)=>{
|
|
245
245
|
e.stopPropagation();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { IUserProfile } from '../../apis/udt-types';
|
|
3
|
-
export interface
|
|
3
|
+
export interface IUserDisplayProps {
|
|
4
4
|
/**
|
|
5
5
|
* 支持传入完整的用户资料(IUserProfile)/ 列表(IUserProfile[])
|
|
6
6
|
* 或仅传入用户 ID(string)/ 列表(string[])。
|
|
@@ -11,5 +11,6 @@ export interface UserDisplayProps {
|
|
|
11
11
|
className?: string;
|
|
12
12
|
style?: React.CSSProperties;
|
|
13
13
|
showLabel?: boolean;
|
|
14
|
+
showUserProfile?: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare const UserDisplay: React.FC<
|
|
16
|
+
export declare const UserDisplay: React.FC<IUserDisplayProps>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { getCachedUserProfiles, setCachedUserProfiles } from "../../utils/userProfileCache.js";
|
|
4
4
|
import { clsxWithTw } from "../../utils/utils.js";
|
|
5
5
|
import { UserProfile } from "./UserProfile/index.js";
|
|
6
6
|
import { UserWithAvatar } from "./UserWithAvatar.js";
|
|
7
7
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
|
|
8
|
+
import { fetchWithDeduplication } from "../../utils/requestManager.js";
|
|
8
9
|
const UserDisplay = ({ users, size, className, style, showLabel = true })=>{
|
|
9
10
|
const normalizedIds = useMemo(()=>{
|
|
10
11
|
if (!users) return [];
|
|
@@ -71,22 +72,20 @@ const UserDisplay = ({ users, size, className, style, showLabel = true })=>{
|
|
|
71
72
|
const fetchProfiles = async ()=>{
|
|
72
73
|
try {
|
|
73
74
|
setLoadingProfiles(true);
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const response = await dataloom.service.user.getByIds(ids);
|
|
89
|
-
const fetchedList = Array.isArray(response?.data) ? response?.data : Array.isArray(response?.data?.user_list) ? response?.data?.user_list : [];
|
|
75
|
+
const { cachedProfiles, remainingIds } = getCachedUserProfiles(normalizedIds);
|
|
76
|
+
if (cachedProfiles.length > 0) setResolvedUsers((prev)=>{
|
|
77
|
+
const updatedUsers = [
|
|
78
|
+
...prev
|
|
79
|
+
];
|
|
80
|
+
cachedProfiles.forEach((cached)=>{
|
|
81
|
+
const index = updatedUsers.findIndex((u)=>u.user_id === cached.user_id);
|
|
82
|
+
if (-1 !== index) updatedUsers[index] = cached;
|
|
83
|
+
});
|
|
84
|
+
return updatedUsers;
|
|
85
|
+
});
|
|
86
|
+
if (0 === remainingIds.length) return void setLoadingProfiles(false);
|
|
87
|
+
const fetchedList = await fetchWithDeduplication(remainingIds);
|
|
88
|
+
if (isCancelled || !fetchedList) return;
|
|
90
89
|
const fetchedMap = new Map();
|
|
91
90
|
fetchedList.forEach((profile)=>{
|
|
92
91
|
const id = String(profile?.user_id ?? '');
|
|
@@ -99,13 +98,15 @@ const UserDisplay = ({ users, size, className, style, showLabel = true })=>{
|
|
|
99
98
|
status: profile?.status ?? 1
|
|
100
99
|
});
|
|
101
100
|
});
|
|
101
|
+
setCachedUserProfiles(fetchedList);
|
|
102
102
|
const mergedUsers = normalizedIds.map((id)=>{
|
|
103
103
|
const fetched = fetchedMap.get(id);
|
|
104
104
|
const given = inputProfilesMap.get(id);
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
105
|
+
const cached = cachedProfiles.find((p)=>p.user_id === id);
|
|
106
|
+
const name = given?.name?.trim() || fetched?.name || cached?.name || '';
|
|
107
|
+
const avatar = given?.avatar || fetched?.avatar || cached?.avatar || '';
|
|
108
|
+
const email = given?.email || fetched?.email || cached?.email || '';
|
|
109
|
+
const status = given?.status ?? fetched?.status ?? cached?.status ?? 1;
|
|
109
110
|
return {
|
|
110
111
|
user_id: id,
|
|
111
112
|
name,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { UserSelect } from './UserSelect';
|
|
2
2
|
export type { UserSelectProps } from './UserSelect';
|
|
3
3
|
export { UserDisplay } from './UserDisplay';
|
|
4
|
-
export type { UserDisplayProps } from './UserDisplay';
|
|
4
|
+
export type { IUserDisplayProps as UserDisplayProps } from './UserDisplay';
|
|
5
5
|
export { UserWithAvatar } from './UserWithAvatar';
|
|
6
6
|
export type { UserWithAvatarProps } from './type';
|
|
7
7
|
export { UserProfile } from './UserProfile';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getDataloom } from "../integrations/dataloom.js";
|
|
2
|
+
const pendingRequests = new Map();
|
|
3
|
+
async function fetchUserProfilesByIds(ids) {
|
|
4
|
+
try {
|
|
5
|
+
const dataloom = await getDataloom();
|
|
6
|
+
if (!dataloom) throw new Error('Dataloom client is unavailable');
|
|
7
|
+
const numericIds = ids.map(Number).filter(Number.isFinite);
|
|
8
|
+
if (0 === numericIds.length) return [];
|
|
9
|
+
const response = await dataloom.service.user.getByIds(numericIds);
|
|
10
|
+
return Array.isArray(response?.data) ? response.data : response?.data?.user_list || [];
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.error(`Failed to fetch profiles for user IDs ${ids.join(', ')}:`, error);
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function fetchWithDeduplication(ids) {
|
|
17
|
+
const key = ids.sort().join(',');
|
|
18
|
+
if (pendingRequests.has(key)) return pendingRequests.get(key);
|
|
19
|
+
const fetchPromise = fetchUserProfilesByIds(ids);
|
|
20
|
+
pendingRequests.set(key, fetchPromise);
|
|
21
|
+
fetchPromise.finally(()=>{
|
|
22
|
+
pendingRequests.delete(key);
|
|
23
|
+
});
|
|
24
|
+
return fetchPromise;
|
|
25
|
+
}
|
|
26
|
+
export { fetchWithDeduplication };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IUserProfile } from '../apis/udt-types';
|
|
2
|
+
export interface ICachedUserProfile {
|
|
3
|
+
profile: IUserProfile;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const cache: Map<string, ICachedUserProfile>;
|
|
7
|
+
export declare const cacheExpiry: number;
|
|
8
|
+
export declare function setCachedUserProfiles(profiles: IUserProfile[]): void;
|
|
9
|
+
export declare function getCachedUserProfiles(ids: string[]): {
|
|
10
|
+
cachedProfiles: IUserProfile[];
|
|
11
|
+
remainingIds: string[];
|
|
12
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const cache = new Map();
|
|
2
|
+
const cacheExpiry = 1 / 0;
|
|
3
|
+
function setCachedUserProfiles(profiles) {
|
|
4
|
+
const now = Date.now();
|
|
5
|
+
profiles.forEach((profile)=>{
|
|
6
|
+
if (profile && profile.user_id) cache.set(String(profile.user_id), {
|
|
7
|
+
profile,
|
|
8
|
+
timestamp: now
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function getCachedUserProfiles(ids) {
|
|
13
|
+
const cachedProfiles = [];
|
|
14
|
+
const remainingIds = [];
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
ids.forEach((id)=>{
|
|
17
|
+
const cachedItem = cache.get(id);
|
|
18
|
+
if (cachedItem && now - cachedItem.timestamp < cacheExpiry) cachedProfiles.push(cachedItem.profile);
|
|
19
|
+
else remainingIds.push(id);
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
cachedProfiles,
|
|
23
|
+
remainingIds
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { cache, cacheExpiry, getCachedUserProfiles, setCachedUserProfiles };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.27-dataloom-test.0",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@ant-design/colors": "^7.2.1",
|
|
82
82
|
"@ant-design/cssinjs": "^1.24.0",
|
|
83
|
-
"@data-loom/js": "
|
|
83
|
+
"@data-loom/js": "0.4.3-alpha.1",
|
|
84
84
|
"@lark-apaas/miaoda-inspector": "^1.0.5",
|
|
85
85
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
86
86
|
"@radix-ui/react-popover": "^1.1.15",
|