@lark-apaas/client-toolkit 1.2.24-alpha.7 → 1.2.24-alpha.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.
- package/lib/components/AppContainer/safety.js +6 -22
- package/lib/integrations/services/index.d.ts +0 -1
- package/lib/integrations/services/index.js +0 -1
- package/lib/integrations/services/types.d.ts +0 -34
- package/package.json +4 -4
- package/lib/integrations/services/ChatService.d.ts +0 -12
- package/lib/integrations/services/ChatService.js +0 -67
|
@@ -14,31 +14,17 @@ const Component = ()=>{
|
|
|
14
14
|
const isMobile = useIsMobile();
|
|
15
15
|
const [userinfo, setUserinfo] = useState(null);
|
|
16
16
|
const [isInternetVisible, setIsInternetVisible] = useState(false);
|
|
17
|
-
const [showBadge, setShowBadge] = useState(true);
|
|
18
|
-
const [badgeLoaded, setBadgeLoaded] = useState(false);
|
|
19
17
|
const timeoutRef = useRef(null);
|
|
20
18
|
useEffect(()=>{
|
|
21
19
|
const appId = getAppId();
|
|
22
|
-
const csrfHeaders = {
|
|
23
|
-
'X-Suda-Csrf-Token': getCsrfToken()
|
|
24
|
-
};
|
|
25
20
|
const tenantInfoUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/tenant_info` : `/spark/b/${appId}/tenant_info`;
|
|
26
21
|
fetch(tenantInfoUrl, {
|
|
27
|
-
headers:
|
|
22
|
+
headers: {
|
|
23
|
+
'X-Suda-Csrf-Token': getCsrfToken()
|
|
24
|
+
}
|
|
28
25
|
}).then((res)=>res.json()).then((data)=>{
|
|
29
26
|
setUserinfo(data?.data?.tenant_info);
|
|
30
27
|
setIsInternetVisible(data?.data?.is_internet_visible);
|
|
31
|
-
}).catch(()=>{});
|
|
32
|
-
const getPublishedUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/get_published` : `/spark/b/${appId}/get_published`;
|
|
33
|
-
fetch(getPublishedUrl, {
|
|
34
|
-
headers: csrfHeaders
|
|
35
|
-
}).then((res)=>res.json()).then((data)=>{
|
|
36
|
-
const badge = data?.data?.app_info?.show_badge;
|
|
37
|
-
setShowBadge(false !== badge);
|
|
38
|
-
}).catch(()=>{
|
|
39
|
-
setShowBadge(true);
|
|
40
|
-
}).finally(()=>{
|
|
41
|
-
setBadgeLoaded(true);
|
|
42
28
|
});
|
|
43
29
|
}, []);
|
|
44
30
|
useEffect(()=>{
|
|
@@ -53,8 +39,6 @@ const Component = ()=>{
|
|
|
53
39
|
isMobile
|
|
54
40
|
]);
|
|
55
41
|
if ('production' !== process.env.NODE_ENV) return null;
|
|
56
|
-
if (!badgeLoaded) return null;
|
|
57
|
-
if (!showBadge) return null;
|
|
58
42
|
if (!visible) return null;
|
|
59
43
|
if (isMobile) return /*#__PURE__*/ jsxs(Sheet, {
|
|
60
44
|
open: open,
|
|
@@ -63,7 +47,7 @@ const Component = ()=>{
|
|
|
63
47
|
/*#__PURE__*/ jsx(SheetTrigger, {
|
|
64
48
|
asChild: true,
|
|
65
49
|
children: /*#__PURE__*/ jsxs("div", {
|
|
66
|
-
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-
|
|
50
|
+
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]",
|
|
67
51
|
onClick: ()=>{
|
|
68
52
|
setOpen(true);
|
|
69
53
|
},
|
|
@@ -258,7 +242,7 @@ const Component = ()=>{
|
|
|
258
242
|
className: "w-full self-stretch shrink-0 flex items-start gap-x-[8px]",
|
|
259
243
|
children: [
|
|
260
244
|
/*#__PURE__*/ jsx("div", {
|
|
261
|
-
className: "flex-1 flex rounded-
|
|
245
|
+
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]",
|
|
262
246
|
"data-custom-element": "safety-close",
|
|
263
247
|
onClick: (e)=>{
|
|
264
248
|
e.stopPropagation();
|
|
@@ -269,7 +253,7 @@ const Component = ()=>{
|
|
|
269
253
|
children: "不再展示"
|
|
270
254
|
}),
|
|
271
255
|
/*#__PURE__*/ jsx("div", {
|
|
272
|
-
className: "flex-1 flex rounded-
|
|
256
|
+
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]",
|
|
273
257
|
"data-custom-element": "safety-more",
|
|
274
258
|
onClick: ()=>{
|
|
275
259
|
window.open('https://miaoda.feishu.cn/landing', '_blank');
|
|
@@ -62,40 +62,6 @@ export type SearchDepartmentsResponse = {
|
|
|
62
62
|
};
|
|
63
63
|
status_code: string;
|
|
64
64
|
};
|
|
65
|
-
export type ChatInfo = {
|
|
66
|
-
/** 群组 ID */
|
|
67
|
-
chatID: string;
|
|
68
|
-
/** 群组名称(国际化文本) */
|
|
69
|
-
name: I18nText;
|
|
70
|
-
/** 头像:URL 或 16 进制 RGB 颜色 */
|
|
71
|
-
avatar: string;
|
|
72
|
-
/** 是否是外部群 */
|
|
73
|
-
isExternal?: boolean;
|
|
74
|
-
/** 群成员数量(不包括机器人),搜索接口返回,批量查询接口不返回 */
|
|
75
|
-
userCount?: number;
|
|
76
|
-
};
|
|
77
|
-
export type SearchChatsParams = {
|
|
78
|
-
query?: string;
|
|
79
|
-
offset?: number;
|
|
80
|
-
pageSize?: number;
|
|
81
|
-
};
|
|
82
|
-
export type SearchChatsResponse = {
|
|
83
|
-
data: {
|
|
84
|
-
result: {
|
|
85
|
-
chatResult?: {
|
|
86
|
-
total: number;
|
|
87
|
-
items: ChatInfo[];
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
status_code: string;
|
|
92
|
-
};
|
|
93
|
-
export type BatchGetChatsResponse = {
|
|
94
|
-
data: {
|
|
95
|
-
chatInfoMap: Record<string, ChatInfo>;
|
|
96
|
-
};
|
|
97
|
-
status_code: string;
|
|
98
|
-
};
|
|
99
65
|
export type UserProfileAccountStatus = 0 | 1 | 2 | 3 | 4;
|
|
100
66
|
export type SimpleUserProfileInfo = {
|
|
101
67
|
name?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.2.24-alpha.
|
|
3
|
+
"version": "1.2.24-alpha.8",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -98,13 +98,13 @@
|
|
|
98
98
|
"dependencies": {
|
|
99
99
|
"@ant-design/colors": "^7.2.1",
|
|
100
100
|
"@ant-design/cssinjs": "^1.24.0",
|
|
101
|
-
"@data-loom/js": "0.4.
|
|
101
|
+
"@data-loom/js": "0.4.9",
|
|
102
102
|
"@lark-apaas/aily-web-sdk": "^0.0.7",
|
|
103
103
|
"@lark-apaas/auth-sdk": "^0.1.2",
|
|
104
104
|
"@lark-apaas/client-capability": "^0.1.6",
|
|
105
105
|
"@lark-apaas/internal-slardar": "^0.0.3",
|
|
106
|
-
"@lark-apaas/miaoda-inspector": "
|
|
107
|
-
"@lark-apaas/observable-web": "^1.0.
|
|
106
|
+
"@lark-apaas/miaoda-inspector": "1.0.14-alpha.23",
|
|
107
|
+
"@lark-apaas/observable-web": "^1.0.4",
|
|
108
108
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
109
109
|
"@radix-ui/react-popover": "^1.1.15",
|
|
110
110
|
"@radix-ui/react-slot": "^1.2.3",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { BatchGetChatsResponse, SearchChatsParams, SearchChatsResponse } from './types';
|
|
2
|
-
export type ChatServiceConfig = {
|
|
3
|
-
getAppId?: () => string | null | undefined;
|
|
4
|
-
searchChatsUrl?: (appId: string) => string;
|
|
5
|
-
listChatsUrl?: (appId: string) => string;
|
|
6
|
-
};
|
|
7
|
-
export declare class ChatService {
|
|
8
|
-
private config;
|
|
9
|
-
constructor(config?: ChatServiceConfig);
|
|
10
|
-
searchChats(params: SearchChatsParams): Promise<SearchChatsResponse>;
|
|
11
|
-
listChatsByIds(chatIds: string[]): Promise<BatchGetChatsResponse>;
|
|
12
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { getAppId } from "../../utils/getAppId.js";
|
|
2
|
-
const DEFAULT_CONFIG = {
|
|
3
|
-
getAppId: ()=>getAppId(),
|
|
4
|
-
searchChatsUrl: (appId)=>`/app/${appId}/__runtime__/api/v1/account/search`,
|
|
5
|
-
listChatsUrl: (appId)=>`/app/${appId}/__runtime__/api/v1/account/chat/list_chats`
|
|
6
|
-
};
|
|
7
|
-
class ChatService {
|
|
8
|
-
config;
|
|
9
|
-
constructor(config = {}){
|
|
10
|
-
this.config = {
|
|
11
|
-
...DEFAULT_CONFIG,
|
|
12
|
-
...config
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
async searchChats(params) {
|
|
16
|
-
const appId = this.config.getAppId();
|
|
17
|
-
if (!appId) throw new Error('Failed to get appId');
|
|
18
|
-
const response = await fetch(this.config.searchChatsUrl(appId), {
|
|
19
|
-
method: 'POST',
|
|
20
|
-
headers: {
|
|
21
|
-
'Content-Type': 'application/json'
|
|
22
|
-
},
|
|
23
|
-
body: JSON.stringify({
|
|
24
|
-
query: params.query,
|
|
25
|
-
filters: {
|
|
26
|
-
userParam: {
|
|
27
|
-
commonParam: {
|
|
28
|
-
searchable: false
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
departmentParam: {
|
|
32
|
-
commonParam: {
|
|
33
|
-
searchable: false
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
chatParam: {
|
|
37
|
-
commonParam: {
|
|
38
|
-
searchable: true,
|
|
39
|
-
pageSize: params.pageSize ?? 100,
|
|
40
|
-
offset: params.offset ?? 0
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}),
|
|
45
|
-
credentials: 'include'
|
|
46
|
-
});
|
|
47
|
-
if (!response.ok) throw new Error('Failed to search chats');
|
|
48
|
-
return response.json();
|
|
49
|
-
}
|
|
50
|
-
async listChatsByIds(chatIds) {
|
|
51
|
-
const appId = this.config.getAppId();
|
|
52
|
-
if (!appId) throw new Error('Failed to get appId');
|
|
53
|
-
const response = await fetch(this.config.listChatsUrl(appId), {
|
|
54
|
-
method: 'POST',
|
|
55
|
-
headers: {
|
|
56
|
-
'Content-Type': 'application/json'
|
|
57
|
-
},
|
|
58
|
-
body: JSON.stringify({
|
|
59
|
-
chatIDList: chatIds
|
|
60
|
-
}),
|
|
61
|
-
credentials: 'include'
|
|
62
|
-
});
|
|
63
|
-
if (!response.ok) throw new Error('Failed to fetch chats by ids');
|
|
64
|
-
return response.json();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
export { ChatService };
|