@lark-apaas/client-toolkit 1.1.21-alpha.auth.dev.1 → 1.1.21-alpha.auth.dev.11
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/README.md +68 -0
- package/lib/antd-table.d.ts +4 -0
- package/lib/antd-table.js +2 -0
- package/lib/apis/utils/getAxiosForBackend.d.ts +1 -0
- package/lib/apis/utils/getAxiosForBackend.js +1 -0
- package/lib/auth.d.ts +1 -0
- package/lib/auth.js +2 -0
- package/lib/components/AppContainer/index.js +179 -8
- package/lib/components/AppContainer/safety.js +16 -16
- package/lib/components/AppContainer/utils/getLarkUser.d.ts +1 -0
- package/lib/components/AppContainer/utils/getLarkUser.js +17 -0
- package/lib/components/AppContainer/utils/tea.d.ts +8 -0
- package/lib/components/AppContainer/utils/tea.js +51 -0
- package/lib/components/ErrorRender/index.js +17 -10
- package/lib/components/User/UserDisplay.d.ts +3 -2
- package/lib/components/User/UserDisplay.js +24 -23
- package/lib/components/User/index.d.ts +1 -1
- package/lib/components/ui/badge.d.ts +1 -1
- package/lib/components/ui/button.d.ts +1 -1
- package/lib/logger/selected-logs.js +11 -3
- package/lib/server-log/index.d.ts +9 -0
- package/lib/server-log/index.js +2 -0
- package/lib/server-log/poller.d.ts +87 -0
- package/lib/server-log/poller.js +135 -0
- package/lib/server-log/types.d.ts +166 -0
- package/lib/server-log/types.js +0 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/tea.d.ts +7 -0
- package/lib/types/tea.js +5 -0
- package/lib/utils/axiosConfig.js +118 -48
- package/lib/utils/deviceType.d.ts +3 -0
- package/lib/utils/deviceType.js +13 -0
- package/lib/utils/getAxiosForBackend.d.ts +11 -0
- package/lib/utils/getAxiosForBackend.js +21 -0
- package/lib/utils/getParentOrigin.d.ts +2 -1
- package/lib/utils/getParentOrigin.js +8 -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 +22 -6
package/README.md
CHANGED
|
@@ -6,3 +6,71 @@
|
|
|
6
6
|
|
|
7
7
|
* 导出所有对外暴露的 API 和组件,并通过 npm exports 来控制
|
|
8
8
|
* 其他目录作为 internal 实现,不对外暴露
|
|
9
|
+
|
|
10
|
+
### auth 目录
|
|
11
|
+
|
|
12
|
+
* 包含与权限相关的 API 和组件
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### 开发组件 - 使用 CanRole 组件 (推荐)
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { CanRole } from '@lark-apaas/client-toolkit/auth';
|
|
19
|
+
|
|
20
|
+
function Home() {
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<CanRole roles={['role_admin']}>
|
|
24
|
+
<div>管理员按钮</div>
|
|
25
|
+
</CanRole>
|
|
26
|
+
<CanRole roles={['role_admin', 'role_editor']}>
|
|
27
|
+
<div>编辑按钮</div>
|
|
28
|
+
</CanRole>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 开发组件 - 使用 AbilityContext 处理复杂场景
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useContext } from 'react';
|
|
38
|
+
import { AbilityContext, ROLE_SUBJECT } from '@lark-apaas/client-toolkit/auth';
|
|
39
|
+
|
|
40
|
+
function Home() {
|
|
41
|
+
const ability = useContext(AbilityContext);
|
|
42
|
+
return (
|
|
43
|
+
<div>
|
|
44
|
+
{ability.can('role_admin', ROLE_SUBJECT) || ability.can('role_editor', ROLE_SUBJECT) ? (
|
|
45
|
+
<div>可见的仪表盘</div>
|
|
46
|
+
) : null}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 开发组件 - 进阶示例
|
|
53
|
+
|
|
54
|
+
### 菜单按权限过滤
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { useContext } from 'react';
|
|
58
|
+
import { AbilityContext, ROLE_SUBJECT } from '@lark-apaas/client-toolkit/auth';
|
|
59
|
+
|
|
60
|
+
const menus = [
|
|
61
|
+
{ name: 'Dashboard', path: '/dashboard', p: { action: 'role_admin', subject: ROLE_SUBJECT } },
|
|
62
|
+
{ name: 'Users', path: '/users', p: { action: 'role_editor', subject: ROLE_SUBJECT } },
|
|
63
|
+
{ name: 'Settings', path: '/settings', p: { action: 'role_admin', subject: ROLE_SUBJECT } },
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
function Nav() {
|
|
67
|
+
const ability = useContext(AbilityContext);
|
|
68
|
+
return (
|
|
69
|
+
<nav>
|
|
70
|
+
{menus.map(m => ability.can(m.p.action, m.p.subject) && (
|
|
71
|
+
<a key={m.path} href={m.path}>{m.name}</a>
|
|
72
|
+
))}
|
|
73
|
+
</nav>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../utils/getAxiosForBackend';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../utils/getAxiosForBackend.js";
|
package/lib/auth.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CanRole, AbilityContext, ROLE_SUBJECT } from '@lark-apaas/auth-sdk';
|
package/lib/auth.js
ADDED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from "react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { ConfigProvider } from "antd";
|
|
3
4
|
import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
|
|
4
5
|
import IframeBridge from "./IframeBridge.js";
|
|
5
6
|
import { defaultUIConfig } from "../theme/ui-config.js";
|
|
@@ -9,15 +10,29 @@ import { findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, them
|
|
|
9
10
|
import { registerDayjsPlugins } from "./dayjsPlugins.js";
|
|
10
11
|
import "../../index.css";
|
|
11
12
|
import { initAxiosConfig } from "../../utils/axiosConfig.js";
|
|
13
|
+
import { reportTeaEvent } from "./utils/tea.js";
|
|
12
14
|
import { useAppInfo } from "../../hooks/index.js";
|
|
15
|
+
import { TrackKey } from "../../types/tea.js";
|
|
13
16
|
import safety from "./safety.js";
|
|
17
|
+
import { getAppId } from "../../utils/getAppId.js";
|
|
18
|
+
import { ServerLogPoller } from "../../server-log/index.js";
|
|
14
19
|
import { AuthProvider } from "@lark-apaas/auth-sdk";
|
|
15
20
|
registerDayjsPlugins();
|
|
16
21
|
initAxiosConfig();
|
|
17
22
|
const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
|
|
23
|
+
const readCssVarColor = (varName, fallback)=>{
|
|
24
|
+
try {
|
|
25
|
+
if ('undefined' == typeof document) return fallback;
|
|
26
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
27
|
+
return value || fallback;
|
|
28
|
+
} catch {
|
|
29
|
+
return fallback;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
18
32
|
const App = (props)=>{
|
|
19
33
|
const { themeMeta = {}, enableAuth } = props;
|
|
20
34
|
useAppInfo();
|
|
35
|
+
const serverLogPollerRef = useRef(null);
|
|
21
36
|
const { rem } = findValueByPixel(themeMetaOptions.themeRadius, themeMeta.borderRadius) || {
|
|
22
37
|
rem: '0.625'
|
|
23
38
|
};
|
|
@@ -29,6 +44,30 @@ const App = (props)=>{
|
|
|
29
44
|
borderRadius: radiusToken
|
|
30
45
|
}
|
|
31
46
|
};
|
|
47
|
+
useEffect(()=>{
|
|
48
|
+
if ('production' !== process.env.NODE_ENV && window.parent !== window) {
|
|
49
|
+
try {
|
|
50
|
+
const backendUrl = window.location.origin;
|
|
51
|
+
serverLogPollerRef.current = new ServerLogPoller({
|
|
52
|
+
serverUrl: backendUrl,
|
|
53
|
+
apiPath: '/dev/logs/server-logs',
|
|
54
|
+
pollInterval: 2000,
|
|
55
|
+
limit: 100,
|
|
56
|
+
debug: true
|
|
57
|
+
});
|
|
58
|
+
serverLogPollerRef.current.start();
|
|
59
|
+
console.log('[AppContainer] Server log poller started');
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error('[AppContainer] Failed to start server log poller:', error);
|
|
62
|
+
}
|
|
63
|
+
return ()=>{
|
|
64
|
+
if (serverLogPollerRef.current) {
|
|
65
|
+
serverLogPollerRef.current.stop();
|
|
66
|
+
console.log('[AppContainer] Server log poller stopped');
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
32
71
|
useEffect(()=>{
|
|
33
72
|
if (isMiaodaPreview) fetch(`${location.origin}/ai/api/feida_preview/csrf`).then(()=>{
|
|
34
73
|
setTimeout(()=>{
|
|
@@ -37,6 +76,16 @@ const App = (props)=>{
|
|
|
37
76
|
}, 300);
|
|
38
77
|
});
|
|
39
78
|
}, []);
|
|
79
|
+
useEffect(()=>{
|
|
80
|
+
if ('production' === process.env.NODE_ENV) reportTeaEvent({
|
|
81
|
+
trackKey: TrackKey.VIEW,
|
|
82
|
+
trackParams: {
|
|
83
|
+
artifact_uid: getAppId(window.location.pathname),
|
|
84
|
+
agent_id: 'agent_miaoda',
|
|
85
|
+
url: window.location.href
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}, []);
|
|
40
89
|
return /*#__PURE__*/ jsxs(AuthProvider, {
|
|
41
90
|
config: {
|
|
42
91
|
enable: enableAuth
|
|
@@ -58,18 +107,140 @@ const App = (props)=>{
|
|
|
58
107
|
]
|
|
59
108
|
});
|
|
60
109
|
};
|
|
61
|
-
const
|
|
110
|
+
const AppContainer_AppContainer = (props)=>{
|
|
62
111
|
const { children, ...rest } = props;
|
|
112
|
+
const [cssColors, setCssColors] = useState(()=>({
|
|
113
|
+
background: readCssVarColor('--background'),
|
|
114
|
+
destructive: readCssVarColor('--destructive'),
|
|
115
|
+
primary: readCssVarColor('--primary'),
|
|
116
|
+
foreground: readCssVarColor('--foreground'),
|
|
117
|
+
warning: readCssVarColor('--warning'),
|
|
118
|
+
success: readCssVarColor('--success'),
|
|
119
|
+
muted: readCssVarColor('--muted'),
|
|
120
|
+
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
121
|
+
border: readCssVarColor('--border'),
|
|
122
|
+
popover: readCssVarColor('--popover'),
|
|
123
|
+
accent: readCssVarColor('--accent')
|
|
124
|
+
}));
|
|
125
|
+
useEffect(()=>{
|
|
126
|
+
if ('production' === process.env.NODE_ENV) return ()=>{};
|
|
127
|
+
const observer = new MutationObserver((mutations)=>{
|
|
128
|
+
for (const mutation of mutations){
|
|
129
|
+
let linkTag = null;
|
|
130
|
+
if ('attributes' === mutation.type) {
|
|
131
|
+
if ('fullstack-nestjs-template:chunk-main' === mutation.target.dataset.webpack) linkTag = mutation.target;
|
|
132
|
+
} else if ('childList' === mutation.type) {
|
|
133
|
+
for (const node of Array.from(mutation.addedNodes))if ('LINK' === node.nodeName && 'fullstack-nestjs-template:chunk-main' === node.dataset.webpack) {
|
|
134
|
+
linkTag = node;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (linkTag) {
|
|
139
|
+
let retryCount = 0;
|
|
140
|
+
const maxRetries = 10;
|
|
141
|
+
const retryDelay = 400;
|
|
142
|
+
const updateColors = ()=>{
|
|
143
|
+
const newColors = {
|
|
144
|
+
background: readCssVarColor('--background'),
|
|
145
|
+
destructive: readCssVarColor('--destructive'),
|
|
146
|
+
primary: readCssVarColor('--primary'),
|
|
147
|
+
foreground: readCssVarColor('--foreground'),
|
|
148
|
+
warning: readCssVarColor('--warning'),
|
|
149
|
+
success: readCssVarColor('--success'),
|
|
150
|
+
muted: readCssVarColor('--muted'),
|
|
151
|
+
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
152
|
+
border: readCssVarColor('--border'),
|
|
153
|
+
popover: readCssVarColor('--popover'),
|
|
154
|
+
accent: readCssVarColor('--accent')
|
|
155
|
+
};
|
|
156
|
+
setCssColors((currentColors)=>{
|
|
157
|
+
if (JSON.stringify(currentColors) !== JSON.stringify(newColors)) {
|
|
158
|
+
retryCount = 0;
|
|
159
|
+
return newColors;
|
|
160
|
+
}
|
|
161
|
+
if (retryCount < maxRetries) {
|
|
162
|
+
retryCount++;
|
|
163
|
+
setTimeout(updateColors, retryDelay);
|
|
164
|
+
}
|
|
165
|
+
return currentColors;
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
setTimeout(updateColors, 100);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
observer.observe(document.head, {
|
|
173
|
+
childList: true,
|
|
174
|
+
subtree: true,
|
|
175
|
+
attributes: true,
|
|
176
|
+
attributeFilter: [
|
|
177
|
+
'href'
|
|
178
|
+
]
|
|
179
|
+
});
|
|
180
|
+
return ()=>{
|
|
181
|
+
observer.disconnect();
|
|
182
|
+
};
|
|
183
|
+
}, []);
|
|
184
|
+
const antdThemeToken = {
|
|
185
|
+
colorBgBase: cssColors.background,
|
|
186
|
+
colorError: cssColors.destructive,
|
|
187
|
+
colorInfo: cssColors.primary,
|
|
188
|
+
colorLink: cssColors.primary,
|
|
189
|
+
colorPrimary: cssColors.primary,
|
|
190
|
+
colorSuccess: cssColors.primary,
|
|
191
|
+
colorTextBase: cssColors.foreground,
|
|
192
|
+
colorWarning: cssColors.destructive
|
|
193
|
+
};
|
|
194
|
+
const antdTableToken = {
|
|
195
|
+
bodySortBg: cssColors.muted,
|
|
196
|
+
borderColor: cssColors.border,
|
|
197
|
+
expandIconBg: cssColors.background,
|
|
198
|
+
filterDropdownBg: cssColors.popover,
|
|
199
|
+
filterDropdownMenuBg: cssColors.popover,
|
|
200
|
+
fixedHeaderSortActiveBg: cssColors.muted,
|
|
201
|
+
footerBg: cssColors.muted,
|
|
202
|
+
footerColor: cssColors.mutedForeground,
|
|
203
|
+
headerBg: cssColors.muted,
|
|
204
|
+
headerColor: cssColors.mutedForeground,
|
|
205
|
+
headerFilterHoverBg: cssColors.muted,
|
|
206
|
+
headerSortActiveBg: cssColors.muted,
|
|
207
|
+
headerSortHoverBg: cssColors.muted,
|
|
208
|
+
headerSplitColor: cssColors.border,
|
|
209
|
+
rowExpandedBg: cssColors.background,
|
|
210
|
+
rowHoverBg: cssColors.muted,
|
|
211
|
+
rowSelectedBg: cssColors.accent,
|
|
212
|
+
rowSelectedHoverBg: cssColors.accent,
|
|
213
|
+
stickyScrollBarBg: cssColors.muted
|
|
214
|
+
};
|
|
215
|
+
const antdPaginationToken = {
|
|
216
|
+
itemActiveBg: cssColors.background,
|
|
217
|
+
itemActiveBgDisabled: cssColors.muted,
|
|
218
|
+
itemActiveColor: cssColors.primary,
|
|
219
|
+
itemActiveColorDisabled: cssColors.muted,
|
|
220
|
+
itemActiveColorHover: cssColors.muted,
|
|
221
|
+
itemBg: cssColors.background,
|
|
222
|
+
itemInputBg: cssColors.background,
|
|
223
|
+
itemLinkBg: cssColors.background
|
|
224
|
+
};
|
|
63
225
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
64
226
|
children: [
|
|
65
227
|
/*#__PURE__*/ jsx(safety, {}),
|
|
66
|
-
/*#__PURE__*/ jsx(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
228
|
+
/*#__PURE__*/ jsx(ConfigProvider, {
|
|
229
|
+
theme: {
|
|
230
|
+
token: antdThemeToken,
|
|
231
|
+
components: {
|
|
232
|
+
Table: antdTableToken,
|
|
233
|
+
Pagination: antdPaginationToken
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
children: /*#__PURE__*/ jsx(App, {
|
|
237
|
+
themeMeta: props.themeMeta,
|
|
238
|
+
enableAuth: props.enableAuth,
|
|
239
|
+
children: children
|
|
240
|
+
})
|
|
70
241
|
})
|
|
71
242
|
]
|
|
72
243
|
});
|
|
73
244
|
};
|
|
74
|
-
const
|
|
75
|
-
export {
|
|
245
|
+
const AppContainer = AppContainer_AppContainer;
|
|
246
|
+
export { AppContainer as default };
|
|
@@ -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-
|
|
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();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLarkUserInfo(): Promise<any>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getAppId } from "../../../utils/getAppId.js";
|
|
2
|
+
import { getCsrfToken } from "../../../utils/getCsrfToken.js";
|
|
3
|
+
async function getLarkUserInfo() {
|
|
4
|
+
const appId = getAppId(window.location.pathname);
|
|
5
|
+
if (!appId) return {
|
|
6
|
+
code: 1,
|
|
7
|
+
msg: 'appId is required',
|
|
8
|
+
data: {}
|
|
9
|
+
};
|
|
10
|
+
const response = await fetch(`/spark/b/${appId}/lark/user_info`, {
|
|
11
|
+
headers: {
|
|
12
|
+
'X-Suda-Csrf-Token': getCsrfToken()
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return await response.json();
|
|
16
|
+
}
|
|
17
|
+
export { getLarkUserInfo };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TrackParams } from '../../../types/tea';
|
|
2
|
+
export declare const encryptTea: (message: any) => string;
|
|
3
|
+
/**
|
|
4
|
+
* 初始化Tea 客户端
|
|
5
|
+
* @export
|
|
6
|
+
*/
|
|
7
|
+
export declare function createTracker(): Promise<void>;
|
|
8
|
+
export declare const reportTeaEvent: ({ trackKey, trackParams }: TrackParams) => Promise<void>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import blueimp_md5 from "blueimp-md5";
|
|
2
|
+
import sha1 from "crypto-js/sha1";
|
|
3
|
+
import { isMobile } from "../../../utils/deviceType.js";
|
|
4
|
+
import { getEnv } from "../../../utils/getParentOrigin.js";
|
|
5
|
+
import { getLarkUserInfo } from "./getLarkUser.js";
|
|
6
|
+
const saltA = '08a441';
|
|
7
|
+
const saltB = '42b91e';
|
|
8
|
+
const encryptTea = (message)=>{
|
|
9
|
+
const msgString = String(message);
|
|
10
|
+
return sha1(saltA + blueimp_md5(msgString + saltB)).toString();
|
|
11
|
+
};
|
|
12
|
+
let teaInstance = false;
|
|
13
|
+
async function createTracker() {
|
|
14
|
+
const { data } = await getLarkUserInfo();
|
|
15
|
+
const { tenantID, userID } = data || {};
|
|
16
|
+
const userIDEncrypt = userID && '0' !== userID ? encryptTea(userID) : void 0;
|
|
17
|
+
const tenantIDEncrypt = tenantID && '0' !== tenantID ? encryptTea(tenantID) : void 0;
|
|
18
|
+
window.collectEvent('init', {
|
|
19
|
+
app_id: 672575,
|
|
20
|
+
channel: 'cn',
|
|
21
|
+
disable_auto_pv: false,
|
|
22
|
+
enable_ab_test: false,
|
|
23
|
+
enable_debug: false,
|
|
24
|
+
enable_stay_duration: true,
|
|
25
|
+
reportTime: 1000
|
|
26
|
+
});
|
|
27
|
+
window.collectEvent('config', {
|
|
28
|
+
user_unique_id: userIDEncrypt,
|
|
29
|
+
device_type: isMobile() ? 'mobile' : 'pc',
|
|
30
|
+
evtParams: {
|
|
31
|
+
open_from: new URLSearchParams(window.location.search).get('open-from') ?? void 0,
|
|
32
|
+
env: getEnv(),
|
|
33
|
+
user_id: userIDEncrypt,
|
|
34
|
+
tenant_id: tenantIDEncrypt
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
teaInstance = true;
|
|
38
|
+
window.collectEvent('start');
|
|
39
|
+
}
|
|
40
|
+
const reportTeaEvent = async ({ trackKey, trackParams = {} })=>{
|
|
41
|
+
try {
|
|
42
|
+
if (!teaInstance) {
|
|
43
|
+
teaInstance = true;
|
|
44
|
+
await createTracker();
|
|
45
|
+
}
|
|
46
|
+
window.collectEvent(trackKey, trackParams);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error(err);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export { createTracker, encryptTea, reportTeaEvent };
|
|
@@ -2,19 +2,26 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { logger } from "../../logger/index.js";
|
|
4
4
|
import { createApplyHandle, getModuleHot } from "../../utils/module-hot.js";
|
|
5
|
+
import { submitPostMessage } from "../../utils/postMessage.js";
|
|
5
6
|
const RenderError = (props)=>{
|
|
6
7
|
const { error, resetErrorBoundary } = props;
|
|
7
8
|
useEffect(()=>{
|
|
8
|
-
if (error)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
if (error) {
|
|
10
|
+
submitPostMessage({
|
|
11
|
+
type: 'RenderError',
|
|
12
|
+
data: error
|
|
13
|
+
});
|
|
14
|
+
logger.log({
|
|
15
|
+
level: 'error',
|
|
16
|
+
args: [
|
|
17
|
+
'Render Error',
|
|
18
|
+
error
|
|
19
|
+
],
|
|
20
|
+
meta: {
|
|
21
|
+
type: 'render-error'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
18
25
|
}, [
|
|
19
26
|
error
|
|
20
27
|
]);
|
|
@@ -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>;
|