@lark-apaas/client-toolkit 1.2.9 → 1.2.34
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/antd-table.d.ts +2 -2
- package/lib/apis/aily-chat.d.ts +2 -0
- package/lib/apis/aily-chat.js +2 -0
- package/lib/apis/hooks/useScrollReveal.d.ts +1 -0
- package/lib/apis/hooks/useScrollReveal.js +1 -0
- package/lib/apis/udt-types.d.ts +4 -0
- package/lib/apis/utils/resolveAppUrl.d.ts +1 -0
- package/lib/apis/utils/resolveAppUrl.js +2 -0
- package/lib/apis/utils/scopedStorage.d.ts +1 -0
- package/lib/apis/utils/scopedStorage.js +2 -0
- package/lib/auth.d.ts +2 -1
- package/lib/auth.js +2 -2
- package/lib/components/AppContainer/api-proxy/core.js +2 -1
- package/lib/components/AppContainer/index.d.ts +5 -1
- package/lib/components/AppContainer/index.js +41 -34
- package/lib/components/AppContainer/safety.js +27 -8
- package/lib/components/AppContainer/utils/childApi.js +1 -0
- package/lib/components/AppContainer/utils/getLarkUser.js +4 -2
- package/lib/components/AppContainer/utils/observable.js +7 -1
- package/lib/components/AppContainer/utils/tea.js +1 -1
- package/lib/components/ErrorRender/index.js +5 -11
- package/lib/components/User/UserSelect.js +1 -13
- package/lib/components/theme/index.d.ts +0 -1
- package/lib/components/theme/index.js +0 -1
- package/lib/components/theme/util.d.ts +0 -2
- package/lib/components/theme/util.js +0 -108
- package/lib/components/ui/badge.d.ts +1 -1
- package/lib/components/ui/button.d.ts +2 -2
- package/lib/components/ui/button.js +1 -1
- package/lib/components/ui/confirm.d.ts +28 -0
- package/lib/components/ui/confirm.js +83 -0
- package/lib/components/ui/toast.d.ts +2 -0
- package/lib/components/ui/toast.js +53 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useCurrentUserProfile.d.ts +18 -3
- package/lib/hooks/useCurrentUserProfile.js +38 -29
- package/lib/hooks/useLogout.js +2 -17
- package/lib/hooks/useScrollReveal.d.ts +61 -0
- package/lib/hooks/useScrollReveal.js +37 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +14 -2
- package/lib/integrations/dataloom.d.ts +3 -1
- package/lib/integrations/dataloom.js +18 -10
- package/lib/integrations/getCurrentUserProfile.d.ts +7 -1
- package/lib/integrations/services/ChatService.d.ts +12 -0
- package/lib/integrations/services/ChatService.js +67 -0
- package/lib/integrations/services/DepartmentService.js +3 -2
- package/lib/integrations/services/UserProfileService.js +3 -2
- package/lib/integrations/services/UserService.d.ts +3 -1
- package/lib/integrations/services/UserService.js +23 -3
- package/lib/integrations/services/index.d.ts +1 -0
- package/lib/integrations/services/index.js +1 -0
- package/lib/integrations/services/types.d.ts +45 -0
- package/lib/logger/intercept-global-error.js +34 -25
- package/lib/logger/log-types.d.ts +4 -4
- package/lib/logger/log-types.js +1 -1
- package/lib/runtime/index.d.ts +1 -0
- package/lib/runtime/index.js +1 -0
- package/lib/runtime/react-devtools-hook.d.ts +19 -0
- package/lib/runtime/react-devtools-hook.js +20 -0
- package/lib/theme-layer.css +2 -1
- package/lib/utils/apiPath.d.ts +5 -0
- package/lib/utils/apiPath.js +5 -0
- package/lib/utils/axiosConfig.js +163 -9
- package/lib/utils/getAppId.d.ts +2 -4
- package/lib/utils/getAppId.js +2 -9
- package/lib/utils/getInitialInfo.d.ts +4 -3
- package/lib/utils/getInitialInfo.js +17 -8
- package/lib/utils/getUserProfile.js +4 -12
- package/lib/utils/hmr-api.d.ts +45 -0
- package/lib/utils/hmr-api.js +36 -0
- package/lib/utils/module-hot.d.ts +9 -5
- package/lib/utils/module-hot.js +9 -10
- package/lib/utils/postMessage.d.ts +0 -1
- package/lib/utils/postMessage.js +19 -6
- package/lib/utils/requestManager.js +1 -3
- package/lib/utils/resolveAppUrl.d.ts +27 -0
- package/lib/utils/resolveAppUrl.js +19 -0
- package/lib/utils/safeStringify.js +5 -0
- package/lib/utils/safeStringify.spec.d.ts +1 -0
- package/lib/utils/safeStringify.spec.js +125 -0
- package/lib/utils/scopedStorage.d.ts +5 -0
- package/lib/utils/scopedStorage.js +46 -0
- package/package.json +13 -6
- package/lib/apis/tools/generateImage.d.ts +0 -1
- package/lib/apis/tools/generateImage.js +0 -1
- package/lib/apis/tools/generateTextStream.d.ts +0 -1
- package/lib/apis/tools/generateTextStream.js +0 -1
- package/lib/components/theme/ui-config.d.ts +0 -1
- package/lib/components/theme/ui-config.js +0 -2
- package/lib/integrations/generateImage.d.ts +0 -1
- package/lib/integrations/generateImage.js +0 -47
- package/lib/integrations/generateTextStream.d.ts +0 -21
- package/lib/integrations/generateTextStream.js +0 -98
package/lib/antd-table.d.ts
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { ChatPanel, IframeEventMessage, IframeMessage, IframeMessageType, IframeRequestMessage, IframeResponseMessage, WebSDKCommonConfig, WebSDKConfig, WebSDKConversionConfig, WebSDKEditorConfig, WebSDKEvents, WebSDKSkillInfo, } from '@lark-apaas/aily-web-sdk';
|
|
2
|
+
export { DEFAULT_ANONYMOUS_CHANNEL_TYPE, DEFAULT_CHANNEL_TYPE, getIframeBaseURL, IFRAME_BASE_URL, initAilyChat, MESSAGE_TIMEOUT, } from '@lark-apaas/aily-web-sdk';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { DEFAULT_ANONYMOUS_CHANNEL_TYPE, DEFAULT_CHANNEL_TYPE, IFRAME_BASE_URL, MESSAGE_TIMEOUT, getIframeBaseURL, initAilyChat } from "@lark-apaas/aily-web-sdk";
|
|
2
|
+
export { DEFAULT_ANONYMOUS_CHANNEL_TYPE, DEFAULT_CHANNEL_TYPE, IFRAME_BASE_URL, MESSAGE_TIMEOUT, getIframeBaseURL, initAilyChat };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../hooks/useScrollReveal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../hooks/useScrollReveal.js";
|
package/lib/apis/udt-types.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolveAppUrl } from '../../utils/resolveAppUrl';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { scopedStorage } from '../../utils/scopedStorage';
|
package/lib/auth.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { CanRole, AbilityContext, ROLE_SUBJECT } from '@lark-apaas/auth-sdk';
|
|
1
|
+
export { AuthProvider, useAuth, Can, CanRole, useCan, AbilityContext, useUserPermissions, PermissionClient, ROLE_SUBJECT, } from '@lark-apaas/auth-sdk';
|
|
2
|
+
export type { AuthProviderProps, PermissionApiResponse, PermissionApiConfig, PermissionPointData, AuthSdkConfig, } from '@lark-apaas/auth-sdk';
|
package/lib/auth.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AbilityContext, CanRole, ROLE_SUBJECT } from "@lark-apaas/auth-sdk";
|
|
2
|
-
export { AbilityContext, CanRole, ROLE_SUBJECT };
|
|
1
|
+
import { AbilityContext, AuthProvider, Can, CanRole, PermissionClient, ROLE_SUBJECT, useAuth, useCan, useUserPermissions } from "@lark-apaas/auth-sdk";
|
|
2
|
+
export { AbilityContext, AuthProvider, Can, CanRole, PermissionClient, ROLE_SUBJECT, useAuth, useCan, useUserPermissions };
|
|
@@ -139,7 +139,8 @@ class ApiProxy {
|
|
|
139
139
|
...config,
|
|
140
140
|
headers: {
|
|
141
141
|
...this.defaultConfig.headers,
|
|
142
|
-
...config.headers
|
|
142
|
+
...config.headers,
|
|
143
|
+
'X-Page-Route': 'undefined' != typeof window ? window.location?.pathname || '/' : '/'
|
|
143
144
|
}
|
|
144
145
|
};
|
|
145
146
|
const requestKey = this.generateRequestKey(mergedConfig);
|
|
@@ -4,7 +4,11 @@ import '../../runtime';
|
|
|
4
4
|
interface IBaseAuthProviderProps {
|
|
5
5
|
enableAuth?: boolean;
|
|
6
6
|
}
|
|
7
|
+
interface IToasterProps {
|
|
8
|
+
/** 禁用内建 Toaster 组件,默认 false */
|
|
9
|
+
disableToaster?: boolean;
|
|
10
|
+
}
|
|
7
11
|
declare const AppContainer: React.FC<{
|
|
8
12
|
children: React.ReactNode;
|
|
9
|
-
} & IBaseThemeProviderProps & IBaseAuthProviderProps>;
|
|
13
|
+
} & IBaseThemeProviderProps & IBaseAuthProviderProps & IToasterProps>;
|
|
10
14
|
export default AppContainer;
|
|
@@ -4,15 +4,15 @@ import { ConfigProvider } from "antd";
|
|
|
4
4
|
import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
|
|
5
5
|
import zh_CN from "antd/locale/zh_CN";
|
|
6
6
|
import IframeBridge from "./IframeBridge.js";
|
|
7
|
-
import { defaultUIConfig } from "../theme/ui-config.js";
|
|
8
7
|
import { Toaster } from "./sonner.js";
|
|
9
8
|
import { PageHoc } from "./PageHoc.js";
|
|
10
|
-
import { findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, themeMetaOptions } from "../theme/index.js";
|
|
11
9
|
import { reportTeaEvent } from "./utils/tea.js";
|
|
12
10
|
import { useAppInfo } from "../../hooks/index.js";
|
|
13
11
|
import { TrackKey } from "../../types/tea.js";
|
|
12
|
+
import { slardar } from "@lark-apaas/internal-slardar";
|
|
14
13
|
import safety from "./safety.js";
|
|
15
14
|
import { getAppId } from "../../utils/getAppId.js";
|
|
15
|
+
import { isNewPathEnabled } from "../../utils/apiPath.js";
|
|
16
16
|
import QueryProvider from "../QueryProvider/index.js";
|
|
17
17
|
import { AuthProvider } from "@lark-apaas/auth-sdk";
|
|
18
18
|
import "../../runtime/index.js";
|
|
@@ -26,20 +26,10 @@ const readCssVarColor = (varName, fallback)=>{
|
|
|
26
26
|
return fallback;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
+
const appFlags = process.env.APP_FLAGS || {};
|
|
29
30
|
const App = (props)=>{
|
|
30
|
-
const {
|
|
31
|
+
const { enableAuth, disableToaster = false } = props;
|
|
31
32
|
useAppInfo();
|
|
32
|
-
const { rem } = findValueByPixel(themeMetaOptions.themeRadius, themeMeta.borderRadius) || {
|
|
33
|
-
rem: '0.625'
|
|
34
|
-
};
|
|
35
|
-
const radiusToken = generateTailwindRadiusToken(Number(rem));
|
|
36
|
-
const themeToken = {
|
|
37
|
-
...defaultUIConfig,
|
|
38
|
-
common: {
|
|
39
|
-
...defaultUIConfig.common,
|
|
40
|
-
borderRadius: radiusToken
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
33
|
useEffect(()=>{
|
|
44
34
|
if (isMiaodaPreview) fetch(`${location.origin}/ai/api/feida_preview/csrf`).then(()=>{
|
|
45
35
|
setTimeout(()=>{
|
|
@@ -49,29 +39,46 @@ const App = (props)=>{
|
|
|
49
39
|
});
|
|
50
40
|
}, []);
|
|
51
41
|
useEffect(()=>{
|
|
52
|
-
if ('production' === process.env.NODE_ENV)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
if ('production' === process.env.NODE_ENV) {
|
|
43
|
+
reportTeaEvent({
|
|
44
|
+
trackKey: TrackKey.VIEW,
|
|
45
|
+
trackParams: {
|
|
46
|
+
artifact_uid: getAppId(),
|
|
47
|
+
agent_id: 'agent_miaoda',
|
|
48
|
+
url: window.location.href
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const appId = getAppId();
|
|
52
|
+
const firstRenderTime = Math.round(performance.now());
|
|
53
|
+
const navEntry = performance.getEntriesByType('navigation')[0];
|
|
54
|
+
const pageLoadTime = navEntry && navEntry.loadEventEnd > 0 ? Math.round(navEntry.loadEventEnd - navEntry.startTime) : void 0;
|
|
55
|
+
slardar.sendEvent({
|
|
56
|
+
name: 'app-first-render',
|
|
57
|
+
metrics: {
|
|
58
|
+
firstRenderTime,
|
|
59
|
+
...null != pageLoadTime ? {
|
|
60
|
+
pageLoadTime
|
|
61
|
+
} : {}
|
|
62
|
+
},
|
|
63
|
+
categories: {
|
|
64
|
+
appId: appId ?? 'unknown',
|
|
65
|
+
mode: isMiaodaPreview ? 'preview' : 'runtime'
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
60
69
|
}, []);
|
|
70
|
+
const appId = getAppId();
|
|
71
|
+
const permissionApiUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/permissions/roles` : `/spark/app/${appId}/runtime/api/v1/permissions/roles`;
|
|
61
72
|
return /*#__PURE__*/ jsxs(AuthProvider, {
|
|
62
73
|
config: {
|
|
63
|
-
enable: enableAuth
|
|
74
|
+
enable: enableAuth,
|
|
75
|
+
permissionApi: {
|
|
76
|
+
url: permissionApiUrl
|
|
77
|
+
}
|
|
64
78
|
},
|
|
65
79
|
children: [
|
|
66
|
-
/*#__PURE__*/ jsx(Toaster, {}),
|
|
67
|
-
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {
|
|
68
|
-
theme: {
|
|
69
|
-
themeMetaOptions: themeMetaOptions,
|
|
70
|
-
themeColorTokenMap: themeColorTokenMap,
|
|
71
|
-
themeToken
|
|
72
|
-
},
|
|
73
|
-
cwd: process.env.CWD || ''
|
|
74
|
-
}),
|
|
80
|
+
!disableToaster && true !== appFlags.customToaster && /*#__PURE__*/ jsx(Toaster, {}),
|
|
81
|
+
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {}),
|
|
75
82
|
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(IframeBridge, {}),
|
|
76
83
|
/*#__PURE__*/ jsx(PageHoc, {
|
|
77
84
|
children: props.children
|
|
@@ -80,7 +87,7 @@ const App = (props)=>{
|
|
|
80
87
|
});
|
|
81
88
|
};
|
|
82
89
|
const AppContainer_AppContainer = (props)=>{
|
|
83
|
-
const { children
|
|
90
|
+
const { children } = props;
|
|
84
91
|
const [cssColors, setCssColors] = useState(()=>({
|
|
85
92
|
background: readCssVarColor('--background'),
|
|
86
93
|
destructive: readCssVarColor('--destructive'),
|
|
@@ -208,8 +215,8 @@ const AppContainer_AppContainer = (props)=>{
|
|
|
208
215
|
}
|
|
209
216
|
},
|
|
210
217
|
children: /*#__PURE__*/ jsx(App, {
|
|
211
|
-
themeMeta: props.themeMeta,
|
|
212
218
|
enableAuth: props.enableAuth,
|
|
219
|
+
disableToaster: props.disableToaster,
|
|
213
220
|
children: children
|
|
214
221
|
})
|
|
215
222
|
})
|
|
@@ -3,25 +3,42 @@ import { useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
|
|
4
4
|
import { getCsrfToken } from "../../utils/getCsrfToken.js";
|
|
5
5
|
import { getAppId } from "../../utils/getAppId.js";
|
|
6
|
+
import { isNewPathEnabled } from "../../utils/apiPath.js";
|
|
6
7
|
import { useIsMobile } from "../../hooks/index.js";
|
|
7
8
|
import { X } from "lucide-react";
|
|
8
9
|
import { Sheet, SheetContent, SheetTrigger } from "../ui/drawer.js";
|
|
9
10
|
const Component = ()=>{
|
|
10
|
-
const HasClosedKey = `miaoda-creatByMiaoda-has-closed-${getAppId(
|
|
11
|
+
const HasClosedKey = `miaoda-creatByMiaoda-has-closed-${getAppId()}`;
|
|
11
12
|
const [visible, setVisible] = useState(!window.localStorage?.getItem(HasClosedKey));
|
|
12
13
|
const [open, setOpen] = useState(false);
|
|
13
14
|
const isMobile = useIsMobile();
|
|
14
15
|
const [userinfo, setUserinfo] = useState(null);
|
|
15
16
|
const [isInternetVisible, setIsInternetVisible] = useState(false);
|
|
17
|
+
const [showBadge, setShowBadge] = useState(true);
|
|
18
|
+
const [badgeLoaded, setBadgeLoaded] = useState(false);
|
|
16
19
|
const timeoutRef = useRef(null);
|
|
17
20
|
useEffect(()=>{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const appId = getAppId();
|
|
22
|
+
const csrfHeaders = {
|
|
23
|
+
'X-Suda-Csrf-Token': getCsrfToken()
|
|
24
|
+
};
|
|
25
|
+
const tenantInfoUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/tenant_info` : `/spark/b/${appId}/tenant_info`;
|
|
26
|
+
fetch(tenantInfoUrl, {
|
|
27
|
+
headers: csrfHeaders
|
|
22
28
|
}).then((res)=>res.json()).then((data)=>{
|
|
23
29
|
setUserinfo(data?.data?.tenant_info);
|
|
24
30
|
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);
|
|
25
42
|
});
|
|
26
43
|
}, []);
|
|
27
44
|
useEffect(()=>{
|
|
@@ -36,6 +53,8 @@ const Component = ()=>{
|
|
|
36
53
|
isMobile
|
|
37
54
|
]);
|
|
38
55
|
if ('production' !== process.env.NODE_ENV) return null;
|
|
56
|
+
if (!badgeLoaded) return null;
|
|
57
|
+
if (!showBadge) return null;
|
|
39
58
|
if (!visible) return null;
|
|
40
59
|
if (isMobile) return /*#__PURE__*/ jsxs(Sheet, {
|
|
41
60
|
open: open,
|
|
@@ -44,7 +63,7 @@ const Component = ()=>{
|
|
|
44
63
|
/*#__PURE__*/ jsx(SheetTrigger, {
|
|
45
64
|
asChild: true,
|
|
46
65
|
children: /*#__PURE__*/ jsxs("div", {
|
|
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-
|
|
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-[6px] text-[#ebebeb)] font-['PingFang_SC'] text-xs leading-[20px] tracking-[0px] z-[10000000]",
|
|
48
67
|
onClick: ()=>{
|
|
49
68
|
setOpen(true);
|
|
50
69
|
},
|
|
@@ -239,7 +258,7 @@ const Component = ()=>{
|
|
|
239
258
|
className: "w-full self-stretch shrink-0 flex items-start gap-x-[8px]",
|
|
240
259
|
children: [
|
|
241
260
|
/*#__PURE__*/ jsx("div", {
|
|
242
|
-
className: "flex-1 flex rounded-
|
|
261
|
+
className: "flex-1 flex rounded-[8px] 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
262
|
"data-custom-element": "safety-close",
|
|
244
263
|
onClick: (e)=>{
|
|
245
264
|
e.stopPropagation();
|
|
@@ -250,7 +269,7 @@ const Component = ()=>{
|
|
|
250
269
|
children: "不再展示"
|
|
251
270
|
}),
|
|
252
271
|
/*#__PURE__*/ jsx("div", {
|
|
253
|
-
className: "flex-1 flex rounded-
|
|
272
|
+
className: "flex-1 flex rounded-[8px] 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]",
|
|
254
273
|
"data-custom-element": "safety-more",
|
|
255
274
|
onClick: ()=>{
|
|
256
275
|
window.open('https://miaoda.feishu.cn/landing', '_blank');
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { getAppId } from "../../../utils/getAppId.js";
|
|
2
2
|
import { getCsrfToken } from "../../../utils/getCsrfToken.js";
|
|
3
|
+
import { isNewPathEnabled } from "../../../utils/apiPath.js";
|
|
3
4
|
async function getLarkUserInfo() {
|
|
4
|
-
const appId = getAppId(
|
|
5
|
+
const appId = getAppId();
|
|
5
6
|
if (!appId) return {
|
|
6
7
|
code: 1,
|
|
7
8
|
msg: 'appId is required',
|
|
8
9
|
data: {}
|
|
9
10
|
};
|
|
10
|
-
const
|
|
11
|
+
const url = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/lark/user_info` : `/spark/b/${appId}/lark/user_info`;
|
|
12
|
+
const response = await fetch(url, {
|
|
11
13
|
headers: {
|
|
12
14
|
'X-Suda-Csrf-Token': getCsrfToken()
|
|
13
15
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { AppEnv, observable } from "@lark-apaas/observable-web";
|
|
2
|
+
import { isNewPathEnabled } from "../../../utils/apiPath.js";
|
|
2
3
|
const initObservable = ()=>{
|
|
3
4
|
try {
|
|
4
5
|
const appId = window.appId;
|
|
5
6
|
observable.start({
|
|
6
7
|
serviceName: "app",
|
|
7
8
|
env: 'development' === process.env.NODE_ENV ? AppEnv.Dev : AppEnv.Prod,
|
|
8
|
-
collectorUrl: {
|
|
9
|
+
collectorUrl: isNewPathEnabled() ? {
|
|
10
|
+
log: `/app/${appId}/__runtime__/api/v1/observability/logs/collect`,
|
|
11
|
+
trace: `/app/${appId}/__runtime__/api/v1/observability/traces/collect`,
|
|
12
|
+
metric: `/app/${appId}/__runtime__/api/v1/observability/metrics/collect`,
|
|
13
|
+
time: `/app/${appId}/__runtime__/api/v1/observability/current_server_timestamp`
|
|
14
|
+
} : {
|
|
9
15
|
log: `/spark/app/${appId}/runtime/api/v1/observability/logs/collect`,
|
|
10
16
|
trace: `/spark/app/${appId}/runtime/api/v1/observability/traces/collect`,
|
|
11
17
|
metric: `/spark/app/${appId}/runtime/api/v1/observability/metrics/collect`,
|
|
@@ -16,7 +16,7 @@ async function createTracker() {
|
|
|
16
16
|
const userIDEncrypt = userID && '0' !== userID ? encryptTea(userID) : void 0;
|
|
17
17
|
const tenantIDEncrypt = tenantID && '0' !== tenantID ? encryptTea(tenantID) : void 0;
|
|
18
18
|
window.collectEvent('init', {
|
|
19
|
-
app_id:
|
|
19
|
+
app_id: 788827,
|
|
20
20
|
channel: 'cn',
|
|
21
21
|
disable_auto_pv: false,
|
|
22
22
|
enable_ab_test: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { logger } from "../../logger/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getHmrApi } from "../../utils/hmr-api.js";
|
|
5
5
|
import { submitPostMessage } from "../../utils/postMessage.js";
|
|
6
6
|
const RenderError = (props)=>{
|
|
7
7
|
const { error, resetErrorBoundary } = props;
|
|
@@ -27,16 +27,10 @@ const RenderError = (props)=>{
|
|
|
27
27
|
]);
|
|
28
28
|
useEffect(()=>{
|
|
29
29
|
if (!resetErrorBoundary) return;
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
hot.addStatusHandler(handler);
|
|
36
|
-
return ()=>{
|
|
37
|
-
hot.removeStatusHandler(handler);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
30
|
+
const hmr = getHmrApi();
|
|
31
|
+
if (hmr) return hmr.onSuccess(()=>{
|
|
32
|
+
resetErrorBoundary();
|
|
33
|
+
});
|
|
40
34
|
}, [
|
|
41
35
|
resetErrorBoundary
|
|
42
36
|
]);
|
|
@@ -67,20 +67,8 @@ const UserSelect = ({ mode = 'single', defaultValue, value, onChange, placeholde
|
|
|
67
67
|
if (!normalizedIds.length) return void setUiValue(void 0);
|
|
68
68
|
const fetchProfiles = async ()=>{
|
|
69
69
|
try {
|
|
70
|
-
const ids = normalizedIds.map((id)=>Number(id)).filter((id)=>Number.isFinite(id));
|
|
71
|
-
if (!ids.length) {
|
|
72
|
-
const profiles = normalizedIds.map((id)=>inputProfilesMap.get(id) ?? {
|
|
73
|
-
user_id: id,
|
|
74
|
-
name: '',
|
|
75
|
-
avatar: '',
|
|
76
|
-
email: '',
|
|
77
|
-
status: 1
|
|
78
|
-
});
|
|
79
|
-
setUiValue('single' === mode ? profiles[0] : profiles);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
70
|
const dataloom = await getDataloom();
|
|
83
|
-
const response = await dataloom.service.user.getByIds(
|
|
71
|
+
const response = await dataloom.service.user.getByIds(normalizedIds);
|
|
84
72
|
const fetchedList = Array.isArray(response?.data) ? response?.data : Array.isArray(response?.data?.user_list) ? response?.data?.user_list : [];
|
|
85
73
|
const fetchedMap = new Map();
|
|
86
74
|
fetchedList.forEach((profile)=>{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ITheme } from "../../types";
|
|
2
|
-
import { UIComponentConfig } from "./ui-config";
|
|
3
2
|
export interface IBaseThemeProviderProps {
|
|
4
3
|
defaultTheme?: ITheme;
|
|
5
4
|
themeMeta?: Partial<IThemeTokenMeta>;
|
|
@@ -18,4 +17,3 @@ export interface IThemeTokenMeta {
|
|
|
18
17
|
*/
|
|
19
18
|
spacing: number;
|
|
20
19
|
}
|
|
21
|
-
export declare const generateTailwindRadiusToken: (radiusRemValue: number) => UIComponentConfig;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const generateTailwindRadiusToken = (radiusRemValue)=>{
|
|
2
|
-
try {
|
|
3
|
-
const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
4
|
-
const radiusPx = radiusRemValue * rootFontSize;
|
|
5
|
-
const tempElement = document.createElement('div');
|
|
6
|
-
tempElement.style.position = 'absolute';
|
|
7
|
-
tempElement.style.visibility = 'hidden';
|
|
8
|
-
document.body.appendChild(tempElement);
|
|
9
|
-
tempElement.style.borderRadius = `${radiusPx}px`;
|
|
10
|
-
const computed = getComputedStyle(tempElement).borderRadius;
|
|
11
|
-
document.body.removeChild(tempElement);
|
|
12
|
-
if (computed && 'auto' !== computed && 'initial' !== computed) return {
|
|
13
|
-
type: 'select',
|
|
14
|
-
options: [
|
|
15
|
-
{
|
|
16
|
-
value: 'rounded-none',
|
|
17
|
-
label: 'none(0px)',
|
|
18
|
-
rawValue: '0'
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
value: 'rounded-sm',
|
|
22
|
-
label: `sm (${Math.max(0, radiusPx - 4)}px)`,
|
|
23
|
-
rawValue: `${Math.max(0, radiusPx - 4)}`
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
value: 'rounded',
|
|
27
|
-
label: 's (4px)',
|
|
28
|
-
rawValue: '4'
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
value: 'rounded-md',
|
|
32
|
-
label: `m (${Math.max(0, radiusPx - 2)}px)`,
|
|
33
|
-
rawValue: `${Math.max(0, radiusPx - 2)}`
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
value: 'rounded-lg',
|
|
37
|
-
label: `l (${radiusPx}px)`,
|
|
38
|
-
rawValue: `${radiusPx}`
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
value: 'rounded-xl',
|
|
42
|
-
label: `xl (${radiusPx + 4}px)`,
|
|
43
|
-
rawValue: `${radiusPx + 4}`
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
value: 'rounded-2xl',
|
|
47
|
-
label: '2xl (16px)',
|
|
48
|
-
rawValue: '16'
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
value: 'rounded-full',
|
|
52
|
-
label: 'Full',
|
|
53
|
-
rawValue: '9999'
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
};
|
|
57
|
-
throw new Error('Browser calculation validation failed');
|
|
58
|
-
} catch (error) {
|
|
59
|
-
console.warn('Failed to get computed values from browser, falling back to default calculation:', error);
|
|
60
|
-
const radiusPx = 16 * radiusRemValue;
|
|
61
|
-
return {
|
|
62
|
-
type: 'select',
|
|
63
|
-
options: [
|
|
64
|
-
{
|
|
65
|
-
value: 'rounded-none',
|
|
66
|
-
label: 'none(0px)',
|
|
67
|
-
rawValue: '0'
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
value: 'rounded-sm',
|
|
71
|
-
label: `sm (${Math.max(0, radiusPx - 4)}px)`,
|
|
72
|
-
rawValue: `${Math.max(0, radiusPx - 4)}`
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
value: 'rounded',
|
|
76
|
-
label: 's (4px)',
|
|
77
|
-
rawValue: '4'
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
value: 'rounded-md',
|
|
81
|
-
label: `m (${Math.max(0, radiusPx - 2)}px)`,
|
|
82
|
-
rawValue: `${Math.max(0, radiusPx - 2)}`
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
value: 'rounded-lg',
|
|
86
|
-
label: `l (${radiusPx}px)`,
|
|
87
|
-
rawValue: `${radiusPx}`
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
value: 'rounded-xl',
|
|
91
|
-
label: `xl (${radiusPx + 4}px)`,
|
|
92
|
-
rawValue: `${radiusPx + 4}`
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
value: 'rounded-2xl',
|
|
96
|
-
label: '2xl (16px)',
|
|
97
|
-
rawValue: '16'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
value: 'rounded-full',
|
|
101
|
-
label: 'Full',
|
|
102
|
-
rawValue: '9999'
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
export { generateTailwindRadiusToken };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const badgeVariants: (props?: {
|
|
4
|
-
variant?: "default" | "destructive" | "
|
|
4
|
+
variant?: "default" | "destructive" | "outline" | "secondary";
|
|
5
5
|
} & import("class-variance-authority/dist/types").ClassProp) => string;
|
|
6
6
|
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
7
7
|
asChild?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const buttonVariants: (props?: {
|
|
4
|
-
variant?: "default" | "link" | "destructive" | "
|
|
5
|
-
size?: "default" | "
|
|
4
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost";
|
|
5
|
+
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg";
|
|
6
6
|
} & import("class-variance-authority/dist/types").ClassProp) => string;
|
|
7
7
|
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
8
8
|
asChild?: boolean;
|
|
@@ -8,7 +8,7 @@ const buttonVariants = cva("inline-flex items-center justify-center gap-2 whites
|
|
|
8
8
|
variant: {
|
|
9
9
|
default: "bg-primary text-primary-foreground not-disabled:hover:bg-primary/90",
|
|
10
10
|
destructive: "bg-destructive text-white not-disabled:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
11
|
-
outline: "border bg-
|
|
11
|
+
outline: "border border-input bg-transparent text-foreground not-disabled:hover:bg-accent not-disabled:hover:text-accent-foreground",
|
|
12
12
|
secondary: "bg-secondary text-secondary-foreground not-disabled:hover:bg-secondary/80",
|
|
13
13
|
ghost: "not-disabled:hover:bg-accent not-disabled:hover:text-accent-foreground dark:not-disabled:hover:bg-accent/50",
|
|
14
14
|
link: "text-primary underline-offset-4 not-disabled:hover:underline"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ConfirmOptions {
|
|
2
|
+
/** 标题,默认 "提示" */
|
|
3
|
+
title?: string;
|
|
4
|
+
/** 内容描述 */
|
|
5
|
+
message: string;
|
|
6
|
+
/** 确认按钮文案,默认 "确认" */
|
|
7
|
+
confirmText?: string;
|
|
8
|
+
/** 取消按钮文案,默认 "取消" */
|
|
9
|
+
cancelText?: string;
|
|
10
|
+
/** 确认按钮样式变体 */
|
|
11
|
+
variant?: 'default' | 'destructive';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 函数式确认弹窗,作为 window.confirm 的直接平替。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // 简单用法(兼容 window.confirm 传参)
|
|
18
|
+
* const ok = await showConfirm('确定删除吗?');
|
|
19
|
+
*
|
|
20
|
+
* // 完整用法
|
|
21
|
+
* const ok = await showConfirm({
|
|
22
|
+
* title: '确认删除',
|
|
23
|
+
* message: '删除后不可恢复',
|
|
24
|
+
* confirmText: '删除',
|
|
25
|
+
* variant: 'destructive',
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
28
|
+
export declare function showConfirm(options: string | ConfirmOptions): Promise<boolean>;
|