Skip to content

Commit

Permalink
fix: 修复老组件报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft committed Oct 14, 2024
1 parent 472596b commit c81d9be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/editor/src/packages/IFrame/IFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const IFrame = ({ id, type, config }: ComponentType, ref: any) => {
});
// 裁剪后,重新计算高度
const height = useMemo(() => {
const { top } = config.props.clip;
// TODO: 临时兼容老版本,后续需要删除
const { top } = config.props.clip || { top: '0px' };
let height = '100%';
const px = (num: string) => Number(num.replace('px', ''));
const topPx = px(top);
Expand All @@ -33,9 +34,9 @@ const IFrame = ({ id, type, config }: ComponentType, ref: any) => {
}, [config.props.clip]);
return (
visible && (
<div className="" style={config.style} data-id={id} data-type={type}>
<div style={config.style} data-id={id} data-type={type}>
<iframe
style={{ position: 'absolute', top: config.props.clip.top, left: 0, width: '100%', height, border: 'none' }}
style={{ position: 'absolute', top: config.props.clip?.top || 0, left: 0, width: '100%', height, border: 'none' }}
{...config.props}
></iframe>
</div>
Expand Down
5 changes: 3 additions & 2 deletions packages/materials/IFrame/IFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const IFrame = ({ config }: ComponentType, ref: any) => {
});
// 裁剪后,重新计算高度
const height = useMemo(() => {
const { top } = config.props.clip;
// TODO: 临时兼容老版本,后续需要删除
const { top } = config.props.clip || { top: '0px' };
let height = '100%';
const px = (num: string) => Number(num.replace('px', ''));
const topPx = px(top);
Expand All @@ -35,7 +36,7 @@ const IFrame = ({ config }: ComponentType, ref: any) => {
visible && (
<div style={config.style}>
<iframe
style={{ position: 'absolute', top: config.props.clip.top, left: 0, width: '100%', height, border: 'none' }}
style={{ position: 'absolute', top: config.props.clip?.top || 0, left: 0, width: '100%', height, border: 'none' }}
{...config.props}
></iframe>
</div>
Expand Down

0 comments on commit c81d9be

Please sign in to comment.