mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
Merge pull request #7432 from nwind/chore-office-viewer-inited
chore: 进一步避免 office viewer 在 loading 时更新
This commit is contained in:
commit
2bdfb1a9f8
@ -62,9 +62,6 @@ export default class OfficeViewer extends React.Component<
|
|||||||
// 文档数据,避免 update 参数的时候重复加载
|
// 文档数据,避免 update 参数的时候重复加载
|
||||||
document?: any;
|
document?: any;
|
||||||
|
|
||||||
// 是否已经初始化过
|
|
||||||
inited?: boolean;
|
|
||||||
|
|
||||||
constructor(props: OfficeViewerProps) {
|
constructor(props: OfficeViewerProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.rootElement = React.createRef();
|
this.rootElement = React.createRef();
|
||||||
@ -80,8 +77,8 @@ export default class OfficeViewer extends React.Component<
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps: OfficeViewerProps) {
|
componentDidUpdate(prevProps: OfficeViewerProps) {
|
||||||
// 避免无限更新
|
// 避免 loading 时更新
|
||||||
if (!this.inited) {
|
if (this.state.loading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
@ -153,7 +150,6 @@ export default class OfficeViewer extends React.Component<
|
|||||||
} else if (name) {
|
} else if (name) {
|
||||||
this.renderFormFile();
|
this.renderFormFile();
|
||||||
}
|
}
|
||||||
this.inited = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchWord() {
|
async fetchWord() {
|
||||||
@ -187,7 +183,6 @@ export default class OfficeViewer extends React.Component<
|
|||||||
this.rootElement.current.innerHTML =
|
this.rootElement.current.innerHTML =
|
||||||
__('loadingFailed') + ' url:' + finalSrc;
|
__('loadingFailed') + ' url:' + finalSrc;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
} finally {
|
} finally {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false
|
loading: false
|
||||||
|
Loading…
Reference in New Issue
Block a user