@lark-apaas/client-toolkit 1.2.28-alpha.75 → 1.2.28-alpha.77
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 +19 -3
- package/lib/components/ErrorRender/index.js +2 -1
- package/lib/components/NotFoundRender/index.js +8 -3
- package/lib/components/PagePlaceholder/index.js +10 -5
- package/lib/components/User/UserProfile/UserProfileUI.js +5 -4
- package/lib/components/User/UserSelectUI/UserSelectUI.js +4 -2
- package/lib/components/ui/confirm.js +8 -4
- package/lib/index.js +2 -1
- package/lib/locales/messages.js +72 -0
- package/package.json +1 -1
|
@@ -12,10 +12,26 @@ const Component = ()=>{
|
|
|
12
12
|
const [open, setOpen] = useState(false);
|
|
13
13
|
const isMobile = useIsMobile();
|
|
14
14
|
const timeoutRef = useRef(null);
|
|
15
|
-
const platformData = window.__platform__
|
|
16
|
-
const
|
|
17
|
-
const isInternetVisible = platformData.isInternetVisible ?? false;
|
|
15
|
+
const platformData = window.__platform_data__ || window.__platform__ || {};
|
|
16
|
+
const appId = getAppId() || platformData.appId;
|
|
18
17
|
const showBadge = false !== platformData.showBadge;
|
|
18
|
+
const [tenantName, setTenantName] = useState('');
|
|
19
|
+
const [isInternetVisible, setIsInternetVisible] = useState(false);
|
|
20
|
+
useEffect(()=>{
|
|
21
|
+
if (!showBadge || !visible) return;
|
|
22
|
+
fetch(`/spark/b/${appId}/tenant_info`).then((res)=>res.json()).then((data)=>{
|
|
23
|
+
if (data?.status_code === '0' || data?.code === 0) {
|
|
24
|
+
setTenantName(data?.data?.tenant_info?.name || '');
|
|
25
|
+
setIsInternetVisible(data?.data?.is_internet_visible || false);
|
|
26
|
+
}
|
|
27
|
+
}).catch((e)=>{
|
|
28
|
+
console.warn('Failed to fetch tenant info:', e);
|
|
29
|
+
});
|
|
30
|
+
}, [
|
|
31
|
+
appId,
|
|
32
|
+
showBadge,
|
|
33
|
+
visible
|
|
34
|
+
]);
|
|
19
35
|
useEffect(()=>{
|
|
20
36
|
if (isMobile) {
|
|
21
37
|
const link = document.createElement('link');
|
|
@@ -3,6 +3,7 @@ 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";
|
|
6
7
|
const RenderError = (props)=>{
|
|
7
8
|
const { error, resetErrorBoundary } = props;
|
|
8
9
|
useEffect(()=>{
|
|
@@ -46,7 +47,7 @@ const RenderError = (props)=>{
|
|
|
46
47
|
}),
|
|
47
48
|
/*#__PURE__*/ jsx("p", {
|
|
48
49
|
className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium",
|
|
49
|
-
children:
|
|
50
|
+
children: t('errorRender.title')
|
|
50
51
|
})
|
|
51
52
|
]
|
|
52
53
|
})
|
|
@@ -2,16 +2,21 @@ 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";
|
|
5
6
|
const NotFound = ()=>{
|
|
6
7
|
const location = useLocation();
|
|
7
8
|
useEffect(()=>{
|
|
8
9
|
logger.log({
|
|
9
10
|
level: 'error',
|
|
10
11
|
args: [
|
|
11
|
-
|
|
12
|
+
t('notFound.logger.pageNotExist', {
|
|
13
|
+
path: location.pathname
|
|
14
|
+
})
|
|
12
15
|
],
|
|
13
16
|
meta: {
|
|
14
|
-
repairMessage:
|
|
17
|
+
repairMessage: t('notFound.logger.repairMessage', {
|
|
18
|
+
path: location.pathname
|
|
19
|
+
}),
|
|
15
20
|
noStacktrace: true,
|
|
16
21
|
stacktrace: [],
|
|
17
22
|
type: 'not-found'
|
|
@@ -30,7 +35,7 @@ const NotFound = ()=>{
|
|
|
30
35
|
}),
|
|
31
36
|
/*#__PURE__*/ jsx("p", {
|
|
32
37
|
className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium",
|
|
33
|
-
children:
|
|
38
|
+
children: t('notFound.pageNotExist')
|
|
34
39
|
})
|
|
35
40
|
]
|
|
36
41
|
});
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
|
|
3
|
+
import { t } from "../../locales/index.js";
|
|
4
|
+
const PagePlaceholder_PagePlaceholder = ({ title, description })=>{
|
|
5
|
+
const defaultTitle = t('pagePlaceholder.title');
|
|
6
|
+
const defaultDescription = t("pagePlaceholder.description");
|
|
7
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
4
8
|
className: "flex flex-col items-center justify-center px-6 w-full h-[calc(100vh-64px)] text-center",
|
|
5
9
|
children: [
|
|
6
10
|
/*#__PURE__*/ jsx("img", {
|
|
@@ -12,13 +16,14 @@ const PagePlaceholder = ({ title = '页面待开发', description = '页面暂
|
|
|
12
16
|
}),
|
|
13
17
|
/*#__PURE__*/ jsx("div", {
|
|
14
18
|
className: "text-center text-foreground text-base font-medium mb-1 leading-6",
|
|
15
|
-
children: title
|
|
19
|
+
children: title ?? defaultTitle
|
|
16
20
|
}),
|
|
17
21
|
/*#__PURE__*/ jsx("div", {
|
|
18
22
|
className: "text-center text-muted-foreground text-base leading-6 line-clamp-2 sm:max-w-[480px]",
|
|
19
|
-
children: description
|
|
23
|
+
children: description ?? defaultDescription
|
|
20
24
|
})
|
|
21
25
|
]
|
|
22
26
|
});
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
};
|
|
28
|
+
const PagePlaceholder = PagePlaceholder_PagePlaceholder;
|
|
29
|
+
export { PagePlaceholder as default };
|
|
@@ -3,6 +3,7 @@ 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";
|
|
6
7
|
function UserProfileUI({ user }) {
|
|
7
8
|
const [avatarError, setAvatarError] = useState(false);
|
|
8
9
|
const canShowAvatar = Boolean(user.avatar) && !avatarError;
|
|
@@ -52,7 +53,7 @@ function UserProfileUI({ user }) {
|
|
|
52
53
|
}),
|
|
53
54
|
'inactive' === user.status && /*#__PURE__*/ jsx("span", {
|
|
54
55
|
className: "shrink-0 inline-flex items-center rounded-sm bg-destructive px-2 py-0.5 text-xs font-medium text-white",
|
|
55
|
-
children:
|
|
56
|
+
children: t('userProfile.status.inactive')
|
|
56
57
|
})
|
|
57
58
|
]
|
|
58
59
|
}),
|
|
@@ -75,7 +76,7 @@ function UserProfileUI({ user }) {
|
|
|
75
76
|
fill: "currentColor"
|
|
76
77
|
})
|
|
77
78
|
}),
|
|
78
|
-
|
|
79
|
+
t('userProfile.button.message')
|
|
79
80
|
]
|
|
80
81
|
})
|
|
81
82
|
}) : null
|
|
@@ -90,7 +91,7 @@ function UserProfileUI({ user }) {
|
|
|
90
91
|
children: [
|
|
91
92
|
/*#__PURE__*/ jsx("span", {
|
|
92
93
|
className: "min-w-[74px] text-sm text-muted-foreground",
|
|
93
|
-
children:
|
|
94
|
+
children: t('userProfile.label.department')
|
|
94
95
|
}),
|
|
95
96
|
/*#__PURE__*/ jsx("span", {
|
|
96
97
|
className: clsxWithTw('flex-1 break-all text-sm text-foreground', {
|
|
@@ -105,7 +106,7 @@ function UserProfileUI({ user }) {
|
|
|
105
106
|
children: [
|
|
106
107
|
/*#__PURE__*/ jsx("span", {
|
|
107
108
|
className: "min-w-[74px] text-sm text-muted-foreground",
|
|
108
|
-
children:
|
|
109
|
+
children: t('userProfile.label.email')
|
|
109
110
|
}),
|
|
110
111
|
user.email ? /*#__PURE__*/ jsx("a", {
|
|
111
112
|
href: `mailto:${user.email}`,
|
|
@@ -7,7 +7,9 @@ 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
|
-
|
|
10
|
+
import { t } from "../../../locales/index.js";
|
|
11
|
+
const UserSelectUI = ({ mode = 'single', value, onChange, placeholder, disabled = false, allowClear = true, onSearch, loading = false, options = [] })=>{
|
|
12
|
+
const defaultPlaceholder = t('userSelect.placeholder');
|
|
11
13
|
const [isOpen, setIsOpen] = useState(false);
|
|
12
14
|
const [searchText, setSearchText] = useState('');
|
|
13
15
|
const [searchResults, setSearchResults] = useState([]);
|
|
@@ -135,7 +137,7 @@ const UserSelectUI = ({ mode = 'single', value, onChange, placeholder = '请选
|
|
|
135
137
|
const singleSelectedUser = 'single' === mode && hasSelection ? selectedUsers[0] : void 0;
|
|
136
138
|
const showSingleSelection = !!singleSelectedUser && 0 === searchText.length;
|
|
137
139
|
const canClear = allowClear && hasSelection && !disabled;
|
|
138
|
-
const inputPlaceholder = hasSelection ? '' : placeholder;
|
|
140
|
+
const inputPlaceholder = hasSelection ? '' : placeholder ?? defaultPlaceholder;
|
|
139
141
|
const focusInputAtStart = ()=>{
|
|
140
142
|
const input = inputRef.current;
|
|
141
143
|
if (!input) return;
|
|
@@ -4,11 +4,15 @@ 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";
|
|
7
8
|
function showConfirm(options) {
|
|
8
9
|
const opts = 'string' == typeof options ? {
|
|
9
10
|
message: options
|
|
10
11
|
} : options;
|
|
11
|
-
const { title
|
|
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');
|
|
12
16
|
return new Promise((resolve)=>{
|
|
13
17
|
const container = document.createElement('div');
|
|
14
18
|
document.body.appendChild(container);
|
|
@@ -26,10 +30,10 @@ function showConfirm(options) {
|
|
|
26
30
|
resolve(false);
|
|
27
31
|
}
|
|
28
32
|
root.render(/*#__PURE__*/ jsx(ConfirmDialog, {
|
|
29
|
-
title: title,
|
|
33
|
+
title: title ?? defaultTitle,
|
|
30
34
|
message: message,
|
|
31
|
-
confirmText: confirmText,
|
|
32
|
-
cancelText: cancelText,
|
|
35
|
+
confirmText: confirmText ?? defaultConfirmText,
|
|
36
|
+
cancelText: cancelText ?? defaultCancelText,
|
|
33
37
|
variant: variant,
|
|
34
38
|
onConfirm: handleConfirm,
|
|
35
39
|
onCancel: handleCancel
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,7 @@ 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";
|
|
7
8
|
import { version } from "../package.json";
|
|
8
9
|
import { showConfirm } from "./components/ui/confirm.js";
|
|
9
10
|
const _appId = getAppId();
|
|
@@ -20,7 +21,7 @@ const capabilityClient = createClient({
|
|
|
20
21
|
},
|
|
21
22
|
logger: logger,
|
|
22
23
|
onRateLimitError: ()=>{
|
|
23
|
-
showToast('
|
|
24
|
+
showToast(t('index.rateLimitError'));
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
const src = {
|
package/lib/locales/messages.js
CHANGED
|
@@ -30,6 +30,78 @@ const messages_messages = {
|
|
|
30
30
|
'safety.cover.mobile': {
|
|
31
31
|
zh: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-mobile.png',
|
|
32
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'
|
|
33
105
|
}
|
|
34
106
|
};
|
|
35
107
|
const messages = messages_messages;
|