react-ai-renderer 0.1.16 → 0.1.17

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/dist/index.d.ts CHANGED
@@ -1,5 +1,28 @@
1
1
  import React from 'react';
2
2
 
3
+ /**
4
+ * 骨架图配置接口
5
+ */
6
+ interface SkeletonConfig {
7
+ /** 自定义骨架图组件 */
8
+ component?: React.ComponentType<SkeletonProps>;
9
+ /** 自定义骨架图元素 */
10
+ element?: React.ReactElement;
11
+ /** 自定义骨架图生成函数 */
12
+ generator?: (props: SkeletonProps) => React.ReactElement;
13
+ /** 是否启用自动生成 */
14
+ autoGenerate?: boolean;
15
+ }
16
+ /**
17
+ * 骨架图组件的属性
18
+ */
19
+ interface SkeletonProps {
20
+ componentName: string;
21
+ componentData?: ComponentData$1;
22
+ props?: Record<string, any>;
23
+ style?: React.CSSProperties;
24
+ }
25
+
3
26
  interface ComponentData$1 {
4
27
  type: "text" | "component";
5
28
  value: string;
@@ -22,6 +45,8 @@ interface ComponentHandler extends BaseComponentHandler {
22
45
  onRender?: (item: ComponentData$1, scope: any) => void;
23
46
  /** 自定义加载组件,可以是 React 组件、React 元素、字符串、布尔值或返回 React 元素的函数 */
24
47
  loader?: React.ComponentType<any> | React.ReactElement | string | boolean | ((componentName: string) => React.ReactElement);
48
+ /** 骨架图配置,用于在加载时显示骨架图。如果未提供且 loader 也未提供,将自动根据组件名称生成骨架图 */
49
+ skeleton?: SkeletonConfig;
25
50
  /** 组件的显示标签,用于在占位组件中显示 */
26
51
  label?: string;
27
52
  }
@@ -33,6 +58,8 @@ interface EnhancedComponentConfig {
33
58
  label?: string;
34
59
  /** 自定义加载组件,可以是 React 组件、React 元素、字符串、布尔值或返回 React 元素的函数 */
35
60
  loader?: React.ComponentType<any> | React.ReactElement | string | boolean | ((componentName: string) => React.ReactElement);
61
+ /** 骨架图配置,用于在加载时显示骨架图。如果未提供且 loader 也未提供,将自动根据组件名称生成骨架图 */
62
+ skeleton?: SkeletonConfig;
36
63
  /** 组件渲染完成后的钩子 */
37
64
  onRenderFinished?: (item: ComponentData$1, scope: any) => void;
38
65
  /** 组件渲染过程中的钩子 */
package/dist/index.js CHANGED
@@ -8,7 +8,6 @@ import RemarkGfm from 'remark-gfm';
8
8
  import { run, compile } from '@mdx-js/mdx';
9
9
  import RehypeKatex from 'rehype-katex';
10
10
  import RehypeHighlight from 'rehype-highlight';
11
- import RehypeRaw from 'rehype-raw';
12
11
 
13
12
  // SSR 兼容性 polyfill
14
13
  // 这个文件确保在服务端渲染时不会因为访问 document 而报错
@@ -58337,13 +58336,13 @@ function renderText(textContent, scope, registeredComponents) {
58337
58336
  children: textContent,
58338
58337
  components: registeredComponents,
58339
58338
  remarkPlugins: [RemarkMath, RemarkGfm, RemarkBreaks],
58340
- rehypePlugins: [RehypeRaw, RehypeKatex, [RehypeHighlight, {
58339
+ rehypePlugins: [RehypeKatex, [RehypeHighlight, {
58341
58340
  detect: false,
58342
58341
  ignoreMissing: true,
58343
58342
  plainText: ['mermaid'] // 将mermaid作为纯文本处理,避免被错误高亮
58344
58343
  }]],
58345
58344
  remarkRehypeOptions: {
58346
- allowDangerousHtml: true // 允许处理 HTML 标签
58345
+ allowDangerousHtml: false // 允许处理 HTML 标签
58347
58346
  }
58348
58347
  })];
58349
58348
  });
@@ -58603,10 +58602,523 @@ function MdxLayout(_a) {
58603
58602
  });
58604
58603
  }
58605
58604
 
58605
+ function generateSkeletonByComponentName(componentName, props, style) {
58606
+ var _a, _b;
58607
+ var baseStyle = __assign({
58608
+ borderRadius: '8px',
58609
+ backgroundColor: '#f3f4f6'
58610
+ }, style);
58611
+ // 根据组件名称模式匹配生成不同的骨架图
58612
+ var name = componentName.toLowerCase();
58613
+ // 图表类组件
58614
+ if (name.includes('chart') || name.includes('graph') || name.includes('plot')) {
58615
+ return /*#__PURE__*/jsxs("div", {
58616
+ style: __assign(__assign({}, baseStyle), {
58617
+ padding: '24px',
58618
+ minHeight: (props === null || props === void 0 ? void 0 : props.height) ? "".concat(props.height, "px") : '300px',
58619
+ display: 'flex',
58620
+ flexDirection: 'column',
58621
+ gap: '12px'
58622
+ }),
58623
+ children: [/*#__PURE__*/jsxs("div", {
58624
+ style: {
58625
+ display: 'flex',
58626
+ justifyContent: 'space-between',
58627
+ alignItems: 'center',
58628
+ marginBottom: '8px'
58629
+ },
58630
+ children: [/*#__PURE__*/jsx("div", {
58631
+ style: {
58632
+ width: '120px',
58633
+ height: '20px',
58634
+ backgroundColor: '#e5e7eb',
58635
+ borderRadius: '4px'
58636
+ }
58637
+ }), /*#__PURE__*/jsx("div", {
58638
+ style: {
58639
+ width: '80px',
58640
+ height: '16px',
58641
+ backgroundColor: '#e5e7eb',
58642
+ borderRadius: '4px'
58643
+ }
58644
+ })]
58645
+ }), /*#__PURE__*/jsx("div", {
58646
+ style: {
58647
+ flex: 1,
58648
+ display: 'flex',
58649
+ alignItems: 'flex-end',
58650
+ gap: '8px',
58651
+ height: '200px'
58652
+ },
58653
+ children: Array.from({
58654
+ length: 8
58655
+ }).map(function (_, i) {
58656
+ return /*#__PURE__*/jsx("div", {
58657
+ style: {
58658
+ flex: 1,
58659
+ height: "".concat(Math.random() * 60 + 40, "%"),
58660
+ backgroundColor: '#d1d5db',
58661
+ borderRadius: '4px 4px 0 0',
58662
+ animation: 'pulse 1.5s ease-in-out infinite',
58663
+ animationDelay: "".concat(i * 0.1, "s")
58664
+ }
58665
+ }, i);
58666
+ })
58667
+ }), /*#__PURE__*/jsx("div", {
58668
+ style: {
58669
+ display: 'flex',
58670
+ gap: '12px',
58671
+ marginTop: '8px'
58672
+ },
58673
+ children: Array.from({
58674
+ length: 3
58675
+ }).map(function (_, i) {
58676
+ return /*#__PURE__*/jsxs("div", {
58677
+ style: {
58678
+ display: 'flex',
58679
+ alignItems: 'center',
58680
+ gap: '6px'
58681
+ },
58682
+ children: [/*#__PURE__*/jsx("div", {
58683
+ style: {
58684
+ width: '12px',
58685
+ height: '12px',
58686
+ backgroundColor: '#d1d5db',
58687
+ borderRadius: '2px'
58688
+ }
58689
+ }), /*#__PURE__*/jsx("div", {
58690
+ style: {
58691
+ width: '60px',
58692
+ height: '12px',
58693
+ backgroundColor: '#e5e7eb',
58694
+ borderRadius: '2px'
58695
+ }
58696
+ })]
58697
+ }, i);
58698
+ })
58699
+ }), /*#__PURE__*/jsx("style", {
58700
+ children: "\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "
58701
+ })]
58702
+ });
58703
+ }
58704
+ // 表格类组件
58705
+ if (name.includes('table') || name.includes('grid')) {
58706
+ var rowCount_1 = (props === null || props === void 0 ? void 0 : props.rows) || 5;
58707
+ var colCount_1 = (props === null || props === void 0 ? void 0 : props.columns) || 4;
58708
+ return /*#__PURE__*/jsxs("div", {
58709
+ style: __assign(__assign({}, baseStyle), {
58710
+ padding: '16px',
58711
+ overflow: 'hidden'
58712
+ }),
58713
+ children: [/*#__PURE__*/jsxs("div", {
58714
+ style: {
58715
+ marginBottom: '12px'
58716
+ },
58717
+ children: [/*#__PURE__*/jsx("div", {
58718
+ style: {
58719
+ width: '150px',
58720
+ height: '20px',
58721
+ backgroundColor: '#e5e7eb',
58722
+ borderRadius: '4px',
58723
+ marginBottom: '8px'
58724
+ }
58725
+ }), /*#__PURE__*/jsx("div", {
58726
+ style: {
58727
+ width: '200px',
58728
+ height: '16px',
58729
+ backgroundColor: '#e5e7eb',
58730
+ borderRadius: '4px'
58731
+ }
58732
+ })]
58733
+ }), /*#__PURE__*/jsxs("div", {
58734
+ style: {
58735
+ border: '1px solid #e5e7eb',
58736
+ borderRadius: '4px',
58737
+ overflow: 'hidden'
58738
+ },
58739
+ children: [/*#__PURE__*/jsx("div", {
58740
+ style: {
58741
+ display: 'grid',
58742
+ gridTemplateColumns: "repeat(".concat(colCount_1, ", 1fr)"),
58743
+ backgroundColor: '#f9fafb',
58744
+ borderBottom: '1px solid #e5e7eb'
58745
+ },
58746
+ children: Array.from({
58747
+ length: colCount_1
58748
+ }).map(function (_, i) {
58749
+ return /*#__PURE__*/jsx("div", {
58750
+ style: {
58751
+ padding: '12px',
58752
+ borderRight: i < colCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58753
+ },
58754
+ children: /*#__PURE__*/jsx("div", {
58755
+ style: {
58756
+ width: '80%',
58757
+ height: '16px',
58758
+ backgroundColor: '#d1d5db',
58759
+ borderRadius: '2px'
58760
+ }
58761
+ })
58762
+ }, i);
58763
+ })
58764
+ }), Array.from({
58765
+ length: rowCount_1
58766
+ }).map(function (_, rowIndex) {
58767
+ return /*#__PURE__*/jsx("div", {
58768
+ style: {
58769
+ display: 'grid',
58770
+ gridTemplateColumns: "repeat(".concat(colCount_1, ", 1fr)"),
58771
+ borderBottom: rowIndex < rowCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58772
+ },
58773
+ children: Array.from({
58774
+ length: colCount_1
58775
+ }).map(function (_, colIndex) {
58776
+ return /*#__PURE__*/jsx("div", {
58777
+ style: {
58778
+ padding: '12px',
58779
+ borderRight: colIndex < colCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58780
+ },
58781
+ children: /*#__PURE__*/jsx("div", {
58782
+ style: {
58783
+ width: "".concat(Math.random() * 40 + 60, "%"),
58784
+ height: '14px',
58785
+ backgroundColor: '#e5e7eb',
58786
+ borderRadius: '2px'
58787
+ }
58788
+ })
58789
+ }, colIndex);
58790
+ })
58791
+ }, rowIndex);
58792
+ })]
58793
+ })]
58794
+ });
58795
+ }
58796
+ // 卡片类组件
58797
+ if (name.includes('card')) {
58798
+ return /*#__PURE__*/jsxs("div", {
58799
+ style: __assign(__assign({}, baseStyle), {
58800
+ padding: '20px',
58801
+ minHeight: '200px'
58802
+ }),
58803
+ children: [/*#__PURE__*/jsx("div", {
58804
+ style: {
58805
+ width: '60%',
58806
+ height: '24px',
58807
+ backgroundColor: '#e5e7eb',
58808
+ borderRadius: '4px',
58809
+ marginBottom: '16px'
58810
+ }
58811
+ }), /*#__PURE__*/jsx("div", {
58812
+ style: {
58813
+ width: '100%',
58814
+ height: '16px',
58815
+ backgroundColor: '#e5e7eb',
58816
+ borderRadius: '4px',
58817
+ marginBottom: '8px'
58818
+ }
58819
+ }), /*#__PURE__*/jsx("div", {
58820
+ style: {
58821
+ width: '90%',
58822
+ height: '16px',
58823
+ backgroundColor: '#e5e7eb',
58824
+ borderRadius: '4px',
58825
+ marginBottom: '8px'
58826
+ }
58827
+ }), /*#__PURE__*/jsx("div", {
58828
+ style: {
58829
+ width: '70%',
58830
+ height: '16px',
58831
+ backgroundColor: '#e5e7eb',
58832
+ borderRadius: '4px',
58833
+ marginBottom: '16px'
58834
+ }
58835
+ }), /*#__PURE__*/jsxs("div", {
58836
+ style: {
58837
+ display: 'flex',
58838
+ gap: '8px',
58839
+ marginTop: '16px'
58840
+ },
58841
+ children: [/*#__PURE__*/jsx("div", {
58842
+ style: {
58843
+ width: '80px',
58844
+ height: '32px',
58845
+ backgroundColor: '#d1d5db',
58846
+ borderRadius: '4px'
58847
+ }
58848
+ }), /*#__PURE__*/jsx("div", {
58849
+ style: {
58850
+ width: '80px',
58851
+ height: '32px',
58852
+ backgroundColor: '#d1d5db',
58853
+ borderRadius: '4px'
58854
+ }
58855
+ })]
58856
+ })]
58857
+ });
58858
+ }
58859
+ // 列表类组件
58860
+ if (name.includes('list') || name.includes('todo')) {
58861
+ var itemCount_1 = ((_a = props === null || props === void 0 ? void 0 : props.items) === null || _a === void 0 ? void 0 : _a.length) || (props === null || props === void 0 ? void 0 : props.count) || 3;
58862
+ return /*#__PURE__*/jsx("div", {
58863
+ style: __assign(__assign({}, baseStyle), {
58864
+ padding: '16px'
58865
+ }),
58866
+ children: Array.from({
58867
+ length: itemCount_1
58868
+ }).map(function (_, i) {
58869
+ return /*#__PURE__*/jsxs("div", {
58870
+ style: {
58871
+ display: 'flex',
58872
+ alignItems: 'center',
58873
+ gap: '12px',
58874
+ marginBottom: i < itemCount_1 - 1 ? '12px' : '0',
58875
+ paddingBottom: i < itemCount_1 - 1 ? '12px' : '0',
58876
+ borderBottom: i < itemCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58877
+ },
58878
+ children: [/*#__PURE__*/jsx("div", {
58879
+ style: {
58880
+ width: '20px',
58881
+ height: '20px',
58882
+ backgroundColor: '#d1d5db',
58883
+ borderRadius: '4px',
58884
+ flexShrink: 0
58885
+ }
58886
+ }), /*#__PURE__*/jsxs("div", {
58887
+ style: {
58888
+ flex: 1
58889
+ },
58890
+ children: [/*#__PURE__*/jsx("div", {
58891
+ style: {
58892
+ width: "".concat(Math.random() * 30 + 60, "%"),
58893
+ height: '16px',
58894
+ backgroundColor: '#e5e7eb',
58895
+ borderRadius: '4px',
58896
+ marginBottom: '6px'
58897
+ }
58898
+ }), /*#__PURE__*/jsx("div", {
58899
+ style: {
58900
+ width: "".concat(Math.random() * 40 + 40, "%"),
58901
+ height: '14px',
58902
+ backgroundColor: '#e5e7eb',
58903
+ borderRadius: '4px'
58904
+ }
58905
+ })]
58906
+ })]
58907
+ }, i);
58908
+ })
58909
+ });
58910
+ }
58911
+ // 表单类组件
58912
+ if (name.includes('form') || name.includes('input') || name.includes('select')) {
58913
+ var fieldCount_1 = ((_b = props === null || props === void 0 ? void 0 : props.fields) === null || _b === void 0 ? void 0 : _b.length) || 3;
58914
+ return /*#__PURE__*/jsxs("div", {
58915
+ style: __assign(__assign({}, baseStyle), {
58916
+ padding: '20px'
58917
+ }),
58918
+ children: [Array.from({
58919
+ length: fieldCount_1
58920
+ }).map(function (_, i) {
58921
+ return /*#__PURE__*/jsxs("div", {
58922
+ style: {
58923
+ marginBottom: i < fieldCount_1 - 1 ? '20px' : '0'
58924
+ },
58925
+ children: [/*#__PURE__*/jsx("div", {
58926
+ style: {
58927
+ width: '100px',
58928
+ height: '14px',
58929
+ backgroundColor: '#e5e7eb',
58930
+ borderRadius: '2px',
58931
+ marginBottom: '8px'
58932
+ }
58933
+ }), /*#__PURE__*/jsx("div", {
58934
+ style: {
58935
+ width: '100%',
58936
+ height: '40px',
58937
+ backgroundColor: '#f3f4f6',
58938
+ border: '1px solid #e5e7eb',
58939
+ borderRadius: '4px'
58940
+ }
58941
+ })]
58942
+ }, i);
58943
+ }), /*#__PURE__*/jsxs("div", {
58944
+ style: {
58945
+ display: 'flex',
58946
+ gap: '12px',
58947
+ marginTop: '20px'
58948
+ },
58949
+ children: [/*#__PURE__*/jsx("div", {
58950
+ style: {
58951
+ width: '100px',
58952
+ height: '36px',
58953
+ backgroundColor: '#d1d5db',
58954
+ borderRadius: '4px'
58955
+ }
58956
+ }), /*#__PURE__*/jsx("div", {
58957
+ style: {
58958
+ width: '100px',
58959
+ height: '36px',
58960
+ backgroundColor: '#e5e7eb',
58961
+ borderRadius: '4px'
58962
+ }
58963
+ })]
58964
+ })]
58965
+ });
58966
+ }
58967
+ // 图片/媒体类组件
58968
+ if (name.includes('image') || name.includes('img') || name.includes('video') || name.includes('media')) {
58969
+ return /*#__PURE__*/jsx("div", {
58970
+ style: __assign(__assign({}, baseStyle), {
58971
+ padding: '16px',
58972
+ display: 'flex',
58973
+ alignItems: 'center',
58974
+ justifyContent: 'center',
58975
+ minHeight: (props === null || props === void 0 ? void 0 : props.height) ? "".concat(props.height, "px") : '200px'
58976
+ }),
58977
+ children: /*#__PURE__*/jsx("div", {
58978
+ style: {
58979
+ width: '100%',
58980
+ height: '100%',
58981
+ backgroundColor: '#e5e7eb',
58982
+ borderRadius: '8px',
58983
+ display: 'flex',
58984
+ alignItems: 'center',
58985
+ justifyContent: 'center'
58986
+ },
58987
+ children: /*#__PURE__*/jsx("div", {
58988
+ style: {
58989
+ width: '48px',
58990
+ height: '48px',
58991
+ backgroundColor: '#d1d5db',
58992
+ borderRadius: '50%',
58993
+ display: 'flex',
58994
+ alignItems: 'center',
58995
+ justifyContent: 'center'
58996
+ },
58997
+ children: /*#__PURE__*/jsx("div", {
58998
+ style: {
58999
+ width: '24px',
59000
+ height: '24px',
59001
+ backgroundColor: '#9ca3af',
59002
+ borderRadius: '4px'
59003
+ }
59004
+ })
59005
+ })
59006
+ })
59007
+ });
59008
+ }
59009
+ // 默认骨架图
59010
+ return /*#__PURE__*/jsxs("div", {
59011
+ style: __assign(__assign({}, baseStyle), {
59012
+ padding: '24px',
59013
+ minHeight: '120px',
59014
+ display: 'flex',
59015
+ flexDirection: 'column',
59016
+ gap: '12px',
59017
+ alignItems: 'center',
59018
+ justifyContent: 'center'
59019
+ }),
59020
+ children: [/*#__PURE__*/jsxs("div", {
59021
+ style: {
59022
+ width: '100%',
59023
+ maxWidth: '400px'
59024
+ },
59025
+ children: [/*#__PURE__*/jsx("div", {
59026
+ style: {
59027
+ width: '60%',
59028
+ height: '20px',
59029
+ backgroundColor: '#e5e7eb',
59030
+ borderRadius: '4px',
59031
+ marginBottom: '12px'
59032
+ }
59033
+ }), /*#__PURE__*/jsx("div", {
59034
+ style: {
59035
+ width: '100%',
59036
+ height: '16px',
59037
+ backgroundColor: '#e5e7eb',
59038
+ borderRadius: '4px',
59039
+ marginBottom: '8px'
59040
+ }
59041
+ }), /*#__PURE__*/jsx("div", {
59042
+ style: {
59043
+ width: '90%',
59044
+ height: '16px',
59045
+ backgroundColor: '#e5e7eb',
59046
+ borderRadius: '4px',
59047
+ marginBottom: '8px'
59048
+ }
59049
+ }), /*#__PURE__*/jsx("div", {
59050
+ style: {
59051
+ width: '75%',
59052
+ height: '16px',
59053
+ backgroundColor: '#e5e7eb',
59054
+ borderRadius: '4px'
59055
+ }
59056
+ })]
59057
+ }), /*#__PURE__*/jsxs("div", {
59058
+ style: {
59059
+ display: 'flex',
59060
+ gap: '8px',
59061
+ marginTop: '12px'
59062
+ },
59063
+ children: [/*#__PURE__*/jsx("div", {
59064
+ style: {
59065
+ width: '60px',
59066
+ height: '32px',
59067
+ backgroundColor: '#d1d5db',
59068
+ borderRadius: '4px'
59069
+ }
59070
+ }), /*#__PURE__*/jsx("div", {
59071
+ style: {
59072
+ width: '60px',
59073
+ height: '32px',
59074
+ backgroundColor: '#d1d5db',
59075
+ borderRadius: '4px'
59076
+ }
59077
+ })]
59078
+ })]
59079
+ });
59080
+ }
59081
+ /**
59082
+ * 创建骨架图组件
59083
+ */
59084
+ function createSkeletonComponent(componentName, componentData, skeletonConfig, style) {
59085
+ // 如果提供了自定义骨架图组件
59086
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.component) {
59087
+ var SkeletonComponent = skeletonConfig.component;
59088
+ return /*#__PURE__*/jsx(SkeletonComponent, {
59089
+ componentName: componentName,
59090
+ componentData: componentData,
59091
+ props: componentData === null || componentData === void 0 ? void 0 : componentData.props,
59092
+ style: style
59093
+ });
59094
+ }
59095
+ // 如果提供了自定义骨架图元素
59096
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.element) {
59097
+ return skeletonConfig.element;
59098
+ }
59099
+ // 如果提供了自定义生成函数
59100
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.generator) {
59101
+ return skeletonConfig.generator({
59102
+ componentName: componentName,
59103
+ componentData: componentData,
59104
+ props: componentData === null || componentData === void 0 ? void 0 : componentData.props,
59105
+ style: style
59106
+ });
59107
+ }
59108
+ // 如果启用了自动生成,或者没有提供任何配置
59109
+ if ((skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.autoGenerate) !== false) {
59110
+ return generateSkeletonByComponentName(componentName, componentData === null || componentData === void 0 ? void 0 : componentData.props, style);
59111
+ }
59112
+ // 默认返回空
59113
+ return /*#__PURE__*/jsx(React__default.Fragment, {});
59114
+ }
59115
+
58606
59116
  var ComponentPlaceholder = function (_a) {
58607
59117
  var componentName = _a.componentName,
58608
59118
  style = _a.style,
58609
- loader = _a.loader;
59119
+ loader = _a.loader,
59120
+ skeleton = _a.skeleton,
59121
+ componentData = _a.componentData;
58610
59122
  // 如果有自定义加载内容,优先使用
58611
59123
  if (loader) {
58612
59124
  // 如果是布尔值 true,使用默认样式
@@ -58658,6 +59170,19 @@ var ComponentPlaceholder = function (_a) {
58658
59170
  }
58659
59171
  }
58660
59172
  }
59173
+ // 如果没有 loader,尝试使用骨架图
59174
+ if (skeleton || !loader) {
59175
+ try {
59176
+ var skeletonElement = createSkeletonComponent(componentName, componentData, skeleton, style);
59177
+ // 如果骨架图生成成功且不是空元素,使用骨架图
59178
+ if (skeletonElement && /*#__PURE__*/React__default.isValidElement(skeletonElement)) {
59179
+ return skeletonElement;
59180
+ }
59181
+ } catch (e) {
59182
+ // 如果骨架图生成失败,继续使用默认占位内容
59183
+ console.warn('Failed to generate skeleton:', e);
59184
+ }
59185
+ }
58661
59186
  // 默认占位内容
58662
59187
  return /*#__PURE__*/jsxs("div", {
58663
59188
  style: __assign({