Commit 29f73553 by zhaochengxiang

代码优化

parent 1245dced
......@@ -288,11 +288,11 @@ const ModelTable = (props) => {
useEffect(() => {
if ((modelId||'') !== '') {
window?.addEventListener("storage", (e) => {
if (e.key === 'modelChange') {
getCheckoutDataModel();
}
});
window?.addEventListener("storage", modelEventChange);
return () => {
window?.removeEventListener("storage", modelEventChange);
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
......@@ -435,6 +435,12 @@ const ModelTable = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ tableWidth ])
const modelEventChange = (e) => {
if (e.key === 'modelChange') {
getCheckoutDataModel();
}
}
const getCheckoutDataModel = () => {
dispatch({
type: 'datamodel.getCheckoutDataModel',
......
......@@ -61,11 +61,17 @@ class Model extends React.Component {
componentDidMount() {
this.getModelStates();
window?.addEventListener("storage", (e) => {
if (e.key === 'modelChange') {
this.onTableChange();
}
});
window?.addEventListener("storage", this.modelEventChange);
}
componentWillUnmount() {
window?.removeEventListener("storage", this.modelEventChange);
}
modelEventChange = (e) => {
if (e.key === 'modelChange') {
this.onTableChange();
}
}
getModelStates = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment