Skip to content

Commit 0c9c6bc

Browse files
committed
fix(web): 修复笔记预览时如果数据为空(出现于旧版笔记)则会报错的bug
1 parent 291a98f commit 0c9c6bc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/web/components/editor/Previewer.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { SlateElement } from './render/Element';
66
import { SlateLeaf } from './render/Leaf';
77
import { TMemo } from '@shared/components/TMemo';
88
import { WebErrorBoundary } from '../WebErrorBoundary';
9+
import _isArray from 'lodash/isArray';
10+
import { Result } from 'antd';
911

1012
export const Previewer: React.FC<{
1113
value: TRPGEditorNode[];
@@ -14,6 +16,12 @@ export const Previewer: React.FC<{
1416
const renderElement = useCallback((props) => <SlateElement {...props} />, []);
1517
const renderLeaf = useCallback((props) => <SlateLeaf {...props} />, []);
1618

19+
if (!_isArray(props.value)) {
20+
return (
21+
<Result status="warning" title="笔记数据异常, 请检查是否为旧版笔记" />
22+
);
23+
}
24+
1725
return (
1826
<WebErrorBoundary>
1927
<Slate editor={editor} value={props.value} onChange={(value) => {}}>

0 commit comments

Comments
 (0)