@lark-apaas/miaoda-core 0.1.0-alpha.13 → 0.1.0-alpha.15

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 (67) hide show
  1. package/lib/apis/dataloom.d.ts +1 -1
  2. package/lib/apis/dataloom.js +2 -2
  3. package/lib/apis/hooks/useAppInfo.d.ts +1 -0
  4. package/lib/apis/hooks/useAppInfo.js +1 -0
  5. package/lib/apis/utils/registerChinaMap.js +34 -34
  6. package/lib/components/AppContainer/IframeBridge.js +62 -96
  7. package/lib/components/AppContainer/PageHoc.js +1 -1
  8. package/lib/components/AppContainer/childApi.d.ts +5 -0
  9. package/lib/components/AppContainer/childApi.js +20 -0
  10. package/lib/components/AppContainer/index.js +1 -1
  11. package/lib/components/ErrorRender/index.js +4 -4
  12. package/lib/components/NotFoundRender/index.js +3 -3
  13. package/lib/components/TopNav/BottomNav.js +1 -1
  14. package/lib/components/TopNav/TitleBar.js +9 -6
  15. package/lib/components/TopNav/TopNav.js +3 -3
  16. package/lib/components/User/UserDisplay.d.ts +1 -1
  17. package/lib/components/User/UserProfile/UserProfileUI.js +4 -4
  18. package/lib/components/User/UserProfile/utils.js +1 -1
  19. package/lib/components/User/UserSelect.js +3 -2
  20. package/lib/components/User/UserWithAvatar.js +1 -1
  21. package/lib/components/Welcome/index.js +3 -3
  22. package/lib/components/common/LogoInfo.js +3 -3
  23. package/lib/components/common/NavItem.js +1 -1
  24. package/lib/components/common/UserAvatarMenu.js +1 -1
  25. package/lib/components/theme/ThemeProvider.d.ts +2 -2
  26. package/lib/components/theme/ThemeProvider.js +3 -3
  27. package/lib/components/theme/constants.d.ts +1 -1
  28. package/lib/components/theme/constants.js +5 -4
  29. package/lib/components/theme/ui-config.d.ts +1 -49
  30. package/lib/components/theme/ui-config.js +1 -757
  31. package/lib/components/theme/util.d.ts +3 -3
  32. package/lib/components/theme/util.js +4 -4
  33. package/lib/hooks/index.d.ts +1 -1
  34. package/lib/hooks/index.js +1 -1
  35. package/lib/hooks/{useCurrentAppInfo.d.ts → useAppInfo.d.ts} +1 -1
  36. package/lib/hooks/{useCurrentAppInfo.js → useAppInfo.js} +6 -5
  37. package/lib/hooks/useCurrentUserProfile.js +34 -2
  38. package/lib/hooks/useLogout.js +16 -2
  39. package/lib/hooks/useTheme.js +1 -1
  40. package/lib/index.css +1 -0
  41. package/lib/inspector.dev.css +10 -0
  42. package/lib/integrations/dataloom.d.ts +2 -1
  43. package/lib/integrations/dataloom.js +22 -8
  44. package/lib/integrations/generateImage.js +15 -0
  45. package/lib/integrations/generateTextStream.d.ts +0 -5
  46. package/lib/integrations/generateTextStream.js +28 -13
  47. package/lib/integrations/getAppInfo.d.ts +1 -1
  48. package/lib/integrations/getAppInfo.js +12 -2
  49. package/lib/tailwind-theme.css +1 -101
  50. package/lib/theme-layer.css +3 -0
  51. package/lib/types/common.d.ts +0 -7
  52. package/lib/types/iframe-events.d.ts +9 -1
  53. package/lib/types/index.d.ts +2 -0
  54. package/lib/utils/copyToClipboard.js +2 -2
  55. package/lib/utils/getAppId.d.ts +1 -6
  56. package/lib/utils/getAppId.js +4 -2
  57. package/lib/utils/getCsrfToken.d.ts +5 -0
  58. package/lib/utils/getCsrfToken.js +10 -0
  59. package/lib/utils/getInitialInfo.d.ts +20 -0
  60. package/lib/utils/getInitialInfo.js +32 -0
  61. package/lib/utils/getParentOrigin.js +2 -2
  62. package/lib/utils/getUserProfile.js +7 -1
  63. package/lib/utils/utils.d.ts +2 -0
  64. package/lib/utils/utils.js +4 -1
  65. package/package.json +22 -20
  66. package/lib/apis/hooks/useCurrentAppInfo.d.ts +0 -1
  67. package/lib/apis/hooks/useCurrentAppInfo.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import { type ThemeConfig } from 'antd';
2
2
  import { UIComponentConfig } from './ui-config';
3
3
  export type IThemeMode = 'dark' | 'light' | 'system';
4
- export interface IThemeMeta {
4
+ export interface IThemeTokenMeta {
5
5
  /**
6
6
  * 品牌色
7
7
  */
@@ -16,5 +16,5 @@ export interface IThemeMeta {
16
16
  spacing: number;
17
17
  }
18
18
  export declare const generateTailwindRadiusToken: (radiusRemValue: number) => UIComponentConfig;
19
- export declare function generateLightTheme(override?: Partial<IThemeMeta>): ThemeConfig;
20
- export declare function generateDarkTheme(override?: Partial<IThemeMeta>): ThemeConfig;
19
+ export declare function generateLightTheme(override?: Partial<IThemeTokenMeta>): ThemeConfig;
20
+ export declare function generateDarkTheme(override?: Partial<IThemeTokenMeta>): ThemeConfig;
@@ -70,7 +70,7 @@ const generateTailwindRadiusToken = (radiusRemValue)=>{
70
70
  options: [
71
71
  {
72
72
  value: 'rounded-none',
73
- label: 'none(0px)',
73
+ label: "none\uFF080px\uFF09",
74
74
  rawValue: '0'
75
75
  },
76
76
  {
@@ -119,7 +119,7 @@ const generateTailwindRadiusToken = (radiusRemValue)=>{
119
119
  options: [
120
120
  {
121
121
  value: 'rounded-none',
122
- label: 'none(0px)',
122
+ label: "none\uFF080px\uFF09",
123
123
  rawValue: '0'
124
124
  },
125
125
  {
@@ -169,7 +169,7 @@ function generateLightTheme(override) {
169
169
  token: {
170
170
  ...defaultLightTheme.token,
171
171
  ...generateColorPrimaryToken(override?.colorPrimary || lightColorPrimary, 'light'),
172
- ...generateBorderRadiusTokenSyncTailwind(override?.borderRadius || 4),
172
+ ...generateBorderRadiusTokenSyncTailwind(override?.borderRadius),
173
173
  ...generateSpacingToken(override)
174
174
  }
175
175
  };
@@ -180,7 +180,7 @@ function generateDarkTheme(override) {
180
180
  token: {
181
181
  ...defaultDarkTheme.token,
182
182
  ...generateColorPrimaryToken(override?.colorPrimary || darkColorPrimary, 'dark'),
183
- ...generateBorderRadiusTokenSyncTailwind(override?.borderRadius || 4),
183
+ ...generateBorderRadiusTokenSyncTailwind(override?.borderRadius),
184
184
  ...generateSpacingToken(override)
185
185
  }
186
186
  };
@@ -1,4 +1,4 @@
1
- export * from './useCurrentAppInfo';
1
+ export * from './useAppInfo';
2
2
  export * from './useCurrentUserProfile';
3
3
  export * from './useIsMobile';
4
4
  export * from './useLogout';
@@ -1,4 +1,4 @@
1
- export * from "./useCurrentAppInfo.js";
1
+ export * from "./useAppInfo.js";
2
2
  export * from "./useCurrentUserProfile.js";
3
3
  export * from "./useIsMobile.js";
4
4
  export * from "./useLogout.js";
@@ -1,4 +1,4 @@
1
- export declare const useCurrentAppInfo: () => {
1
+ export declare const useAppInfo: () => {
2
2
  appName: string;
3
3
  appLogo: string;
4
4
  name?: string;
@@ -1,11 +1,12 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { getAppInfo } from "../integrations/getAppInfo.js";
3
- const useCurrentAppInfo = ()=>{
4
- const [appInfo, setAppInfo] = useState(()=>getAppInfo());
3
+ const useAppInfo = ()=>{
4
+ const [appInfo, setAppInfo] = useState({});
5
5
  useEffect(()=>{
6
- const handleMetaInfoChanged = ()=>{
7
- setAppInfo(getAppInfo());
6
+ const handleMetaInfoChanged = async ()=>{
7
+ setAppInfo(await getAppInfo());
8
8
  };
9
+ handleMetaInfoChanged();
9
10
  window.addEventListener('MiaoDaMetaInfoChanged', handleMetaInfoChanged);
10
11
  return ()=>{
11
12
  window.removeEventListener('MiaoDaMetaInfoChanged', handleMetaInfoChanged);
@@ -17,4 +18,4 @@ const useCurrentAppInfo = ()=>{
17
18
  appLogo: appInfo.avatar
18
19
  };
19
20
  };
20
- export { useCurrentAppInfo };
21
+ export { useAppInfo };
@@ -1,6 +1,8 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { logger } from "../logger/index.js";
3
3
  import { getCurrentUserProfile } from "../integrations/getCurrentUserProfile.js";
4
+ import { getDataloom } from "../integrations/dataloom.js";
5
+ import { isSanboxMode } from "../utils/utils.js";
4
6
  function getCompatibilityUserProfile() {
5
7
  const userInfo = getCurrentUserProfile();
6
8
  return {
@@ -12,8 +14,38 @@ function getCompatibilityUserProfile() {
12
14
  const useCurrentUserProfile = ()=>{
13
15
  const [userInfo, setUserInfo] = useState(()=>getCompatibilityUserProfile());
14
16
  useEffect(()=>{
15
- const handleMetaInfoChanged = ()=>{
16
- logger.info('MiaoDaMetaInfoChanged', getCurrentUserProfile());
17
+ let handleMetaInfoChanged;
18
+ if (isSanboxMode()) {
19
+ (async ()=>{
20
+ const dataloom = await getDataloom();
21
+ const result = await dataloom.service.session.getUserInfo();
22
+ const userInfo = result?.data?.user_info;
23
+ setUserInfo({
24
+ user_id: userInfo.user_id?.toString(),
25
+ email: userInfo.email,
26
+ name: userInfo.name?.[0]?.text,
27
+ avatar: userInfo.avatar?.image?.large,
28
+ userName: userInfo?.name?.[0]?.text,
29
+ userAvatar: userInfo?.avatar?.image?.large
30
+ });
31
+ })();
32
+ handleMetaInfoChanged = async ()=>{
33
+ const dataloom = await getDataloom();
34
+ const result = await dataloom.service.session.getUserInfo();
35
+ const userInfo = result?.data?.user_info;
36
+ const newUserInfo = {
37
+ user_id: userInfo.user_id?.toString(),
38
+ email: userInfo.email,
39
+ name: userInfo.name?.[0]?.text,
40
+ avatar: userInfo.avatar?.image?.large,
41
+ userName: userInfo?.name?.[0]?.text,
42
+ userAvatar: userInfo?.avatar?.image?.large
43
+ };
44
+ logger.info('MiaoDaMetaInfoChanged', newUserInfo);
45
+ setUserInfo(newUserInfo);
46
+ };
47
+ } else handleMetaInfoChanged = ()=>{
48
+ logger.info('MiaoDaMetaInfoChanged', getCompatibilityUserProfile());
17
49
  setUserInfo(getCompatibilityUserProfile());
18
50
  };
19
51
  window.addEventListener('MiaoDaMetaInfoChanged', handleMetaInfoChanged);
@@ -1,8 +1,22 @@
1
1
  import { useState } from "react";
2
+ import { getDataloom } from "../integrations/dataloom.js";
3
+ import { isSanboxMode } from "../utils/utils.js";
2
4
  function useLogout() {
3
5
  const [isLoading, setIsLoading] = useState(false);
4
6
  async function handlerLogout() {
5
- if ('production' !== process.env.NODE_ENV) return void console.log('只有生产环境才执行登出');
7
+ if ('production' !== process.env.NODE_ENV) return void console.log("\u53EA\u6709\u751F\u4EA7\u73AF\u5883\u624D\u6267\u884C\u767B\u51FA");
8
+ if (isSanboxMode()) {
9
+ setIsLoading(true);
10
+ try {
11
+ const dataloom = await getDataloom();
12
+ await dataloom.service.session.signOut();
13
+ } catch (error) {
14
+ console.error("\u767B\u51FA\u5931\u8D25", error);
15
+ } finally{
16
+ setIsLoading(false);
17
+ }
18
+ return;
19
+ }
6
20
  setIsLoading(true);
7
21
  try {
8
22
  await fetch('/ai/api/ui/page/logout', {
@@ -10,7 +24,7 @@ function useLogout() {
10
24
  });
11
25
  window.location.reload();
12
26
  } catch (error) {
13
- console.error('登出失败', error);
27
+ console.error("\u767B\u51FA\u5931\u8D25", error);
14
28
  } finally{
15
29
  setIsLoading(false);
16
30
  }
@@ -2,7 +2,7 @@ import { useContext } from "react";
2
2
  import { ThemeProviderContext } from "../components/theme/index.js";
3
3
  const useTheme = ()=>{
4
4
  const context = useContext(ThemeProviderContext);
5
- if (void 0 === context) throw new Error('useTheme 必须在 ThemeProvider 内使用');
5
+ if (void 0 === context) throw new Error("useTheme \u5FC5\u987B\u5728 ThemeProvider \u5185\u4F7F\u7528");
6
6
  return context;
7
7
  };
8
8
  export { useTheme };
package/lib/index.css CHANGED
@@ -1,3 +1,4 @@
1
+ @import "./theme-layer.css";
1
2
  @import "./tailwind-theme.css";
2
3
  @import "./override.css";
3
4
 
@@ -0,0 +1,10 @@
1
+ @source inline("text-{xs,sm,base,lg,xl,2xl,3xl,4xl,5xl,6xl,7xl,8xl,9xl}");
2
+
3
+ @source inline("{bg,text,border}-{blue,pink,neutral,red,orange,violet,lime,yellow,green,teal,cyan,indigo,purple,amber,emerald,slate}-{50,{100..900..100},950}");
4
+
5
+ @source inline("{bg,text,border}-{blue,pink,neutral,red,orange,violet,lime,yellow,green,teal,cyan,indigo,purple,amber,emerald,slate}");
6
+
7
+ @source inline("{bg,text,border}-neutral-{00,1000}");
8
+
9
+ @source inline("rounded-{none,sm,md,lg,xl,full}");
10
+
@@ -1 +1,2 @@
1
- export declare const dataloom: import("@data-loom/js").DataloomClient<any, "public", any>;
1
+ /** 获取dataloom实例 */
2
+ export declare function getDataloom(): Promise<import("@data-loom/js").DataloomClient<any, "public", any>>;
@@ -1,18 +1,32 @@
1
1
  import { splitWorkspaceUrl } from "../utils/url.js";
2
2
  import { createClient } from "@data-loom/js";
3
- const PAT_URL_NAMESPACE = 'FEISUDA_UUU';
4
- const PAT_TOKEN_NAMESPACE = 'FEISUDA_TTT';
5
- const DATALOOM_CLIENT_URL = window[PAT_URL_NAMESPACE];
6
- const DATALOOM_PAT = window[PAT_TOKEN_NAMESPACE];
3
+ import { getAppId } from "../utils/getAppId.js";
4
+ import { getInitialInfo } from "../utils/getInitialInfo.js";
7
5
  const createDataLoomClient = (url, pat)=>{
8
- if (!url || !pat) return null;
6
+ if (!url) return null;
9
7
  const { baseUrl, workspace } = splitWorkspaceUrl(url);
8
+ const appId = getAppId(window.location.pathname);
10
9
  return createClient(baseUrl, pat, workspace, {
11
10
  global: {
12
11
  enablePostgresBuilderLog: 'production' !== process.env.NODE_ENV,
13
- requestRateLimit: 'production' !== process.env.NODE_ENV ? 100 : void 0
12
+ requestRateLimit: 'production' !== process.env.NODE_ENV ? 100 : void 0,
13
+ brandName: 'miaoda',
14
+ appId,
15
+ onError: (error, dataloomInstance)=>{
16
+ if (error?.status === 401) {
17
+ if (error?.code === 'k_ident_013001') dataloomInstance.service.session.redirectToLogin();
18
+ }
19
+ }
14
20
  }
15
21
  });
16
22
  };
17
- const dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
18
- export { dataloom };
23
+ let dataloom = null;
24
+ async function getDataloom() {
25
+ if (dataloom) return dataloom;
26
+ const { app_runtime_extra } = await getInitialInfo();
27
+ const DATALOOM_CLIENT_URL = app_runtime_extra?.url;
28
+ const DATALOOM_PAT = app_runtime_extra?.token;
29
+ dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
30
+ return dataloom;
31
+ }
32
+ export { getDataloom };
@@ -1,5 +1,7 @@
1
1
  import { getAppId } from "../utils/getAppId.js";
2
+ import { getCsrfToken } from "../utils/getCsrfToken.js";
2
3
  import { getEnvPath } from "../utils/getEnvPath.js";
4
+ import { isSanboxMode } from "../utils/utils.js";
3
5
  async function generateImage(prompt, size = '1024x1024', headers = {}) {
4
6
  const appId = getAppId(window.location.pathname);
5
7
  if (!appId) return {
@@ -18,6 +20,19 @@ async function generateImage(prompt, size = '1024x1024', headers = {}) {
18
20
  'x-lgw-csrf-token': window.lgw_csrf_token,
19
21
  ...window.CSRF_HEADERS || {}
20
22
  };
23
+ if (isSanboxMode()) {
24
+ mergedHeaders['X-Suda-Csrf-Token'] = getCsrfToken();
25
+ const response = await fetch(`${window.location.origin}/spark/b/${appId}/text2image`, {
26
+ method: 'POST',
27
+ headers: mergedHeaders,
28
+ credentials: 'include',
29
+ body: JSON.stringify({
30
+ prompt: prompt,
31
+ size: size
32
+ })
33
+ });
34
+ return await response.json();
35
+ }
21
36
  const response = await fetch(`${window.location.origin}/ai/api/${getEnvPath()}/v1/apps/${appId}/text2image`, {
22
37
  method: 'POST',
23
38
  headers: mergedHeaders,
@@ -1,8 +1,3 @@
1
- declare global {
2
- interface Window {
3
- token?: string;
4
- }
5
- }
6
1
  interface GenerateTextOptions {
7
2
  text: string;
8
3
  thinking_type?: 'enabled' | 'disabled';
@@ -1,5 +1,7 @@
1
1
  import { getAppId } from "../utils/getAppId.js";
2
+ import { getCsrfToken } from "../utils/getCsrfToken.js";
2
3
  import { getEnvPath } from "../utils/getEnvPath.js";
4
+ import { isSanboxMode } from "../utils/utils.js";
3
5
  async function generateTextStream(options, onChunk) {
4
6
  const { text, thinking_type = 'disabled', headers = {} } = options;
5
7
  const appId = getAppId(window.location.pathname);
@@ -10,16 +12,29 @@ async function generateTextStream(options, onChunk) {
10
12
  error: 'appId is required'
11
13
  };
12
14
  try {
13
- const response = await fetch(`${window.location.origin}/ai/api/${getEnvPath()}/v1/apps/${appId}/text/generate`, {
15
+ const mergedHeaders = {
16
+ 'Content-Type': 'application/json',
17
+ ...headers,
18
+ 'X-Kunlun-Token': window.token,
19
+ 'x-miaoda-token': window.MIAODA_BUILTIN_TTT,
20
+ 'x-lgw-csrf-token': window.lgw_csrf_token,
21
+ ...window.CSRF_HEADERS || {}
22
+ };
23
+ let response;
24
+ if (isSanboxMode()) {
25
+ mergedHeaders['X-Suda-Csrf-Token'] = getCsrfToken();
26
+ response = await fetch(`${window.location.origin}/spark/b/${appId}/text/generate`, {
27
+ method: 'POST',
28
+ headers: mergedHeaders,
29
+ credentials: 'include',
30
+ body: JSON.stringify({
31
+ text,
32
+ thinking_type
33
+ })
34
+ });
35
+ } else response = await fetch(`${window.location.origin}/ai/api/${getEnvPath()}/v1/apps/${appId}/text/generate`, {
14
36
  method: 'POST',
15
- headers: {
16
- 'Content-Type': 'application/json',
17
- ...headers,
18
- 'X-Kunlun-Token': window.token,
19
- 'x-miaoda-token': window.MIAODA_BUILTIN_TTT,
20
- 'x-lgw-csrf-token': window.lgw_csrf_token,
21
- ...window.CSRF_HEADERS || {}
22
- },
37
+ headers: mergedHeaders,
23
38
  credentials: 'include',
24
39
  body: JSON.stringify({
25
40
  text,
@@ -28,7 +43,7 @@ async function generateTextStream(options, onChunk) {
28
43
  });
29
44
  if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
30
45
  const reader = response.body?.getReader();
31
- if (!reader) throw new Error('无法获取响应流');
46
+ if (!reader) throw new Error("\u65E0\u6CD5\u83B7\u53D6\u54CD\u5E94\u6D41");
32
47
  let fullContent = '';
33
48
  let fullReasoningContent = '';
34
49
  const decoder = new TextDecoder();
@@ -47,7 +62,7 @@ async function generateTextStream(options, onChunk) {
47
62
  content: '',
48
63
  reasoning_content: '',
49
64
  success: false,
50
- error: data.msg || '生成失败'
65
+ error: data.msg || "\u751F\u6210\u5931\u8D25"
51
66
  };
52
67
  if (data.data.content) fullContent += data.data.content;
53
68
  if (data.data.reasoning_content) fullReasoningContent += data.data.reasoning_content;
@@ -62,7 +77,7 @@ async function generateTextStream(options, onChunk) {
62
77
  success: true
63
78
  };
64
79
  } catch (parseError) {
65
- console.error(`解析JSON失败: ${jsonStr}`);
80
+ console.error(`\u{89E3}\u{6790}JSON\u{5931}\u{8D25}: ${jsonStr}`);
66
81
  }
67
82
  }
68
83
  }
@@ -76,7 +91,7 @@ async function generateTextStream(options, onChunk) {
76
91
  content: '',
77
92
  reasoning_content: '',
78
93
  success: false,
79
- error: error instanceof Error ? error.message : '未知错误'
94
+ error: error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"
80
95
  };
81
96
  }
82
97
  }
@@ -1,2 +1,2 @@
1
1
  import { AppInfoPayload } from '../types/common';
2
- export declare function getAppInfo(): AppInfoPayload;
2
+ export declare function getAppInfo(): Promise<AppInfoPayload>;
@@ -1,4 +1,14 @@
1
- function getAppInfo() {
2
- return window._appInfo || {};
1
+ import { getInitialInfo } from "../utils/getInitialInfo.js";
2
+ import { isSanboxMode } from "../utils/utils.js";
3
+ async function getAppInfo() {
4
+ let appInfo = window._appInfo;
5
+ if (!appInfo && isSanboxMode()) {
6
+ const info = (await getInitialInfo()).app_info;
7
+ appInfo = {
8
+ name: info?.app_name || '',
9
+ avatar: info?.app_avatar || ''
10
+ };
11
+ }
12
+ return appInfo ?? {};
3
13
  }
4
14
  export { getAppInfo };
@@ -1,39 +1,7 @@
1
- @import "tailwindcss";
2
- @layer theme;
1
+ @import "@/inspector.dev.css";
3
2
 
4
3
  @layer base {
5
4
  :root {
6
- --color-background: #fff;
7
- --color-foreground: #1f2329;
8
- --color-card: #fff;
9
- --color-card-foreground: #1f2329;
10
- --color-popover: #fff;
11
- --color-popover-foreground: #1f2329;
12
- --color-primary: #1456f0;
13
- --color-primary-foreground: #f8f9fa;
14
- --color-secondary: #f2f3f5;
15
- --color-secondary-foreground: #1f2329;
16
- --color-muted: #f2f3f5;
17
- --color-muted-foreground: #8f959e;
18
- --color-accent: #f2f3f5;
19
- --color-accent-foreground: #1f2329;
20
- --color-destructive: #f54a45;
21
- --color-border: #dee0e3;
22
- --color-input: #dee0e3;
23
- --color-ring: #d0d3d6;
24
- --color-chart-1: #3370eb;
25
- --color-chart-2: #1bcebf;
26
- --color-chart-3: #ffc60a;
27
- --color-chart-4: #ed6d0c;
28
- --color-chart-5: #dca1e4;
29
- --color-sidebar: #fafafa;
30
- --color-sidebar-foreground: #1f2329;
31
- --color-sidebar-primary: #373c43;
32
- --color-sidebar-primary-foreground: #f8f9fa;
33
- --color-sidebar-accent: #f2f3f5;
34
- --color-sidebar-accent-foreground: #1f2329;
35
- --color-sidebar-border: #dee0e3;
36
- --color-sidebar-ring: #d0d3d6;
37
5
  --color-blue-50: #f0f4ff;
38
6
  --color-blue-100: #e0e9ff;
39
7
  --color-blue-200: #c2d4ff;
@@ -197,53 +165,9 @@
197
165
  --bgTextSelection: 20, 86, 240, .3;
198
166
  --lineDividerDefault: 31, 35, 41, .15;
199
167
  --lineDividerModule: 31, 35, 41, .15;
200
- --font-sans: "Geist", "Geist Fallback", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
201
- --font-serif: "Geist", "Geist Fallback", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
202
- --font-mono: Source Code Pro, monospace;
203
- --radius: .5rem;
204
- --shadow-2xs: 0px 6px 12px 0px #1f232903;
205
- --shadow-xs: 0px 6px 12px 0px #1f232903;
206
- --shadow-sm: 0px 6px 12px 0px #1f232908, 0px 1px 2px -1px #1f232908;
207
- --shadow: 0px 6px 12px 0px #1f232908, 0px 1px 2px -1px #1f232908;
208
- --shadow-md: 0px 6px 12px 0px #1f232908, 0px 2px 4px -1px #1f232908;
209
- --shadow-lg: 0px 6px 12px 0px #1f232908, 0px 4px 6px -1px #1f232908;
210
- --shadow-xl: 0px 6px 12px 0px #1f232908, 0px 8px 10px -1px #1f232908;
211
- --shadow-2xl: 0px 6px 12px 0px #1f232912;
212
- --spacing: .3rem;
213
168
  }
214
169
 
215
170
  .dark {
216
- --color-background: #0a0a0a;
217
- --color-foreground: #ebebeb;
218
- --color-card: #1a1a1a;
219
- --color-card-foreground: #ebebeb;
220
- --color-popover: #1a1a1a;
221
- --color-popover-foreground: #ebebeb;
222
- --color-primary: #336df4;
223
- --color-primary-foreground: #ebebeb;
224
- --color-secondary: #27272a;
225
- --color-secondary-foreground: #fafafa;
226
- --color-muted: #1a1a1a;
227
- --color-muted-foreground: #9f9fa9;
228
- --color-accent: #373737;
229
- --color-accent-foreground: #fafafa;
230
- --color-destructive: #f05b56;
231
- --color-border: #ebebeb26;
232
- --color-input: #ebebeb26;
233
- --color-ring: #505050;
234
- --color-chart-1: #336df4;
235
- --color-chart-2: #00bc7d;
236
- --color-chart-3: #fe9a00;
237
- --color-chart-4: #ad46ff;
238
- --color-chart-5: #ff2056;
239
- --color-sidebar: #18181b;
240
- --color-sidebar-foreground: #ebebeb;
241
- --color-sidebar-primary: #336df4;
242
- --color-sidebar-primary-foreground: #fafafa;
243
- --color-sidebar-accent: #27272a;
244
- --color-sidebar-accent-foreground: #fafafa;
245
- --color-sidebar-border: #ffffff1a;
246
- --color-sidebar-ring: #71717b;
247
171
  --color-blue-50: #152340;
248
172
  --color-blue-100: #173166;
249
173
  --color-blue-200: #194294;
@@ -406,30 +330,6 @@
406
330
  --bgTextSelection: 117, 164, 255, .3;
407
331
  --lineDividerDefault: 207, 207, 207, .15;
408
332
  --lineDividerModule: 0, 0, 0, 1;
409
- --shadow-2xs: 0 1px 3px 0px #0000000d;
410
- --shadow-xs: 0 1px 3px 0px #0000000d;
411
- --shadow-sm: 0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;
412
- --shadow: 0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;
413
- --shadow-md: 0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;
414
- --shadow-lg: 0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;
415
- --shadow-xl: 0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;
416
- --shadow-2xl: 0 1px 3px 0px #00000040;
417
333
  }
418
334
  }
419
335
 
420
- @layer components, utilities;
421
-
422
- @source inline("text-{xs,sm,base,lg,xl,2xl,3xl,4xl,5xl,6xl,7xl,8xl,9xl}");
423
-
424
- @source inline("{bg,text,border}-{blue,pink,neutral,red,orange,violet,lime,yellow,green,teal,cyan,indigo,purple,amber,emerald,slate}-{50,{100..900..100},950}");
425
-
426
- @source inline("{bg,text,border}-{blue,pink,neutral,red,orange,violet,lime,yellow,green,teal,cyan,indigo,purple,amber,emerald,slate}");
427
-
428
- @source inline("{bg,text,border}-neutral-{00,1000}");
429
-
430
- @source inline("rounded-{none,sm,md,lg,xl,full}");
431
-
432
- @theme {
433
- --color-background: var(--color-background) ; --color-foreground: var(--color-foreground) ; --color-card: var(--color-card) ; --color-card-foreground: var(--color-card-foreground) ; --color-popover: var(--color-popover) ; --color-popover-foreground: var(--color-popover-foreground) ; --color-primary: var(--color-primary) ; --color-primary-foreground: var(--color-primary-foreground) ; --color-secondary: var(--color-secondary) ; --color-secondary-foreground: var(--color-secondary-foreground) ; --color-muted: var(--color-muted) ; --color-muted-foreground: var(--color-muted-foreground) ; --color-accent: var(--color-accent) ; --color-accent-foreground: var(--color-accent-foreground) ; --color-destructive: var(--color-destructive) ; --color-border: var(--color-border) ; --color-input: var(--color-input) ; --color-ring: var(--color-ring) ; --color-chart-1: var(--color-chart-1) ; --color-chart-2: var(--color-chart-2) ; --color-chart-3: var(--color-chart-3) ; --color-chart-4: var(--color-chart-4) ; --color-chart-5: var(--color-chart-5) ; --color-sidebar: var(--color-sidebar) ; --color-sidebar-foreground: var(--color-sidebar-foreground) ; --color-sidebar-primary: var(--color-sidebar-primary) ; --color-sidebar-primary-foreground: var(--color-sidebar-primary-foreground) ; --color-sidebar-accent: var(--color-sidebar-accent) ; --color-sidebar-accent-foreground: var(--color-sidebar-accent-foreground) ; --color-sidebar-border: var(--color-sidebar-border) ; --color-sidebar-ring: var(--color-sidebar-ring) ; --color-crm-blue: #3b82f6; --color-crm-lightBlue: #93c5fd; --color-crm-darkBlue: #1e40af; --color-crm-gray: #6b7280; --color-crm-lightGray: #e5e7eb; --color-crm-darkGray: #374151; --font-sans: var(--font-sans) ; --font-mono: var(--font-mono) ; --font-serif: var(--font-serif) ; --radius-sm: calc(var(--radius) - 4px) ; --radius: var(--radius) ; --radius-md: calc(var(--radius) - 2px) ; --radius-lg: var(--radius) ; --radius-xl: calc(var(--radius) + 4px) ; --shadow-2xs: var(--shadow-2xs) ; --shadow-xs: var(--shadow-xs) ; --shadow-sm: var(--shadow-sm) ; --shadow: var(--shadow) ; --shadow-md: var(--shadow-md) ; --shadow-lg: var(--shadow-lg) ; --shadow-xl: var(--shadow-xl) ; --shadow-2xl: var(--shadow-2xl) ;
434
- }
435
-
@@ -0,0 +1,3 @@
1
+ @layer theme, base, antd, components, utilities;
2
+ @import "tailwindcss";
3
+
@@ -2,10 +2,3 @@ export interface AppInfoPayload {
2
2
  name: string;
3
3
  avatar: string;
4
4
  }
5
- declare global {
6
- interface Window {
7
- MIAODA_APP_ID?: string;
8
- MIAODA_BUILTIN_TTT?: string;
9
- token?: string;
10
- }
11
- }
@@ -30,8 +30,16 @@ export interface UpdateRoutesMessage extends IframeMessage<{
30
30
  }> {
31
31
  type: 'UpdateRoutes';
32
32
  }
33
- export type OutgoingMessage = PreviewReadyMessage | ConsoleMessage | ChildLocationChangeMessage | CreatePageMessage | RenderErrorMessage | RenderErrorRepairMessage | PageScreenshotMessage | UpdateRoutesMessage;
33
+ export interface HmrMessage extends IframeMessage<Record<string, never>> {
34
+ type: 'Hmr';
35
+ }
36
+ export type OutgoingMessage = PreviewReadyMessage | HmrMessage | ConsoleMessage | ChildLocationChangeMessage | CreatePageMessage | RenderErrorMessage | RenderErrorRepairMessage | PageScreenshotMessage | UpdateRoutesMessage;
34
37
  export interface GetRoutesMessage extends IframeMessage<Record<string, never>> {
35
38
  type: 'GetRoutes';
36
39
  }
37
40
  export type IncomingMessage = GetRoutesMessage;
41
+ export interface ParentApi {
42
+ }
43
+ export interface ChildApi {
44
+ getRoutes: () => Promise<any[]>;
45
+ }
@@ -36,5 +36,7 @@ declare global {
36
36
  MIAODA_BUILTIN_TTT?: string;
37
37
  MIAODA_APP_ID?: string;
38
38
  IS_MIAODA_PREVIEW?: boolean;
39
+ _IS_Spark_RUNTIME?: boolean;
40
+ _bucket_id?: string;
39
41
  }
40
42
  }
@@ -6,7 +6,7 @@ async function copyToClipboard(text) {
6
6
  }
7
7
  return fallbackCopyToClipboard(text);
8
8
  } catch (error) {
9
- console.error('复制到剪切板失败:', error);
9
+ console.error("\u590D\u5236\u5230\u526A\u5207\u677F\u5931\u8D25:", error);
10
10
  return false;
11
11
  }
12
12
  }
@@ -25,7 +25,7 @@ function fallbackCopyToClipboard(text) {
25
25
  document.body.removeChild(textArea);
26
26
  return successful;
27
27
  } catch (error) {
28
- console.error('降级复制方案失败:', error);
28
+ console.error("\u964D\u7EA7\u590D\u5236\u65B9\u6848\u5931\u8D25:", error);
29
29
  return false;
30
30
  }
31
31
  }
@@ -1,11 +1,6 @@
1
- declare global {
2
- interface Window {
3
- MIAODA_APP_ID?: string;
4
- }
5
- }
6
1
  /**
7
2
  * 提取固定前缀后的第一个目录名
8
3
  * @param {string} path - 输入路径字符串
9
4
  * @returns {string|null} - 提取的目录名或null
10
5
  */
11
- export declare function getAppId(path: string): string;
6
+ export declare function getAppId(path: string): string | null;
@@ -1,9 +1,11 @@
1
1
  function getAppId(path) {
2
2
  if (window.MIAODA_APP_ID) return window.MIAODA_APP_ID;
3
- const prefix = location.pathname.includes('/ai/feida/runtime/') ? '/ai/feida/runtime/' : '/ai/miaoda/';
3
+ let prefix;
4
+ prefix = path.includes('/ai/feida/runtime/') ? '/ai/feida/runtime/' : path.includes('/spark/r/') ? '/spark/r/' : '/ai/miaoda/';
4
5
  if (!path.startsWith(prefix)) return null;
5
6
  const remainder = path.substring(prefix.length);
6
7
  const nextSlashIndex = remainder.indexOf('/');
7
- return -1 === nextSlashIndex ? remainder : remainder.substring(0, nextSlashIndex);
8
+ if (-1 === nextSlashIndex) return remainder;
9
+ return remainder.substring(0, nextSlashIndex);
8
10
  }
9
11
  export { getAppId };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 获取cookie中存放的suda-csrf-token值
3
+ * @returns {string | null} - suda-csrf-token的值,如果不存在则返回null
4
+ */
5
+ export declare function getCsrfToken(): string;
@@ -0,0 +1,10 @@
1
+ function getCsrfToken() {
2
+ const cookieName = 'suda-csrf-token';
3
+ const cookies = document.cookie.split('; ');
4
+ for (const cookie of cookies){
5
+ const [name, value] = cookie.split('=');
6
+ if (name === cookieName) return decodeURIComponent(value);
7
+ }
8
+ return null;
9
+ }
10
+ export { getCsrfToken };