@lark-apaas/client-toolkit 1.2.35-alpha-test.1 → 1.2.35-alpha.1
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/index.js +37 -33
- package/lib/components/AppContainer/safety.js +43 -40
- package/lib/components/ErrorRender/index.d.ts +2 -2
- package/lib/components/ErrorRender/index.js +1 -2
- package/lib/components/NotFoundRender/index.js +3 -8
- package/lib/components/PagePlaceholder/index.js +5 -10
- package/lib/components/User/UserProfile/UserProfileUI.js +4 -5
- package/lib/components/User/UserSelectUI/UserSelectUI.js +2 -4
- package/lib/components/ui/confirm.js +4 -8
- package/lib/index.js +1 -2
- package/lib/utils/getInitialInfo.js +0 -14
- package/lib/utils/postMessage.js +2 -30
- package/package.json +1 -1
- package/lib/locales/index.d.ts +0 -15
- package/lib/locales/index.js +0 -10
- package/lib/locales/messages.d.ts +0 -12
- package/lib/locales/messages.js +0 -108
- package/lib/utils/locale.d.ts +0 -9
- package/lib/utils/locale.js +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
import { ConfigProvider } from "antd";
|
|
4
4
|
import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
|
|
5
5
|
import zh_CN from "antd/locale/zh_CN";
|
|
@@ -10,33 +10,20 @@ import { reportTeaEvent } from "./utils/tea.js";
|
|
|
10
10
|
import { useAppInfo } from "../../hooks/index.js";
|
|
11
11
|
import { TrackKey } from "../../types/tea.js";
|
|
12
12
|
import { slardar } from "@lark-apaas/internal-slardar";
|
|
13
|
+
import safety from "./safety.js";
|
|
13
14
|
import { getAppId } from "../../utils/getAppId.js";
|
|
14
15
|
import { isNewPathEnabled } from "../../utils/apiPath.js";
|
|
15
16
|
import QueryProvider from "../QueryProvider/index.js";
|
|
16
17
|
import { AuthProvider } from "@lark-apaas/auth-sdk";
|
|
17
18
|
import "../../runtime/index.js";
|
|
18
|
-
const Safety = /*#__PURE__*/ react.lazy(()=>import("./safety.js"));
|
|
19
19
|
const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
|
|
20
|
-
const
|
|
20
|
+
const readCssVarColor = (varName, fallback)=>{
|
|
21
21
|
try {
|
|
22
|
-
if ('undefined' == typeof document) return
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
background: read('--background'),
|
|
27
|
-
destructive: read('--destructive'),
|
|
28
|
-
primary: read('--primary'),
|
|
29
|
-
foreground: read('--foreground'),
|
|
30
|
-
warning: read('--warning'),
|
|
31
|
-
success: read('--success'),
|
|
32
|
-
muted: read('--muted'),
|
|
33
|
-
mutedForeground: read('--muted-foreground'),
|
|
34
|
-
border: read('--border'),
|
|
35
|
-
popover: read('--popover'),
|
|
36
|
-
accent: read('--accent')
|
|
37
|
-
};
|
|
22
|
+
if ('undefined' == typeof document) return fallback;
|
|
23
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
24
|
+
return value || fallback;
|
|
38
25
|
} catch {
|
|
39
|
-
return
|
|
26
|
+
return fallback;
|
|
40
27
|
}
|
|
41
28
|
};
|
|
42
29
|
const appFlags = process.env.APP_FLAGS || {};
|
|
@@ -82,17 +69,13 @@ const App = (props)=>{
|
|
|
82
69
|
}, []);
|
|
83
70
|
const appId = getAppId();
|
|
84
71
|
const permissionApiUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/permissions/roles` : `/spark/app/${appId}/runtime/api/v1/permissions/roles`;
|
|
85
|
-
|
|
72
|
+
return /*#__PURE__*/ jsxs(AuthProvider, {
|
|
73
|
+
config: {
|
|
86
74
|
enable: enableAuth,
|
|
87
75
|
permissionApi: {
|
|
88
76
|
url: permissionApiUrl
|
|
89
77
|
}
|
|
90
|
-
}
|
|
91
|
-
enableAuth,
|
|
92
|
-
permissionApiUrl
|
|
93
|
-
]);
|
|
94
|
-
return /*#__PURE__*/ jsxs(AuthProvider, {
|
|
95
|
-
config: authConfig,
|
|
78
|
+
},
|
|
96
79
|
children: [
|
|
97
80
|
!disableToaster && true !== appFlags.customToaster && /*#__PURE__*/ jsx(Toaster, {}),
|
|
98
81
|
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {}),
|
|
@@ -105,7 +88,19 @@ const App = (props)=>{
|
|
|
105
88
|
};
|
|
106
89
|
const AppContainer_AppContainer = (props)=>{
|
|
107
90
|
const { children } = props;
|
|
108
|
-
const [cssColors, setCssColors] = useState(
|
|
91
|
+
const [cssColors, setCssColors] = useState(()=>({
|
|
92
|
+
background: readCssVarColor('--background'),
|
|
93
|
+
destructive: readCssVarColor('--destructive'),
|
|
94
|
+
primary: readCssVarColor('--primary'),
|
|
95
|
+
foreground: readCssVarColor('--foreground'),
|
|
96
|
+
warning: readCssVarColor('--warning'),
|
|
97
|
+
success: readCssVarColor('--success'),
|
|
98
|
+
muted: readCssVarColor('--muted'),
|
|
99
|
+
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
100
|
+
border: readCssVarColor('--border'),
|
|
101
|
+
popover: readCssVarColor('--popover'),
|
|
102
|
+
accent: readCssVarColor('--accent')
|
|
103
|
+
}));
|
|
109
104
|
useEffect(()=>{
|
|
110
105
|
if ('production' === process.env.NODE_ENV) return ()=>{};
|
|
111
106
|
const observer = new MutationObserver((mutations)=>{
|
|
@@ -124,7 +119,19 @@ const AppContainer_AppContainer = (props)=>{
|
|
|
124
119
|
const maxRetries = 10;
|
|
125
120
|
const retryDelay = 400;
|
|
126
121
|
const updateColors = ()=>{
|
|
127
|
-
const newColors =
|
|
122
|
+
const newColors = {
|
|
123
|
+
background: readCssVarColor('--background'),
|
|
124
|
+
destructive: readCssVarColor('--destructive'),
|
|
125
|
+
primary: readCssVarColor('--primary'),
|
|
126
|
+
foreground: readCssVarColor('--foreground'),
|
|
127
|
+
warning: readCssVarColor('--warning'),
|
|
128
|
+
success: readCssVarColor('--success'),
|
|
129
|
+
muted: readCssVarColor('--muted'),
|
|
130
|
+
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
131
|
+
border: readCssVarColor('--border'),
|
|
132
|
+
popover: readCssVarColor('--popover'),
|
|
133
|
+
accent: readCssVarColor('--accent')
|
|
134
|
+
};
|
|
128
135
|
setCssColors((currentColors)=>{
|
|
129
136
|
if (JSON.stringify(currentColors) !== JSON.stringify(newColors)) {
|
|
130
137
|
retryCount = 0;
|
|
@@ -196,10 +203,7 @@ const AppContainer_AppContainer = (props)=>{
|
|
|
196
203
|
};
|
|
197
204
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
198
205
|
children: [
|
|
199
|
-
/*#__PURE__*/ jsx(
|
|
200
|
-
fallback: null,
|
|
201
|
-
children: /*#__PURE__*/ jsx(Safety, {})
|
|
202
|
-
}),
|
|
206
|
+
/*#__PURE__*/ jsx(safety, {}),
|
|
203
207
|
/*#__PURE__*/ jsx(QueryProvider, {
|
|
204
208
|
children: /*#__PURE__*/ jsx(ConfigProvider, {
|
|
205
209
|
locale: zh_CN,
|
|
@@ -1,58 +1,59 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
|
|
4
|
-
import { getAppId } from "../../utils/getAppId.js";
|
|
5
4
|
import { getCsrfToken } from "../../utils/getCsrfToken.js";
|
|
5
|
+
import { getAppId } from "../../utils/getAppId.js";
|
|
6
6
|
import { isNewPathEnabled } from "../../utils/apiPath.js";
|
|
7
7
|
import { useIsMobile } from "../../hooks/index.js";
|
|
8
8
|
import { X } from "lucide-react";
|
|
9
9
|
import { Sheet, SheetContent, SheetTrigger } from "../ui/drawer.js";
|
|
10
|
-
import { t } from "../../locales/index.js";
|
|
11
10
|
const Component = ()=>{
|
|
12
11
|
const HasClosedKey = `miaoda-creatByMiaoda-has-closed-${getAppId()}`;
|
|
13
12
|
const [visible, setVisible] = useState(!window.localStorage?.getItem(HasClosedKey));
|
|
14
13
|
const [open, setOpen] = useState(false);
|
|
15
14
|
const isMobile = useIsMobile();
|
|
16
|
-
const
|
|
17
|
-
const platformData = window.__platform_data__ || window.__platform__ || {};
|
|
18
|
-
const appId = getAppId() || platformData.appId;
|
|
19
|
-
const showBadge = false !== platformData.showBadge;
|
|
20
|
-
const [tenantName, setTenantName] = useState('');
|
|
15
|
+
const [userinfo, setUserinfo] = useState(null);
|
|
21
16
|
const [isInternetVisible, setIsInternetVisible] = useState(false);
|
|
17
|
+
const [showBadge, setShowBadge] = useState(true);
|
|
18
|
+
const [badgeLoaded, setBadgeLoaded] = useState(false);
|
|
19
|
+
const timeoutRef = useRef(null);
|
|
22
20
|
useEffect(()=>{
|
|
23
|
-
|
|
24
|
-
const csrfToken = getCsrfToken() ?? '';
|
|
21
|
+
const appId = getAppId();
|
|
25
22
|
const csrfHeaders = {
|
|
26
|
-
'X-Suda-Csrf-Token':
|
|
23
|
+
'X-Suda-Csrf-Token': getCsrfToken()
|
|
27
24
|
};
|
|
28
25
|
const tenantInfoUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/tenant_info` : `/spark/b/${appId}/tenant_info`;
|
|
29
26
|
fetch(tenantInfoUrl, {
|
|
30
27
|
headers: csrfHeaders
|
|
31
28
|
}).then((res)=>res.json()).then((data)=>{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
setUserinfo(data?.data?.tenant_info);
|
|
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);
|
|
38
42
|
});
|
|
39
|
-
}, [
|
|
40
|
-
appId,
|
|
41
|
-
showBadge,
|
|
42
|
-
visible
|
|
43
|
-
]);
|
|
43
|
+
}, []);
|
|
44
44
|
useEffect(()=>{
|
|
45
45
|
if (isMobile) {
|
|
46
46
|
const link = document.createElement('link');
|
|
47
47
|
link.rel = 'preload';
|
|
48
48
|
link.as = 'image';
|
|
49
|
-
link.href =
|
|
49
|
+
link.href = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-mobile.png';
|
|
50
50
|
document.head.appendChild(link);
|
|
51
51
|
}
|
|
52
52
|
}, [
|
|
53
53
|
isMobile
|
|
54
54
|
]);
|
|
55
55
|
if ('production' !== process.env.NODE_ENV) return null;
|
|
56
|
+
if (!badgeLoaded) return null;
|
|
56
57
|
if (!showBadge) return null;
|
|
57
58
|
if (!visible) return null;
|
|
58
59
|
if (isMobile) return /*#__PURE__*/ jsxs(Sheet, {
|
|
@@ -73,7 +74,7 @@ const Component = ()=>{
|
|
|
73
74
|
}),
|
|
74
75
|
/*#__PURE__*/ jsx("p", {
|
|
75
76
|
className: "shrink-0 min-w-[28px] m-0! text-[#EBEBEB]",
|
|
76
|
-
children:
|
|
77
|
+
children: "妙搭"
|
|
77
78
|
})
|
|
78
79
|
]
|
|
79
80
|
})
|
|
@@ -89,7 +90,7 @@ const Component = ()=>{
|
|
|
89
90
|
onClick: ()=>setOpen(false)
|
|
90
91
|
}),
|
|
91
92
|
/*#__PURE__*/ jsx("img", {
|
|
92
|
-
src:
|
|
93
|
+
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-mobile.png",
|
|
93
94
|
alt: "",
|
|
94
95
|
className: "w-full h-full",
|
|
95
96
|
onClick: ()=>{
|
|
@@ -109,11 +110,12 @@ const Component = ()=>{
|
|
|
109
110
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/icon_company_outlined.svg",
|
|
110
111
|
className: "shrink-0 w-[14px] h-[14px]"
|
|
111
112
|
}),
|
|
112
|
-
/*#__PURE__*/
|
|
113
|
+
/*#__PURE__*/ jsxs("p", {
|
|
113
114
|
className: "shrink-0 min-w-[96px] m-0! text-[#646A73] text-sm",
|
|
114
|
-
children:
|
|
115
|
-
name
|
|
116
|
-
|
|
115
|
+
children: [
|
|
116
|
+
userinfo?.name,
|
|
117
|
+
"运营"
|
|
118
|
+
]
|
|
117
119
|
})
|
|
118
120
|
]
|
|
119
121
|
}),
|
|
@@ -126,7 +128,7 @@ const Component = ()=>{
|
|
|
126
128
|
}),
|
|
127
129
|
/*#__PURE__*/ jsx("p", {
|
|
128
130
|
className: "shrink-0 min-w-[163px] m-0! text-[#646A73] text-sm",
|
|
129
|
-
children:
|
|
131
|
+
children: "包含 AI 生成内容,请注意甄别"
|
|
130
132
|
})
|
|
131
133
|
]
|
|
132
134
|
})
|
|
@@ -144,14 +146,14 @@ const Component = ()=>{
|
|
|
144
146
|
setTimeout(()=>setVisible(false), 200);
|
|
145
147
|
window.localStorage?.setItem(HasClosedKey, 'true');
|
|
146
148
|
},
|
|
147
|
-
children:
|
|
149
|
+
children: "不再展示"
|
|
148
150
|
}),
|
|
149
151
|
/*#__PURE__*/ jsx("div", {
|
|
150
152
|
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]",
|
|
151
153
|
onClick: ()=>{
|
|
152
154
|
window.open('https://miaoda.feishu.cn/landing', '_blank');
|
|
153
155
|
},
|
|
154
|
-
children:
|
|
156
|
+
children: "了解更多"
|
|
155
157
|
})
|
|
156
158
|
]
|
|
157
159
|
})
|
|
@@ -184,7 +186,7 @@ const Component = ()=>{
|
|
|
184
186
|
}),
|
|
185
187
|
/*#__PURE__*/ jsx("p", {
|
|
186
188
|
className: "shrink-0 min-w-[60px] m-0! text-[#EBEBEB]",
|
|
187
|
-
children:
|
|
189
|
+
children: "由妙搭搭建"
|
|
188
190
|
})
|
|
189
191
|
]
|
|
190
192
|
})
|
|
@@ -208,7 +210,7 @@ const Component = ()=>{
|
|
|
208
210
|
className: "flex flex-col bg-[#1A1A1A]",
|
|
209
211
|
children: [
|
|
210
212
|
/*#__PURE__*/ jsx("img", {
|
|
211
|
-
src:
|
|
213
|
+
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover.png",
|
|
212
214
|
alt: "",
|
|
213
215
|
className: "w-[286px] h-[128px] cursor-pointer",
|
|
214
216
|
onClick: ()=>{
|
|
@@ -228,11 +230,12 @@ const Component = ()=>{
|
|
|
228
230
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/icon_company_outlined.svg",
|
|
229
231
|
className: "shrink-0 w-[12px] h-[12px]"
|
|
230
232
|
}),
|
|
231
|
-
/*#__PURE__*/
|
|
233
|
+
/*#__PURE__*/ jsxs("p", {
|
|
232
234
|
className: "shrink-0 min-w-[96px] m-0! text-[#a6a6a6]",
|
|
233
|
-
children:
|
|
234
|
-
name
|
|
235
|
-
|
|
235
|
+
children: [
|
|
236
|
+
userinfo?.name,
|
|
237
|
+
"运营"
|
|
238
|
+
]
|
|
236
239
|
})
|
|
237
240
|
]
|
|
238
241
|
}),
|
|
@@ -245,7 +248,7 @@ const Component = ()=>{
|
|
|
245
248
|
}),
|
|
246
249
|
/*#__PURE__*/ jsx("p", {
|
|
247
250
|
className: "shrink-0 min-w-[163px] m-0! text-[#a6a6a6]",
|
|
248
|
-
children:
|
|
251
|
+
children: "包含 AI 生成内容,请注意甄别"
|
|
249
252
|
})
|
|
250
253
|
]
|
|
251
254
|
})
|
|
@@ -263,7 +266,7 @@ const Component = ()=>{
|
|
|
263
266
|
setVisible(false);
|
|
264
267
|
window.localStorage?.setItem(HasClosedKey, 'true');
|
|
265
268
|
},
|
|
266
|
-
children:
|
|
269
|
+
children: "不再展示"
|
|
267
270
|
}),
|
|
268
271
|
/*#__PURE__*/ jsx("div", {
|
|
269
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]",
|
|
@@ -271,7 +274,7 @@ const Component = ()=>{
|
|
|
271
274
|
onClick: ()=>{
|
|
272
275
|
window.open('https://miaoda.feishu.cn/landing', '_blank');
|
|
273
276
|
},
|
|
274
|
-
children:
|
|
277
|
+
children: "了解更多"
|
|
275
278
|
})
|
|
276
279
|
]
|
|
277
280
|
})
|
|
@@ -3,7 +3,6 @@ import { useEffect } from "react";
|
|
|
3
3
|
import { logger } from "../../logger/index.js";
|
|
4
4
|
import { getHmrApi } from "../../utils/hmr-api.js";
|
|
5
5
|
import { submitPostMessage } from "../../utils/postMessage.js";
|
|
6
|
-
import { t } from "../../locales/index.js";
|
|
7
6
|
const RenderError = (props)=>{
|
|
8
7
|
const { error, resetErrorBoundary } = props;
|
|
9
8
|
useEffect(()=>{
|
|
@@ -47,7 +46,7 @@ const RenderError = (props)=>{
|
|
|
47
46
|
}),
|
|
48
47
|
/*#__PURE__*/ jsx("p", {
|
|
49
48
|
className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium",
|
|
50
|
-
children:
|
|
49
|
+
children: "页面出错了"
|
|
51
50
|
})
|
|
52
51
|
]
|
|
53
52
|
})
|
|
@@ -2,21 +2,16 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useLocation } from "react-router-dom";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { logger } from "../../logger/index.js";
|
|
5
|
-
import { t } from "../../locales/index.js";
|
|
6
5
|
const NotFound = ()=>{
|
|
7
6
|
const location = useLocation();
|
|
8
7
|
useEffect(()=>{
|
|
9
8
|
logger.log({
|
|
10
9
|
level: 'error',
|
|
11
10
|
args: [
|
|
12
|
-
|
|
13
|
-
path: location.pathname
|
|
14
|
-
})
|
|
11
|
+
`页面 ${location.pathname} 不存在`
|
|
15
12
|
],
|
|
16
13
|
meta: {
|
|
17
|
-
repairMessage:
|
|
18
|
-
path: location.pathname
|
|
19
|
-
}),
|
|
14
|
+
repairMessage: `页面 ${location.pathname} 不存在,帮我创建对应页面,并配置到"client/src/app.tsx"路由表中`,
|
|
20
15
|
noStacktrace: true,
|
|
21
16
|
stacktrace: [],
|
|
22
17
|
type: 'not-found'
|
|
@@ -35,7 +30,7 @@ const NotFound = ()=>{
|
|
|
35
30
|
}),
|
|
36
31
|
/*#__PURE__*/ jsx("p", {
|
|
37
32
|
className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium",
|
|
38
|
-
children:
|
|
33
|
+
children: "页面不存在"
|
|
39
34
|
})
|
|
40
35
|
]
|
|
41
36
|
});
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
|
|
4
|
-
const PagePlaceholder_PagePlaceholder = ({ title, description })=>{
|
|
5
|
-
const defaultTitle = t('pagePlaceholder.title');
|
|
6
|
-
const defaultDescription = t("pagePlaceholder.description");
|
|
7
|
-
return /*#__PURE__*/ jsxs("div", {
|
|
3
|
+
const PagePlaceholder = ({ title = '页面待开发', description = '页面暂未开发,请耐心等待...' })=>/*#__PURE__*/ jsxs("div", {
|
|
8
4
|
className: "flex flex-col items-center justify-center px-6 w-full h-[calc(100vh-64px)] text-center",
|
|
9
5
|
children: [
|
|
10
6
|
/*#__PURE__*/ jsx("img", {
|
|
@@ -16,14 +12,13 @@ const PagePlaceholder_PagePlaceholder = ({ title, description })=>{
|
|
|
16
12
|
}),
|
|
17
13
|
/*#__PURE__*/ jsx("div", {
|
|
18
14
|
className: "text-center text-foreground text-base font-medium mb-1 leading-6",
|
|
19
|
-
children: title
|
|
15
|
+
children: title
|
|
20
16
|
}),
|
|
21
17
|
/*#__PURE__*/ jsx("div", {
|
|
22
18
|
className: "text-center text-muted-foreground text-base leading-6 line-clamp-2 sm:max-w-[480px]",
|
|
23
|
-
children: description
|
|
19
|
+
children: description
|
|
24
20
|
})
|
|
25
21
|
]
|
|
26
22
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export { PagePlaceholder as default };
|
|
23
|
+
const components_PagePlaceholder = PagePlaceholder;
|
|
24
|
+
export { components_PagePlaceholder as default };
|
|
@@ -3,7 +3,6 @@ import { useState } from "react";
|
|
|
3
3
|
import { clsxWithTw } from "../../../utils/utils.js";
|
|
4
4
|
import { getChatAppLink } from "./utils.js";
|
|
5
5
|
import { OverflowTooltipText } from "../../ui/overflow-tooltip-text.js";
|
|
6
|
-
import { t } from "../../../locales/index.js";
|
|
7
6
|
function UserProfileUI({ user }) {
|
|
8
7
|
const [avatarError, setAvatarError] = useState(false);
|
|
9
8
|
const canShowAvatar = Boolean(user.avatar) && !avatarError;
|
|
@@ -53,7 +52,7 @@ function UserProfileUI({ user }) {
|
|
|
53
52
|
}),
|
|
54
53
|
'inactive' === user.status && /*#__PURE__*/ jsx("span", {
|
|
55
54
|
className: "shrink-0 inline-flex items-center rounded-sm bg-destructive px-2 py-0.5 text-xs font-medium text-white",
|
|
56
|
-
children:
|
|
55
|
+
children: "暂停使用"
|
|
57
56
|
})
|
|
58
57
|
]
|
|
59
58
|
}),
|
|
@@ -76,7 +75,7 @@ function UserProfileUI({ user }) {
|
|
|
76
75
|
fill: "currentColor"
|
|
77
76
|
})
|
|
78
77
|
}),
|
|
79
|
-
|
|
78
|
+
"消息"
|
|
80
79
|
]
|
|
81
80
|
})
|
|
82
81
|
}) : null
|
|
@@ -91,7 +90,7 @@ function UserProfileUI({ user }) {
|
|
|
91
90
|
children: [
|
|
92
91
|
/*#__PURE__*/ jsx("span", {
|
|
93
92
|
className: "min-w-[74px] text-sm text-muted-foreground",
|
|
94
|
-
children:
|
|
93
|
+
children: "部门"
|
|
95
94
|
}),
|
|
96
95
|
/*#__PURE__*/ jsx("span", {
|
|
97
96
|
className: clsxWithTw('flex-1 break-all text-sm text-foreground', {
|
|
@@ -106,7 +105,7 @@ function UserProfileUI({ user }) {
|
|
|
106
105
|
children: [
|
|
107
106
|
/*#__PURE__*/ jsx("span", {
|
|
108
107
|
className: "min-w-[74px] text-sm text-muted-foreground",
|
|
109
|
-
children:
|
|
108
|
+
children: "邮箱"
|
|
110
109
|
}),
|
|
111
110
|
user.email ? /*#__PURE__*/ jsx("a", {
|
|
112
111
|
href: `mailto:${user.email}`,
|
|
@@ -7,9 +7,7 @@ import { MultipleSelectionTags } from "./MultipleSelectionTags.js";
|
|
|
7
7
|
import { SingleSelectionPreview } from "./SingleSelectionPreview.js";
|
|
8
8
|
import { ActionButtons } from "./ActionButtons.js";
|
|
9
9
|
import { Dropdown } from "./Dropdown.js";
|
|
10
|
-
|
|
11
|
-
const UserSelectUI = ({ mode = 'single', value, onChange, placeholder, disabled = false, allowClear = true, onSearch, loading = false, options = [] })=>{
|
|
12
|
-
const defaultPlaceholder = t('userSelect.placeholder');
|
|
10
|
+
const UserSelectUI = ({ mode = 'single', value, onChange, placeholder = '请选择用户', disabled = false, allowClear = true, onSearch, loading = false, options = [] })=>{
|
|
13
11
|
const [isOpen, setIsOpen] = useState(false);
|
|
14
12
|
const [searchText, setSearchText] = useState('');
|
|
15
13
|
const [searchResults, setSearchResults] = useState([]);
|
|
@@ -137,7 +135,7 @@ const UserSelectUI = ({ mode = 'single', value, onChange, placeholder, disabled
|
|
|
137
135
|
const singleSelectedUser = 'single' === mode && hasSelection ? selectedUsers[0] : void 0;
|
|
138
136
|
const showSingleSelection = !!singleSelectedUser && 0 === searchText.length;
|
|
139
137
|
const canClear = allowClear && hasSelection && !disabled;
|
|
140
|
-
const inputPlaceholder = hasSelection ? '' : placeholder
|
|
138
|
+
const inputPlaceholder = hasSelection ? '' : placeholder;
|
|
141
139
|
const focusInputAtStart = ()=>{
|
|
142
140
|
const input = inputRef.current;
|
|
143
141
|
if (!input) return;
|
|
@@ -4,15 +4,11 @@ import { createRoot } from "react-dom/client";
|
|
|
4
4
|
import { Content, Description, Overlay, Portal, Root, Title } from "@radix-ui/react-dialog";
|
|
5
5
|
import { Button } from "./button.js";
|
|
6
6
|
import { clsxWithTw } from "../../utils/utils.js";
|
|
7
|
-
import { t } from "../../locales/index.js";
|
|
8
7
|
function showConfirm(options) {
|
|
9
8
|
const opts = 'string' == typeof options ? {
|
|
10
9
|
message: options
|
|
11
10
|
} : options;
|
|
12
|
-
const { title, message, confirmText, cancelText, variant = 'default' } = opts;
|
|
13
|
-
const defaultTitle = t('confirm.title');
|
|
14
|
-
const defaultConfirmText = t('confirm.confirmText');
|
|
15
|
-
const defaultCancelText = t('confirm.cancelText');
|
|
11
|
+
const { title = '提示', message, confirmText = '确认', cancelText = '取消', variant = 'default' } = opts;
|
|
16
12
|
return new Promise((resolve)=>{
|
|
17
13
|
const container = document.createElement('div');
|
|
18
14
|
document.body.appendChild(container);
|
|
@@ -30,10 +26,10 @@ function showConfirm(options) {
|
|
|
30
26
|
resolve(false);
|
|
31
27
|
}
|
|
32
28
|
root.render(/*#__PURE__*/ jsx(ConfirmDialog, {
|
|
33
|
-
title: title
|
|
29
|
+
title: title,
|
|
34
30
|
message: message,
|
|
35
|
-
confirmText: confirmText
|
|
36
|
-
cancelText: cancelText
|
|
31
|
+
confirmText: confirmText,
|
|
32
|
+
cancelText: cancelText,
|
|
37
33
|
variant: variant,
|
|
38
34
|
onConfirm: handleConfirm,
|
|
39
35
|
onCancel: handleCancel
|
package/lib/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import { getAppId } from "./utils/getAppId.js";
|
|
|
4
4
|
import { isNewPathEnabled } from "./utils/apiPath.js";
|
|
5
5
|
import { logger } from "./logger/index.js";
|
|
6
6
|
import { showToast } from "./components/ui/toast.js";
|
|
7
|
-
import { t } from "./locales/index.js";
|
|
8
7
|
import { version } from "../package.json";
|
|
9
8
|
import { showConfirm } from "./components/ui/confirm.js";
|
|
10
9
|
const _appId = getAppId();
|
|
@@ -21,7 +20,7 @@ const capabilityClient = createClient({
|
|
|
21
20
|
},
|
|
22
21
|
logger: logger,
|
|
23
22
|
onRateLimitError: ()=>{
|
|
24
|
-
showToast(
|
|
23
|
+
showToast('应用额度已耗尽,请联系应用开发者');
|
|
25
24
|
}
|
|
26
25
|
});
|
|
27
26
|
const src = {
|
|
@@ -24,24 +24,10 @@ async function getAppPublished() {
|
|
|
24
24
|
console.error('Error fetching published app info:', error);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function getPreloadedInfo() {
|
|
28
|
-
try {
|
|
29
|
-
const platformData = window.__platform__?.appPublished;
|
|
30
|
-
if (platformData && 'object' == typeof platformData) return platformData;
|
|
31
|
-
} catch {}
|
|
32
|
-
}
|
|
33
27
|
let initialInfo;
|
|
34
28
|
let pendingPromise = null;
|
|
35
29
|
function getInitialInfo(refresh = false) {
|
|
36
30
|
if (initialInfo && !refresh) return Promise.resolve(initialInfo);
|
|
37
|
-
if (!initialInfo && !refresh) {
|
|
38
|
-
const preloaded = getPreloadedInfo();
|
|
39
|
-
if (preloaded) {
|
|
40
|
-
initialInfo = preloaded;
|
|
41
|
-
if (initialInfo) window._bucket_id = initialInfo.app_runtime_extra?.bucket?.default_bucket_id;
|
|
42
|
-
return Promise.resolve(initialInfo);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
31
|
if (pendingPromise && !refresh) return pendingPromise;
|
|
46
32
|
pendingPromise = getAppPublished().then((info)=>{
|
|
47
33
|
initialInfo = info;
|
package/lib/utils/postMessage.js
CHANGED
|
@@ -1,37 +1,9 @@
|
|
|
1
|
-
const PARENT_ORIGIN_KEY = '__parentOrigin';
|
|
2
|
-
function getParentOriginFromParams() {
|
|
3
|
-
try {
|
|
4
|
-
const params = new URLSearchParams(window.location.search);
|
|
5
|
-
const origin = params.get(PARENT_ORIGIN_KEY);
|
|
6
|
-
if (origin) {
|
|
7
|
-
sessionStorage.setItem(PARENT_ORIGIN_KEY, origin);
|
|
8
|
-
return origin;
|
|
9
|
-
}
|
|
10
|
-
} catch {}
|
|
11
|
-
try {
|
|
12
|
-
return sessionStorage.getItem(PARENT_ORIGIN_KEY) || void 0;
|
|
13
|
-
} catch {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function getLegacyParentOrigin() {
|
|
18
|
-
const { origin } = window.location;
|
|
19
|
-
if (origin.includes('force.feishuapp.net')) return 'https://force.feishu.cn';
|
|
20
|
-
if (origin.includes('force-pre.feishuapp.net')) return 'https://force.feishu-pre.cn';
|
|
21
|
-
if (origin.includes('force.byted.org')) return 'https://force.feishu-boe.cn';
|
|
22
|
-
if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) return 'https://miaoda.feishu.cn';
|
|
23
|
-
if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) return 'https://miaoda.feishu-pre.cn';
|
|
24
|
-
return 'https://miaoda.feishu-boe.cn';
|
|
25
|
-
}
|
|
26
1
|
function resolveParentOrigin() {
|
|
27
|
-
|
|
28
|
-
if (paramOrigin) return paramOrigin;
|
|
29
|
-
return process.env?.FORCE_FRAMEWORK_DOMAIN_MAIN ?? getLegacyParentOrigin();
|
|
2
|
+
return '*';
|
|
30
3
|
}
|
|
31
4
|
function submitPostMessage(message, targetOrigin) {
|
|
32
5
|
try {
|
|
33
|
-
const
|
|
34
|
-
const origin = targetOrigin ?? parentOrigin;
|
|
6
|
+
const origin = '*';
|
|
35
7
|
if (!origin) return;
|
|
36
8
|
window.parent.postMessage(message, origin);
|
|
37
9
|
} catch (e) {
|
package/package.json
CHANGED
package/lib/locales/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 获取当前语言环境下的翻译文案。
|
|
3
|
-
*
|
|
4
|
-
* 支持 `{key}` 形式的变量替换:
|
|
5
|
-
* ```ts
|
|
6
|
-
* t('safety.tenant.operated', { name: '字节' })
|
|
7
|
-
* // zh → "字节运营"
|
|
8
|
-
* // en → "Operated by 字节"
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* 如果 key 不存在,fallback 到中文;中文也没有则返回 key 本身。
|
|
12
|
-
*/
|
|
13
|
-
export declare function t(key: string, params?: Record<string, string>): string;
|
|
14
|
-
export { getLocale } from '../utils/locale';
|
|
15
|
-
export type { Locale } from '../utils/locale';
|
package/lib/locales/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import messages from "./messages.js";
|
|
2
|
-
import { getLocale } from "../utils/locale.js";
|
|
3
|
-
function t(key, params) {
|
|
4
|
-
const locale = getLocale();
|
|
5
|
-
const entry = messages[key];
|
|
6
|
-
let text = entry?.[locale] ?? entry?.zh ?? key;
|
|
7
|
-
if (params) for (const [k, v] of Object.entries(params))text = text.replace(`{${k}}`, v);
|
|
8
|
-
return text;
|
|
9
|
-
}
|
|
10
|
-
export { getLocale, t };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 中英文文案源(统一管理)。
|
|
3
|
-
*
|
|
4
|
-
* 每条文案同时包含 zh 和 en,方便对照和维护。
|
|
5
|
-
* Key 规则:`{组件}.{区域}.{标识}`
|
|
6
|
-
* 文案来源:https://bytedance.larkoffice.com/wiki/BJCQwv9auiP9erkudMfcVIIGnRg
|
|
7
|
-
*/
|
|
8
|
-
declare const messages: Record<string, {
|
|
9
|
-
zh: string;
|
|
10
|
-
en: string;
|
|
11
|
-
}>;
|
|
12
|
-
export default messages;
|
package/lib/locales/messages.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const messages_messages = {
|
|
2
|
-
'safety.badge.label': {
|
|
3
|
-
zh: '妙搭',
|
|
4
|
-
en: 'Spark'
|
|
5
|
-
},
|
|
6
|
-
'safety.badge.builtWith': {
|
|
7
|
-
zh: '由妙搭搭建',
|
|
8
|
-
en: 'Built with Spark'
|
|
9
|
-
},
|
|
10
|
-
'safety.ai.disclaimer': {
|
|
11
|
-
zh: '包含 AI 生成内容,请注意甄别',
|
|
12
|
-
en: 'AI-generated content. Use with care.'
|
|
13
|
-
},
|
|
14
|
-
'safety.tenant.operated': {
|
|
15
|
-
zh: '{name}运营',
|
|
16
|
-
en: 'Operated by {name}'
|
|
17
|
-
},
|
|
18
|
-
'safety.button.dontShowAgain': {
|
|
19
|
-
zh: '不再展示',
|
|
20
|
-
en: "Don't show again"
|
|
21
|
-
},
|
|
22
|
-
'safety.button.learnMore': {
|
|
23
|
-
zh: '了解更多',
|
|
24
|
-
en: 'Learn more'
|
|
25
|
-
},
|
|
26
|
-
'safety.cover.pc': {
|
|
27
|
-
zh: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover.png',
|
|
28
|
-
en: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-pcen.png'
|
|
29
|
-
},
|
|
30
|
-
'safety.cover.mobile': {
|
|
31
|
-
zh: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-mobile.png',
|
|
32
|
-
en: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-weben.png'
|
|
33
|
-
},
|
|
34
|
-
'index.rateLimitError': {
|
|
35
|
-
zh: '应用额度已耗尽,请联系应用开发者',
|
|
36
|
-
en: 'Application quota exhausted, please contact the app developer'
|
|
37
|
-
},
|
|
38
|
-
'theme.themeColors.title': {
|
|
39
|
-
zh: '主题色',
|
|
40
|
-
en: 'Theme Color'
|
|
41
|
-
},
|
|
42
|
-
'theme.themeRadius.title': {
|
|
43
|
-
zh: '圆角',
|
|
44
|
-
en: 'Border Radius'
|
|
45
|
-
},
|
|
46
|
-
'theme.themeSpaces.title': {
|
|
47
|
-
zh: '间距',
|
|
48
|
-
en: 'Spacing'
|
|
49
|
-
},
|
|
50
|
-
'errorRender.title': {
|
|
51
|
-
zh: '页面出错了',
|
|
52
|
-
en: 'Something went wrong'
|
|
53
|
-
},
|
|
54
|
-
'notFound.pageNotExist': {
|
|
55
|
-
zh: '页面不存在',
|
|
56
|
-
en: 'Page not found'
|
|
57
|
-
},
|
|
58
|
-
'notFound.logger.pageNotExist': {
|
|
59
|
-
zh: '页面 {path} 不存在',
|
|
60
|
-
en: 'Page {path} does not exist'
|
|
61
|
-
},
|
|
62
|
-
'notFound.logger.repairMessage': {
|
|
63
|
-
zh: '页面 {path} 不存在,帮我创建对应页面,并配置到"client/src/app.tsx"路由表中',
|
|
64
|
-
en: 'Page {path} does not exist, help me create the corresponding page and configure it in the "client/src/app.tsx" routing table'
|
|
65
|
-
},
|
|
66
|
-
'pagePlaceholder.title': {
|
|
67
|
-
zh: '页面待开发',
|
|
68
|
-
en: 'Page coming soon'
|
|
69
|
-
},
|
|
70
|
-
"pagePlaceholder.description": {
|
|
71
|
-
zh: '页面暂未开发,请耐心等待...',
|
|
72
|
-
en: 'This page is under development, please wait...'
|
|
73
|
-
},
|
|
74
|
-
'confirm.title': {
|
|
75
|
-
zh: '提示',
|
|
76
|
-
en: 'Confirm'
|
|
77
|
-
},
|
|
78
|
-
'confirm.confirmText': {
|
|
79
|
-
zh: '确认',
|
|
80
|
-
en: 'Confirm'
|
|
81
|
-
},
|
|
82
|
-
'confirm.cancelText': {
|
|
83
|
-
zh: '取消',
|
|
84
|
-
en: 'Cancel'
|
|
85
|
-
},
|
|
86
|
-
'userSelect.placeholder': {
|
|
87
|
-
zh: '请选择用户',
|
|
88
|
-
en: 'Select user'
|
|
89
|
-
},
|
|
90
|
-
'userProfile.status.inactive': {
|
|
91
|
-
zh: '暂停使用',
|
|
92
|
-
en: 'Inactive'
|
|
93
|
-
},
|
|
94
|
-
'userProfile.button.message': {
|
|
95
|
-
zh: '消息',
|
|
96
|
-
en: 'Message'
|
|
97
|
-
},
|
|
98
|
-
'userProfile.label.department': {
|
|
99
|
-
zh: '部门',
|
|
100
|
-
en: 'Department'
|
|
101
|
-
},
|
|
102
|
-
'userProfile.label.email': {
|
|
103
|
-
zh: '邮箱',
|
|
104
|
-
en: 'Email'
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const messages = messages_messages;
|
|
108
|
-
export { messages as default };
|
package/lib/utils/locale.d.ts
DELETED