@lark-apaas/client-toolkit-lite 1.1.7-alpha.24 → 1.1.7-alpha.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,13 +19,14 @@ npm install react react-dom react-router-dom @tanstack/react-query
19
19
  ### 1. 使用 AppContainer
20
20
 
21
21
  `AppContainer` 是应用根容器,内部集成:
22
- - **全局样式** — 自动导入主题样式(theme-layer / tailwind-theme / override / font-family),无需手动 import CSS
23
22
  - **Safety** — 生产环境「妙搭构建」安全标识
24
23
  - **QueryProvider** — React Query 数据管理
25
24
  - **useAppInfo** — 自动同步 document title / favicon / OG meta
26
25
  - **Tea 埋点** — 生产环境自动上报页面访问事件
27
26
  - **Runtime** — React DevTools Hook + Axios CSRF 全局注入(防重复)
28
27
 
28
+ > 主题样式**不自动注入**,需在应用入口手动 import,详见下一节。
29
+
29
30
  ```tsx
30
31
  // App.tsx
31
32
  import { AppContainer } from '@lark-apaas/client-toolkit-lite';
@@ -53,6 +54,53 @@ import { QueryProvider } from '@lark-apaas/client-toolkit-lite';
53
54
  <QueryProvider>{children}</QueryProvider>
54
55
  ```
55
56
 
57
+ ### 2. 导入样式
58
+
59
+ 主题样式包含 4 个片段:`theme-layer`(layer 顺序声明)/ `tailwind-theme`(色板变量 + `.dark` 模式)/ `override`(base 兜底)/ `font-family`(Lark 字体)。聚合入口需手动 import:
60
+
61
+ ```ts
62
+ // main.ts / main.tsx
63
+ import '@lark-apaas/client-toolkit-lite/styles.css';
64
+ ```
65
+
66
+ #### Tailwind v4 source 扫描
67
+
68
+ lite 的 `Drawer` / `Popover` / `ErrorRender` 等组件使用了 Tailwind class,由于 v4 默认不扫描 `node_modules`,需要在你自己的主 css 里显式声明 source(否则这些组件会没有视觉):
69
+
70
+ ```css
71
+ /* 你的 main.css */
72
+ @import 'tailwindcss';
73
+ @import '@lark-apaas/client-toolkit-lite/styles.css';
74
+
75
+ /* 路径相对于这个 css 文件所在位置 */
76
+ @source "../node_modules/@lark-apaas/client-toolkit-lite/dist";
77
+ ```
78
+
79
+ #### shadcn 语义变量(按需补)
80
+
81
+ `override.css` 和 `Drawer` / `Popover` 用了 `--background` / `--foreground` / `--border` / `--ring` / `--popover` / `--popover-foreground` / `--muted-foreground` 等 shadcn 风格语义变量。lite 内置色板(`tailwind-theme.css`)**只提供 `--color-*` 全色板**,不包含这些语义变量 —— 需要你在自己的 css 里按业务主题补上:
82
+
83
+ ```css
84
+ :root {
85
+ --background: var(--color-neutral-00);
86
+ --foreground: var(--color-neutral-950);
87
+ --border: var(--color-neutral-300);
88
+ --ring: var(--color-blue-500);
89
+ --popover: var(--color-neutral-00);
90
+ --popover-foreground: var(--color-neutral-950);
91
+ --muted-foreground: var(--color-neutral-700);
92
+ }
93
+ ```
94
+
95
+ #### 按需导入子片段
96
+
97
+ 只要色板或字体时可单独 import:
98
+
99
+ ```ts
100
+ import '@lark-apaas/client-toolkit-lite/styles/tailwind-theme.css';
101
+ import '@lark-apaas/client-toolkit-lite/styles/font-family.css';
102
+ ```
103
+
56
104
  ### 3. Hooks
57
105
 
58
106
  #### useAppInfo
package/dist/index.cjs CHANGED
@@ -1473,6 +1473,11 @@ __name(useLogout, "useLogout");
1473
1473
 
1474
1474
  // src/locales/messages.ts
1475
1475
  var messages = {
1476
+ // ── Index / 通用 ──────────────────────────────────────────────
1477
+ "index.rateLimitError": {
1478
+ zh: "\u5E94\u7528\u989D\u5EA6\u5DF2\u8017\u5C3D\uFF0C\u8BF7\u8054\u7CFB\u5E94\u7528\u5F00\u53D1\u8005",
1479
+ en: "Application quota exhausted, please contact the app developer"
1480
+ },
1476
1481
  // ── Safety 组件 ──────────────────────────────────────────────
1477
1482
  "safety.badge.label": {
1478
1483
  zh: "\u5999\u642D",
@@ -2841,23 +2846,86 @@ var axiosForBackend = getAxiosForBackend();
2841
2846
 
2842
2847
  // src/integrations/capabilityClient.ts
2843
2848
  var import_client_capability = require("@lark-apaas/client-capability");
2849
+
2850
+ // src/components/ui/toast.tsx
2851
+ function showToast2(message, duration = 3e3) {
2852
+ return new Promise((resolve) => {
2853
+ const toast = document.createElement("div");
2854
+ const iconSvg = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2855
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.333a6.667 6.667 0 1 1 0 13.334A6.667 6.667 0 0 1 8 1.333ZM8 10a.667.667 0 1 0 0 1.333A.667.667 0 0 0 8 10Zm0-5.333a.667.667 0 0 0-.667.666v3.334a.667.667 0 0 0 1.334 0V5.333A.667.667 0 0 0 8 4.667Z" fill="#ff811a"/>
2856
+ </svg>`;
2857
+ const iconWrapper = document.createElement("span");
2858
+ iconWrapper.innerHTML = iconSvg;
2859
+ Object.assign(iconWrapper.style, {
2860
+ display: "flex",
2861
+ alignItems: "center",
2862
+ marginRight: "8px",
2863
+ flexShrink: "0"
2864
+ });
2865
+ const textWrapper = document.createElement("span");
2866
+ textWrapper.textContent = message;
2867
+ toast.appendChild(iconWrapper);
2868
+ toast.appendChild(textWrapper);
2869
+ Object.assign(toast.style, {
2870
+ position: "fixed",
2871
+ top: "32px",
2872
+ left: "50%",
2873
+ transform: "translate(-50%, -50%)",
2874
+ display: "flex",
2875
+ alignItems: "center",
2876
+ padding: "12px 16px",
2877
+ backgroundColor: "#fff",
2878
+ color: "#1f2329",
2879
+ border: "1px solid #dee0e3",
2880
+ borderRadius: "6px",
2881
+ fontSize: "14px",
2882
+ lineHeight: "1.5",
2883
+ zIndex: "99999",
2884
+ maxWidth: "80vw",
2885
+ wordBreak: "break-word",
2886
+ boxShadow: "0 4px 8px rgba(0, 0, 0, 0.03), 0 3px 6px rgba(0, 0, 0, 0.05), 0 6px 18px rgba(0, 0, 0, 0.03)",
2887
+ opacity: "0",
2888
+ transition: "opacity 0.3s ease"
2889
+ });
2890
+ document.body.appendChild(toast);
2891
+ requestAnimationFrame(() => {
2892
+ toast.style.opacity = "1";
2893
+ });
2894
+ setTimeout(() => {
2895
+ toast.style.opacity = "0";
2896
+ setTimeout(() => {
2897
+ document.body.removeChild(toast);
2898
+ resolve();
2899
+ }, 300);
2900
+ }, duration);
2901
+ });
2902
+ }
2903
+ __name(showToast2, "showToast");
2904
+
2905
+ // src/integrations/capabilityClient.ts
2844
2906
  var _appId = getAppId();
2845
- var _acquireUploadUrl = isNewPathEnabled() ? `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_upload_url` : `/af/api/v1/studio/plugins/tmp_files/acquire_upload_url`;
2846
- var _acquireDownloadUrl = isNewPathEnabled() ? `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_download_url` : `/af/api/v1/studio/plugins/tmp_files/acquire_download_url`;
2907
+ var _archType = process.env.MIAODA_APP_ARCH_TYPE;
2908
+ var _isFrontendOnly = _archType === "2" || _archType === "3" || _archType === "4";
2847
2909
  var capabilityClient = (0, import_client_capability.createClient)({
2848
2910
  baseURL: normalizeBasePath(process.env.CLIENT_BASE_PATH ?? "/"),
2849
- acquireUploadUrl: _acquireUploadUrl,
2850
- acquireDownloadUrl: _acquireDownloadUrl,
2911
+ acquireUploadUrl: `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_upload_url`,
2912
+ acquireDownloadUrl: `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_download_url`,
2851
2913
  fetchOptions: {
2852
2914
  headers: {
2853
2915
  "X-Suda-Csrf-Token": window.csrfToken ?? ""
2854
2916
  }
2855
2917
  },
2856
- central: {
2857
- enabled: true,
2858
- // window.appId 由妙搭沙箱 / 线上环境注入;非妙搭场景下 capability 调用本身不可用
2859
- appId: _appId ?? ""
2860
- }
2918
+ logger,
2919
+ onRateLimitError: /* @__PURE__ */ __name(() => {
2920
+ showToast2(t("index.rateLimitError"));
2921
+ }, "onRateLimitError"),
2922
+ ..._isFrontendOnly ? {
2923
+ central: {
2924
+ enabled: true,
2925
+ // window.appId 由妙搭沙箱 / 线上环境注入;非妙搭场景下 capability 调用本身不可用
2926
+ appId: _appId ?? ""
2927
+ }
2928
+ } : {}
2861
2929
  });
2862
2930
 
2863
2931
  // src/constants/img-resources/avatar.ts