@lark-apaas/client-toolkit 1.2.86-alpha.20261123035123 → 1.2.86-beta.0

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.
Files changed (62) hide show
  1. package/README.md +1 -30
  2. package/lib/apis/components/UniversalLink.js +1 -2
  3. package/lib/apis/constants/img-resources/avatar.d.ts +11 -11
  4. package/lib/apis/constants/img-resources/avatar.js +11 -12
  5. package/lib/apis/constants/img-resources/banner.d.ts +24 -24
  6. package/lib/apis/constants/img-resources/banner.js +24 -25
  7. package/lib/apis/constants/img-resources/cover.d.ts +36 -36
  8. package/lib/apis/constants/img-resources/cover.js +36 -37
  9. package/lib/apis/dataloom.d.ts +2 -0
  10. package/lib/apis/dataloom.js +2 -1
  11. package/lib/components/AppContainer/Watermark.js +36 -38
  12. package/lib/components/AppContainer/__test__/Watermark.test.js +7 -33
  13. package/lib/components/AppContainer/doubao-watermark-asset.d.ts +3 -4
  14. package/lib/components/AppContainer/doubao-watermark-asset.js +4 -5
  15. package/lib/components/AppContainer/index.js +2 -11
  16. package/lib/components/AppContainer/utils/tea.js +2 -5
  17. package/lib/components/ErrorRender/index.js +1 -2
  18. package/lib/components/NotFoundRender/index.js +3 -4
  19. package/lib/components/PagePlaceholder/index.js +1 -2
  20. package/lib/components/User/UserProfile/UserProfileUI.js +3 -5
  21. package/lib/components/User/UserProfile/utils.d.ts +1 -2
  22. package/lib/components/User/UserProfile/utils.js +8 -12
  23. package/lib/components/User/UserSelectUI/Dropdown.js +2 -3
  24. package/lib/components/User/UserSelectUI/MultipleSelectionTags.js +1 -4
  25. package/lib/components/User/UserWithAvatar.js +1 -2
  26. package/lib/components/theme/constants.js +11 -19
  27. package/lib/hooks/useCurrentUserProfile.js +2 -4
  28. package/lib/hooks/useLogout.js +2 -3
  29. package/lib/index.d.ts +2 -0
  30. package/lib/index.js +2 -1
  31. package/lib/integrations/__test__/base-storage.test.d.ts +1 -0
  32. package/lib/integrations/__test__/base-storage.test.js +74 -0
  33. package/lib/integrations/services/UserProfileService.d.ts +1 -1
  34. package/lib/integrations/services/UserProfileService.js +2 -2
  35. package/lib/locales/__test__/messages.test.js +4 -4
  36. package/lib/locales/index.d.ts +2 -9
  37. package/lib/locales/index.js +6 -9
  38. package/lib/locales/messages.d.ts +5 -208
  39. package/lib/locales/messages.js +52 -156
  40. package/lib/utils/axiosConfig.js +19 -22
  41. package/lib/utils/copyToClipboard.js +1 -2
  42. package/lib/utils/getAxiosForBackend.js +1 -2
  43. package/lib/utils/getParentOrigin.d.ts +0 -1
  44. package/lib/utils/getParentOrigin.js +14 -7
  45. package/lib/utils/locale.d.ts +3 -2
  46. package/lib/utils/locale.js +38 -2
  47. package/lib/utils/postMessage.d.ts +1 -5
  48. package/lib/utils/postMessage.js +20 -2
  49. package/package.json +5 -8
  50. package/README.en-US.md +0 -105
  51. package/lib/apis/utils/createI18nForRuntime.d.ts +0 -6
  52. package/lib/apis/utils/createI18nForRuntime.js +0 -2
  53. package/lib/apis/utils/getLarkJssdkConfig.d.ts +0 -2
  54. package/lib/apis/utils/getLarkJssdkConfig.js +0 -2
  55. package/lib/apis/utils/getLocale.d.ts +0 -3
  56. package/lib/apis/utils/getLocale.js +0 -2
  57. package/lib/locales/dev-messages.d.ts +0 -9
  58. package/lib/locales/dev-messages.js +0 -8
  59. package/lib/utils/i18nText.d.ts +0 -4
  60. package/lib/utils/i18nText.js +0 -10
  61. package/lib/utils/larkJssdk.d.ts +0 -13
  62. package/lib/utils/larkJssdk.js +0 -11
@@ -1,29 +1,14 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
2
  import react from "react";
3
3
  import { renderToStaticMarkup } from "react-dom/server";
4
- import { render, waitFor } from "@testing-library/react";
5
4
  import Watermark, { BrandLogo, CloseIcon, FeedbackIcon, MenuCard, Pill, openReport } from "../Watermark.js";
6
5
  import { DOUBAO_LOGO_SRC, MIAODA_LOGO_SRC } from "../doubao-watermark-asset.js";
7
- vi.mock('../../../utils/getInitialInfo', ()=>({
8
- getInitialInfo: ()=>Promise.resolve({})
9
- }));
10
- const LOCALE_KEY = 'miaoda:preview-locale';
11
- const html = async ()=>{
12
- const { container, unmount } = render(/*#__PURE__*/ react.createElement(Watermark));
13
- await waitFor(()=>expect(container.innerHTML).not.toBe(''));
14
- const out = container.innerHTML;
15
- unmount();
16
- return out;
17
- };
6
+ const html = ()=>renderToStaticMarkup(/*#__PURE__*/ react.createElement(Watermark));
18
7
  const setViewportWidth = (w)=>Object.defineProperty(window, 'innerWidth', {
19
8
  value: w,
20
9
  configurable: true
21
10
  });
22
- beforeEach(()=>{
23
- window.localStorage.setItem(LOCALE_KEY, 'zh_CN');
24
- });
25
11
  afterEach(()=>{
26
- window.localStorage.clear();
27
12
  vi.unstubAllEnvs();
28
13
  vi.restoreAllMocks();
29
14
  delete globalThis.ENVIRONMENT;
@@ -31,17 +16,17 @@ afterEach(()=>{
31
16
  setViewportWidth(1024);
32
17
  });
33
18
  describe('Watermark(水印·变体拆分后)', ()=>{
34
- it('默认(非豆包来源)渲染妙搭变体药丸', async ()=>{
35
- const out = await html();
19
+ it('默认(非豆包来源)渲染妙搭变体药丸', ()=>{
20
+ const out = html();
36
21
  expect(out).toContain('data-custom-element="miaoda-watermark"');
37
22
  expect(out).toContain('妙搭生成');
38
23
  expect(out).toContain(MIAODA_LOGO_SRC);
39
24
  expect(out).not.toContain('aria-label="关闭"');
40
25
  expect(out).not.toContain('投诉与举报');
41
26
  });
42
- it('移动端视口(<768)时展示移动端药丸', async ()=>{
27
+ it('移动端视口(<768)时展示移动端药丸', ()=>{
43
28
  setViewportWidth(375);
44
- const out = await html();
29
+ const out = html();
45
30
  expect(out).toContain('data-custom-element="miaoda-watermark-mobile"');
46
31
  expect(out).toContain(MIAODA_LOGO_SRC);
47
32
  expect(out).toContain('妙搭生成');
@@ -123,23 +108,12 @@ describe('Watermark(水印·变体拆分后)', ()=>{
123
108
  openReport();
124
109
  expect(openSpy).toHaveBeenCalledTimes(1);
125
110
  const [url, target, features] = openSpy.mock.calls[0];
126
- expect(String(url)).toContain('https://tns.feishu-boe.cn/cust/lark_report/');
111
+ expect(String(url)).toContain('tns.feishu-boe.cn/cust/lark_report/');
127
112
  expect(String(url)).toContain(encodeURIComponent('miaoda_app_report'));
128
113
  expect(String(url)).toContain('app_abc');
129
- expect(String(url)).toMatch(/&lang=zh-CN$/);
130
114
  expect(target).toBe('_blank');
131
115
  expect(features).toBe('noopener,noreferrer');
132
116
  });
133
- it('英文环境下 lang 参数为 en-US', ()=>{
134
- const openSpy = vi.spyOn(window, 'open').mockReturnValue(null);
135
- window.localStorage.setItem(LOCALE_KEY, 'en_US');
136
- window.appId = 'app_abc';
137
- globalThis.ENVIRONMENT = 'online';
138
- openReport();
139
- const [url] = openSpy.mock.calls[0];
140
- expect(String(url)).toContain('https://tns.feishu.cn/cust/lark_report/');
141
- expect(String(url)).toMatch(/&lang=en-US$/);
142
- });
143
117
  it('无 appId 时不跳转', ()=>{
144
118
  const openSpy = vi.spyOn(window, 'open').mockReturnValue(null);
145
119
  globalThis.ENVIRONMENT = 'online';
@@ -1,4 +1,3 @@
1
- export declare const DOUBAO_LOGO_SRC: string;
2
- /** 豆包品牌字图取自 doubaoConf,海外接 Dola 时下发 Dola 的图 */
3
- export declare const DOUBAO_BRAND_TEXT_SRC: string;
4
- export declare const MIAODA_LOGO_SRC: string;
1
+ export declare const DOUBAO_LOGO_SRC = "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui/doubao.svg";
2
+ export declare const DOUBAO_BRAND_TEXT_SRC = "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui/Doubao_watermark_aigc.svg";
3
+ export declare const MIAODA_LOGO_SRC = "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodalogo.svg";
@@ -1,6 +1,5 @@
1
- import { getStaticUrl, readSettings } from "@lark-apaas/miaoda-common-settings";
2
- const ASSET_DIR = 'obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp';
3
- const DOUBAO_LOGO_SRC = getStaticUrl(`${ASSET_DIR}/miaoda-ui/doubao.svg`);
4
- const DOUBAO_BRAND_TEXT_SRC = readSettings('doubaoConf.brandImage');
5
- const MIAODA_LOGO_SRC = getStaticUrl(`${ASSET_DIR}/logo/miaodalogo.svg`);
1
+ const CDN = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp';
2
+ const DOUBAO_LOGO_SRC = `${CDN}/miaoda-ui/doubao.svg`;
3
+ const DOUBAO_BRAND_TEXT_SRC = `${CDN}/miaoda-ui/Doubao_watermark_aigc.svg`;
4
+ const MIAODA_LOGO_SRC = `${CDN}/logo/miaodalogo.svg`;
6
5
  export { DOUBAO_BRAND_TEXT_SRC, DOUBAO_LOGO_SRC, MIAODA_LOGO_SRC };
@@ -3,8 +3,6 @@ import { useEffect, useMemo, 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";
6
- import en_US from "antd/locale/en_US";
7
- import { getLocale } from "../../utils/locale.js";
8
6
  import IframeBridge from "./IframeBridge.js";
9
7
  import { Toaster } from "./sonner.js";
10
8
  import { PageHoc } from "./PageHoc.js";
@@ -17,7 +15,6 @@ import Watermark from "./Watermark.js";
17
15
  import { isStandaloneBuild } from "./standalone.js";
18
16
  import { getAppId } from "../../utils/getAppId.js";
19
17
  import { isNewPathEnabled } from "../../utils/apiPath.js";
20
- import { resolveParentOrigin } from "../../utils/postMessage.js";
21
18
  import QueryProvider from "../QueryProvider/index.js";
22
19
  import { AuthProvider } from "@lark-apaas/auth-sdk";
23
20
  import "../../runtime/index.js";
@@ -48,10 +45,6 @@ const appFlags = process.env.APP_FLAGS || {};
48
45
  const App = (props)=>{
49
46
  const { enableAuth, disableToaster = false } = props;
50
47
  useAppInfo();
51
- useEffect(()=>{
52
- const declared = document.documentElement.lang;
53
- if (!declared || 'zh' === declared || 'en' === declared) document.documentElement.lang = getLocale();
54
- }, []);
55
48
  useEffect(()=>{
56
49
  if (isMiaodaPreview) fetch(`${location.origin}/ai/api/feida_preview/csrf`).then(()=>{
57
50
  setTimeout(()=>{
@@ -106,9 +99,7 @@ const App = (props)=>{
106
99
  config: authConfig,
107
100
  children: [
108
101
  !disableToaster && true !== appFlags.customToaster && /*#__PURE__*/ jsx(Toaster, {}),
109
- 'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {
110
- targetOrigin: resolveParentOrigin()
111
- }),
102
+ 'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {}),
112
103
  'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(IframeBridge, {}),
113
104
  /*#__PURE__*/ jsx(PageHoc, {
114
105
  children: props.children
@@ -214,7 +205,7 @@ const AppContainer_AppContainer = (props)=>{
214
205
  }),
215
206
  /*#__PURE__*/ jsx(QueryProvider, {
216
207
  children: /*#__PURE__*/ jsx(ConfigProvider, {
217
- locale: 'zh' === getLocale() ? zh_CN : en_US,
208
+ locale: zh_CN,
218
209
  theme: {
219
210
  token: antdThemeToken,
220
211
  components: {
@@ -1,4 +1,3 @@
1
- import { readSettings } from "@lark-apaas/miaoda-common-settings";
2
1
  import blueimp_md5 from "blueimp-md5";
3
2
  import sha1 from "crypto-js/sha1";
4
3
  import { isMobile } from "../../../utils/deviceType.js";
@@ -16,11 +15,9 @@ async function createTracker() {
16
15
  const { tenantID, userID } = data || {};
17
16
  const userIDEncrypt = userID && '0' !== userID ? encryptTea(userID) : void 0;
18
17
  const tenantIDEncrypt = tenantID && '0' !== tenantID ? encryptTea(tenantID) : void 0;
19
- const tea = readSettings('apm.tea');
20
- if (!tea) return;
21
18
  window.collectEvent('init', {
22
- app_id: tea.appId,
23
- channel: tea.channel,
19
+ app_id: 788827,
20
+ channel: 'cn',
24
21
  disable_auto_pv: false,
25
22
  enable_ab_test: false,
26
23
  enable_debug: false,
@@ -4,7 +4,6 @@ import { logger } from "../../logger/index.js";
4
4
  import { getHmrApi } from "../../utils/hmr-api.js";
5
5
  import { submitPostMessage } from "../../utils/postMessage.js";
6
6
  import { t } from "../../locales/index.js";
7
- import { getStaticUrl } from "@lark-apaas/miaoda-common-settings";
8
7
  const RenderError = (props)=>{
9
8
  const { error, resetErrorBoundary } = props;
10
9
  useEffect(()=>{
@@ -42,7 +41,7 @@ const RenderError = (props)=>{
42
41
  className: "flex flex-col justify-center items-center text-center",
43
42
  children: [
44
43
  /*#__PURE__*/ jsx("img", {
45
- src: getStaticUrl('obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_negative_error.svg'),
44
+ src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_negative_error.svg",
46
45
  alt: "render error",
47
46
  className: "mb-3 w-[100px]"
48
47
  }),
@@ -2,8 +2,7 @@ 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, tDev } from "../../locales/index.js";
6
- import { getStaticUrl } from "@lark-apaas/miaoda-common-settings";
5
+ import { t } from "../../locales/index.js";
7
6
  const NotFound = ()=>{
8
7
  const location = useLocation();
9
8
  useEffect(()=>{
@@ -15,7 +14,7 @@ const NotFound = ()=>{
15
14
  })
16
15
  ],
17
16
  meta: {
18
- repairMessage: tDev('notFound.logger.repairMessage', {
17
+ repairMessage: t('notFound.logger.repairMessage', {
19
18
  path: location.pathname
20
19
  }),
21
20
  noStacktrace: true,
@@ -30,7 +29,7 @@ const NotFound = ()=>{
30
29
  className: "min-h-screen flex flex-col items-center justify-center bg-white gap-3",
31
30
  children: [
32
31
  /*#__PURE__*/ jsx("img", {
33
- src: getStaticUrl('obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_neutral_unfinished_gray.svg'),
32
+ src: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_neutral_unfinished_gray.svg',
34
33
  alt: "Not Found",
35
34
  className: "w-[100px]"
36
35
  }),
@@ -1,7 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { t } from "../../locales/index.js";
4
- import { getStaticUrl } from "@lark-apaas/miaoda-common-settings";
5
4
  const PagePlaceholder_PagePlaceholder = ({ title, description })=>{
6
5
  const defaultTitle = t('pagePlaceholder.title');
7
6
  const defaultDescription = t("pagePlaceholder.description");
@@ -12,7 +11,7 @@ const PagePlaceholder_PagePlaceholder = ({ title, description })=>{
12
11
  className: "rounded-md mb-6",
13
12
  width: "320",
14
13
  height: "200",
15
- src: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg'),
14
+ src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
16
15
  alt: "Welcome"
17
16
  }),
18
17
  /*#__PURE__*/ jsx("div", {
@@ -4,11 +4,9 @@ import { clsxWithTw } from "../../../utils/utils.js";
4
4
  import { getChatAppLink } from "./utils.js";
5
5
  import { OverflowTooltipText } from "../../ui/overflow-tooltip-text.js";
6
6
  import { t } from "../../../locales/index.js";
7
- import { getStaticUrl } from "@lark-apaas/miaoda-common-settings";
8
7
  function UserProfileUI({ user }) {
9
8
  const [avatarError, setAvatarError] = useState(false);
10
9
  const canShowAvatar = Boolean(user.avatar) && !avatarError;
11
- const chatAppLink = user.feishu_open_id ? getChatAppLink(user.feishu_open_id) : void 0;
12
10
  return /*#__PURE__*/ jsxs("div", {
13
11
  className: "overflow-hidden rounded-[8px] border-0 bg-card text-card-foreground h-full",
14
12
  children: [
@@ -18,7 +16,7 @@ function UserProfileUI({ user }) {
18
16
  className: "h-[136px] w-full",
19
17
  children: /*#__PURE__*/ jsx("img", {
20
18
  alt: "cover",
21
- src: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/default-cover.png'),
19
+ src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/default-cover.png",
22
20
  className: "h-full w-full object-cover"
23
21
  })
24
22
  })
@@ -59,11 +57,11 @@ function UserProfileUI({ user }) {
59
57
  })
60
58
  ]
61
59
  }),
62
- chatAppLink ? /*#__PURE__*/ jsx("div", {
60
+ user.feishu_open_id ? /*#__PURE__*/ jsx("div", {
63
61
  className: "w-full mt-2",
64
62
  children: /*#__PURE__*/ jsxs("a", {
65
63
  className: "inline-flex h-[42px] w-full items-center justify-center gap-2 rounded-[10px] border border-transparent bg-muted text-sm font-medium text-foreground transition-colors focus-visible:outline-none hover:bg-foreground/10 active:bg-foreground/15",
66
- href: chatAppLink,
64
+ href: getChatAppLink(user.feishu_open_id),
67
65
  target: "_blank",
68
66
  rel: "noopener noreferrer",
69
67
  children: [
@@ -1,6 +1,5 @@
1
1
  import { UserProfile } from '../../../utils/getUserProfile';
2
2
  import { User } from './type';
3
3
  export declare const formatI18nProfile: (profile: UserProfile) => User;
4
- /** 打开与该用户会话的客户端链接;配置里没有 applink 域名时返回 undefined,不展示「发消息」按钮 */
5
- export declare const getChatAppLink: (openId: string) => string | undefined;
4
+ export declare const getChatAppLink: (openId: string) => string;
6
5
  export declare const INVALID_USER: User;
@@ -1,8 +1,9 @@
1
- import { getStaticUrl, readSettings } from "@lark-apaas/miaoda-common-settings";
2
- import { pickI18nText } from "../../../utils/i18nText.js";
3
- import { t } from "../../../locales/index.js";
4
1
  const convertI18nTextToText = (i18nText)=>{
5
- if (Array.isArray(i18nText) && i18nText.length > 0) return pickI18nText(i18nText)?.text ?? '';
2
+ if (Array.isArray(i18nText) && i18nText.length > 0) {
3
+ const chineseText = i18nText.find((value)=>2052 === value.language_code);
4
+ if (chineseText) return chineseText.text;
5
+ return i18nText[0].text;
6
+ }
6
7
  return '';
7
8
  };
8
9
  const formatI18nProfile = (profile)=>({
@@ -13,15 +14,10 @@ const formatI18nProfile = (profile)=>({
13
14
  feishu_open_id: profile.feishuOpenID || '',
14
15
  status: 1 === profile.status ? 'active' : 'inactive'
15
16
  });
16
- const getChatAppLink = (openId)=>{
17
- const applinkDomain = readSettings('domainConf.applinkDomain');
18
- return applinkDomain ? `${applinkDomain}/client/chat/open?openId=${openId}` : void 0;
19
- };
17
+ const getChatAppLink = (openId)=>`https://applink.feishu.cn/client/chat/open?openId=${openId}`;
20
18
  const INVALID_USER = {
21
- get name () {
22
- return t('user.invalidUser');
23
- },
24
- avatar: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/no-person.svg'),
19
+ name: '无效人员',
20
+ avatar: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/no-person.svg',
25
21
  email: '',
26
22
  department: '',
27
23
  feishu_open_id: '',
@@ -4,7 +4,6 @@ import { Avatar, AvatarFallback, AvatarImage } from "../../ui/avatar.js";
4
4
  import { clsxWithTw } from "../../../utils/utils.js";
5
5
  import { Check } from "lucide-react";
6
6
  import { Spinner } from "./Spinner.js";
7
- import { t } from "../../../locales/index.js";
8
7
  function Dropdown({ isOpen, fetching, searchResults, onSelect, isSelected, onOptionMouseDown }) {
9
8
  if (!isOpen) return null;
10
9
  return /*#__PURE__*/ jsx("div", {
@@ -18,10 +17,10 @@ function Dropdown({ isOpen, fetching, searchResults, onSelect, isSelected, onOpt
18
17
  })
19
18
  }) : 0 === searchResults.length ? /*#__PURE__*/ jsx("div", {
20
19
  className: "px-2 py-[5px] text-[14px] leading-[22px] text-muted-foreground",
21
- children: t('userSelect.dropdown.noResults')
20
+ children: "无结果,建议更换搜索词"
22
21
  }) : searchResults.map((user)=>{
23
22
  const selected = isSelected(user.user_id);
24
- const displayName = user.name?.trim() || t('user.invalidUser');
23
+ const displayName = user.name?.trim() || '无效人员';
25
24
  return /*#__PURE__*/ jsxs("div", {
26
25
  className: "relative flex cursor-pointer items-center gap-2 rounded-sm py-1 pl-3 pr-[7px] text-foreground transition-colors hover:bg-foreground/8",
27
26
  onMouseDown: (event)=>{
@@ -5,7 +5,6 @@ import { Avatar, AvatarFallback, AvatarImage } from "../../ui/avatar.js";
5
5
  import { Badge } from "../../ui/badge.js";
6
6
  import { Button } from "../../ui/button.js";
7
7
  import { X } from "lucide-react";
8
- import { t } from "../../../locales/index.js";
9
8
  function MultipleSelectionTags({ displayUsers, onRemove }) {
10
9
  return /*#__PURE__*/ jsx(Fragment, {
11
10
  children: displayUsers?.map((user, index)=>/*#__PURE__*/ jsxs(Badge, {
@@ -36,9 +35,7 @@ function MultipleSelectionTags({ displayUsers, onRemove }) {
36
35
  "data-select-interactive": "true",
37
36
  className: "h-3 w-3 p-0 rounded-full opacity-60 hover:opacity-100 transition-all duration-200 cursor-pointer flex-shrink-0",
38
37
  onClick: (e)=>onRemove(user.user_id, e),
39
- title: t('userSelect.tag.remove', {
40
- name: user.name
41
- }),
38
+ title: `移除 ${user.name}`,
42
39
  children: /*#__PURE__*/ jsx(X, {
43
40
  size: 10,
44
41
  strokeWidth: 3
@@ -3,7 +3,6 @@ import "react";
3
3
  import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar.js";
4
4
  import { OverflowTooltipText } from "../ui/overflow-tooltip-text.js";
5
5
  import { clsxWithTw } from "../../utils/utils.js";
6
- import { t } from "../../locales/index.js";
7
6
  const avatarDimensionClassMap = {
8
7
  small: 'h-4 w-4',
9
8
  medium: 'h-5 w-5',
@@ -31,7 +30,7 @@ const textVariantMap = {
31
30
  };
32
31
  function UserWithAvatar({ data, size = 'medium', mode = 'tag', className, showLabel = true }) {
33
32
  const { avatar, name } = data;
34
- const displayName = name?.trim() || t('user.invalidUser');
33
+ const displayName = name?.trim() || '无效人员';
35
34
  const formatSize = [
36
35
  'small',
37
36
  'medium',
@@ -1,10 +1,6 @@
1
- import { getStaticUrl } from "@lark-apaas/miaoda-common-settings";
2
- import { t } from "../../locales/index.js";
3
1
  const themeMetaOptions = {
4
2
  themeColors: {
5
- get title () {
6
- return t('theme.themeColors.title');
7
- },
3
+ title: '主题色',
8
4
  options: [
9
5
  {
10
6
  value: '--blue-700',
@@ -37,16 +33,14 @@ const themeMetaOptions = {
37
33
  ]
38
34
  },
39
35
  themeRadius: {
40
- get title () {
41
- return t('theme.themeRadius.title');
42
- },
36
+ title: '圆角',
43
37
  options: [
44
38
  {
45
39
  value: {
46
40
  pixel: '0',
47
41
  rem: '0'
48
42
  },
49
- iconUrl: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/border-radius_ssm.svg'),
43
+ iconUrl: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/border-radius_ssm.svg',
50
44
  size: 'ssm'
51
45
  },
52
46
  {
@@ -54,7 +48,7 @@ const themeMetaOptions = {
54
48
  pixel: '8',
55
49
  rem: '0.625'
56
50
  },
57
- iconUrl: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/border-radius_m.svg'),
51
+ iconUrl: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/border-radius_m.svg',
58
52
  size: 'm'
59
53
  },
60
54
  {
@@ -62,7 +56,7 @@ const themeMetaOptions = {
62
56
  pixel: '12',
63
57
  rem: '0.875'
64
58
  },
65
- iconUrl: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/border-radius_l.svg'),
59
+ iconUrl: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/border-radius_l.svg',
66
60
  size: 'l'
67
61
  },
68
62
  {
@@ -70,15 +64,13 @@ const themeMetaOptions = {
70
64
  pixel: '24',
71
65
  rem: '1.625'
72
66
  },
73
- iconUrl: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/border-radius_xl.svg'),
67
+ iconUrl: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/border-radius_xl.svg',
74
68
  size: 'xl'
75
69
  }
76
70
  ]
77
71
  },
78
72
  themeSpaces: {
79
- get title () {
80
- return t('theme.themeSpaces.title');
81
- },
73
+ title: '间距',
82
74
  options: [
83
75
  {
84
76
  value: {
@@ -89,7 +81,7 @@ const themeMetaOptions = {
89
81
  sizeStep: '4'
90
82
  }
91
83
  },
92
- iconUrl: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/spacing-ssm.svg'),
84
+ iconUrl: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/spacing-ssm.svg',
93
85
  size: 'ssm'
94
86
  },
95
87
  {
@@ -101,7 +93,7 @@ const themeMetaOptions = {
101
93
  sizeStep: '4'
102
94
  }
103
95
  },
104
- iconUrl: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/spacing-m.svg'),
96
+ iconUrl: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/spacing-m.svg',
105
97
  size: 'm'
106
98
  },
107
99
  {
@@ -113,7 +105,7 @@ const themeMetaOptions = {
113
105
  sizeStep: '4'
114
106
  }
115
107
  },
116
- iconUrl: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/spacing-l.svg'),
108
+ iconUrl: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/spacing-l.svg',
117
109
  size: 'l'
118
110
  },
119
111
  {
@@ -125,7 +117,7 @@ const themeMetaOptions = {
125
117
  sizeStep: '4'
126
118
  }
127
119
  },
128
- iconUrl: getStaticUrl('obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/spacing-xl.svg'),
120
+ iconUrl: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/spacing-xl.svg',
129
121
  size: 'xl'
130
122
  }
131
123
  ]
@@ -4,12 +4,10 @@ import { logger } from "../logger/index.js";
4
4
  import { getCurrentUserProfile } from "../integrations/getCurrentUserProfile.js";
5
5
  import { isSparkRuntime } from "../utils/utils.js";
6
6
  import { getAxiosForBackend } from "../utils/getAxiosForBackend.js";
7
- import { getBrandLocale } from "@lark-apaas/miaoda-common-settings";
8
7
  function getNameFromArray(nameArray) {
9
8
  if (!nameArray || 0 === nameArray.length) return;
10
- const languageCode = 'en-US' === getBrandLocale() ? 1033 : 2052;
11
- const name = nameArray.find((item)=>item.language_code === languageCode);
12
- return name?.text ?? nameArray[0]?.text;
9
+ const chineseName = nameArray.find((item)=>2052 === item.language_code);
10
+ return chineseName?.text ?? nameArray[0]?.text;
13
11
  }
14
12
  let _larkUserIdCache = null;
15
13
  let _larkUserIdPromise = null;
@@ -1,15 +1,14 @@
1
1
  import { useState } from "react";
2
2
  import { authClient } from "@lark-apaas/auth-sdk";
3
- import { t } from "../locales/index.js";
4
3
  function useLogout() {
5
4
  const [isLoading, setIsLoading] = useState(false);
6
5
  async function handlerLogout() {
7
- if ('production' !== process.env.NODE_ENV) return void console.log(t('logout.log.productionOnly'));
6
+ if ('production' !== process.env.NODE_ENV) return void console.log('只有生产环境才执行登出');
8
7
  setIsLoading(true);
9
8
  try {
10
9
  await authClient.session.signOut();
11
10
  } catch (error) {
12
- console.error(t('logout.log.failed'), error);
11
+ console.error('登出失败', error);
13
12
  } finally{
14
13
  setIsLoading(false);
15
14
  }
package/lib/index.d.ts CHANGED
@@ -29,6 +29,8 @@ export { getAppId };
29
29
  export { getAppInfo } from './integrations/getAppInfo';
30
30
  export { getCurrentUserProfile } from './integrations/getCurrentUserProfile';
31
31
  export { getDataloom } from './integrations/dataloom';
32
+ export { BaseStorageError } from './apis/dataloom';
33
+ export type { BaseAttachment, UploadedBaseAttachment, BaseStorageResult, BaseStorage, UploadParams, GetAttachmentUrlParams, BaseStorageStage, } from './apis/dataloom';
32
34
  export { logger };
33
35
  export type { LogLevel, LogWithMeta } from './logger/log-types';
34
36
  export { trace } from './trace';
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ import { initAxiosConfig } from "./utils/axiosConfig.js";
31
31
  import { getAppInfo } from "./integrations/getAppInfo.js";
32
32
  import { getCurrentUserProfile } from "./integrations/getCurrentUserProfile.js";
33
33
  import { getDataloom } from "./integrations/dataloom.js";
34
+ import { BaseStorageError } from "./apis/dataloom.js";
34
35
  import { trace } from "./trace/index.js";
35
36
  import { initObservable } from "./runtime/observable.js";
36
37
  import { TrackKey } from "./types/tea.js";
@@ -58,4 +59,4 @@ const capabilityClient = createClient({
58
59
  const src = {
59
60
  version: version
60
61
  };
61
- export { ActiveLink, AppContainer, ErrorRender, NavLink, PagePlaceholder, QueryProvider, TrackKey, UniversalLink, PagePlaceholder as Welcome, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_avatar_js_2c154035__ as avatarImages, axiosForBackend, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_banner_js_72c990bf__ as bannerImages, capabilityClient, clsxWithTw, copyToClipboard, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_cover_js_90a812c2__ as coverImages, src as default, getAppId, getAppInfo, getAxiosForBackend, getCsrfToken, getCurrentUserProfile, getDataloom, getEnvPath, getWsPath, initAxiosConfig, initObservable, isIOS, isIpad, isMobile, isPreview, logger, normalizeBasePath, reportTeaEvent, resolveAppUrl, safeStringify, scopedStorage, showConfirm, trace, useAppInfo, useCurrentUserProfile, useIsMobile, useLogout };
62
+ export { ActiveLink, AppContainer, BaseStorageError, ErrorRender, NavLink, PagePlaceholder, QueryProvider, TrackKey, UniversalLink, PagePlaceholder as Welcome, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_avatar_js_2c154035__ as avatarImages, axiosForBackend, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_banner_js_72c990bf__ as bannerImages, capabilityClient, clsxWithTw, copyToClipboard, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_cover_js_90a812c2__ as coverImages, src as default, getAppId, getAppInfo, getAxiosForBackend, getCsrfToken, getCurrentUserProfile, getDataloom, getEnvPath, getWsPath, initAxiosConfig, initObservable, isIOS, isIpad, isMobile, isPreview, logger, normalizeBasePath, reportTeaEvent, resolveAppUrl, safeStringify, scopedStorage, showConfirm, trace, useAppInfo, useCurrentUserProfile, useIsMobile, useLogout };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,74 @@
1
+ import { File } from "node:buffer";
2
+ import { afterEach, describe, expect, it, vi } from "vitest";
3
+ import { getDataloom } from "../dataloom.js";
4
+ vi.mock('../../utils/getInitialInfo', ()=>({
5
+ getInitialInfo: async ()=>({})
6
+ }));
7
+ vi.mock('@lark-apaas/auth-sdk', ()=>({
8
+ authClient: {
9
+ user: {},
10
+ session: {}
11
+ }
12
+ }));
13
+ afterEach(()=>{
14
+ vi.unstubAllGlobals();
15
+ document.cookie = 'suda-csrf-token=; max-age=0; path=/';
16
+ });
17
+ describe('baseStorage toolkit integration', ()=>{
18
+ it('reads the host at call time and refreshes CSRF for the callback', async ()=>{
19
+ Object.assign(window, {
20
+ appId: 'app-from-host',
21
+ ENVIRONMENT: 'gray'
22
+ });
23
+ document.cookie = 'suda-csrf-token=first; path=/';
24
+ const calls = [];
25
+ vi.stubGlobal('fetch', vi.fn(async (input, init)=>{
26
+ const url = String(input);
27
+ calls.push({
28
+ url,
29
+ init
30
+ });
31
+ if (url.endsWith('/preUpload')) {
32
+ document.cookie = 'suda-csrf-token=second; path=/';
33
+ return new Response(JSON.stringify({
34
+ data: {
35
+ uploadCode: 'up'
36
+ }
37
+ }));
38
+ }
39
+ if (url.includes('prepare_authcode')) return new Response(JSON.stringify({
40
+ code: 0,
41
+ data: {
42
+ upload_id: 'session',
43
+ block_size: 10
44
+ }
45
+ }));
46
+ if (url.includes('finish_authcode')) return new Response(JSON.stringify({
47
+ code: 0,
48
+ data: {
49
+ file_token: 'token'
50
+ }
51
+ }));
52
+ return new Response(JSON.stringify({
53
+ code: 0
54
+ }));
55
+ }));
56
+ const dataloom = await getDataloom();
57
+ const result = await dataloom.baseStorage.upload(new File([
58
+ 'abc'
59
+ ], 'a.png'), {
60
+ baseToken: 'base'
61
+ });
62
+ expect(result.error).toBeNull();
63
+ expect(new URL(calls[0].url).pathname).toContain('/app/app-from-host/');
64
+ expect(new URL(calls[1].url).hostname).toBe('internal-api-drive-stream.feishu.cn');
65
+ expect(new Headers(calls[0].init?.headers).get('X-Suda-Csrf-Token')).toBe('first');
66
+ expect(new Headers(calls[4].init?.headers).get('X-Suda-Csrf-Token')).toBe('second');
67
+ const url = dataloom.baseStorage.getAttachmentUrl({
68
+ baseToken: 'base',
69
+ tableId: 'tbl-real-id',
70
+ attachment: result.data
71
+ });
72
+ expect(url.data?.url).toBe('/app/app-from-host/__runtime__/api/v1/storage/bitable/base/table/tbl-real-id/token');
73
+ });
74
+ });
@@ -1,6 +1,6 @@
1
1
  import type { AccountType, UserProfileData } from './types';
2
2
  /**
3
- * 获取 CDN 资源 URL,CDN 前缀取自配置
3
+ * 获取 CDN 资源 URL
4
4
  */
5
5
  export declare function getAssetsUrl(path: string): string;
6
6
  export type UserProfileServiceConfig = {
@@ -1,8 +1,8 @@
1
1
  import { getAppId } from "../../utils/getAppId.js";
2
2
  import { isNewPathEnabled } from "../../utils/apiPath.js";
3
- import { getStaticUrl } from "@lark-apaas/miaoda-common-settings";
3
+ const CDN_HOST = 'https://lf3-static.bytednsdoc.com';
4
4
  function getAssetsUrl(path) {
5
- return getStaticUrl(path);
5
+ return `${CDN_HOST}${path}`;
6
6
  }
7
7
  const DEFAULT_CONFIG = {
8
8
  getAppId: ()=>getAppId(),