Merge pull request #7432 from nwind/chore-office-viewer-inited

chore: 进一步避免 office viewer 在 loading 时更新
This commit is contained in:
hsm-lv 2023-07-10 10:49:12 +08:00 committed by GitHub
commit 2bdfb1a9f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,9 +62,6 @@ export default class OfficeViewer extends React.Component<
// 文档数据,避免 update 参数的时候重复加载
document?: any;
// 是否已经初始化过
inited?: boolean;
constructor(props: OfficeViewerProps) {
super(props);
this.rootElement = React.createRef();
@ -80,8 +77,8 @@ export default class OfficeViewer extends React.Component<
}
componentDidUpdate(prevProps: OfficeViewerProps) {
// 避免无限更新
if (!this.inited) {
// 避免 loading 时更新
if (this.state.loading) {
return;
}
const props = this.props;
@ -153,7 +150,6 @@ export default class OfficeViewer extends React.Component<
} else if (name) {
this.renderFormFile();
}
this.inited = true;
}
async fetchWord() {
@ -187,7 +183,6 @@ export default class OfficeViewer extends React.Component<
this.rootElement.current.innerHTML =
__('loadingFailed') + ' url:' + finalSrc;
}
return;
} finally {
this.setState({
loading: false