发现弹窗modal性能问题
basicModal不设置maxHeight或height会一直执行setModalHeight,需即使销毁MutationObserverpull/1207/merge
parent
19d1e0ddbc
commit
ffebec59bf
|
@ -45,16 +45,36 @@
|
||||||
|
|
||||||
useWindowSizeFn(setModalHeight.bind(null, false));
|
useWindowSizeFn(setModalHeight.bind(null, false));
|
||||||
|
|
||||||
useMutationObserver(
|
// update-begin--author:liaozhiyang---date:2024-04-18---for:【QQYUN-9035】basicModal不设置maxHeight或height会一直执行setModalHeight,需即使销毁MutationObserver
|
||||||
spinRef,
|
let observer,
|
||||||
() => {
|
recordCount: any = {};
|
||||||
setModalHeight();
|
if (!(props.maxHeight || props.height)) {
|
||||||
},
|
observer = useMutationObserver(
|
||||||
{
|
spinRef,
|
||||||
attributes: true,
|
() => {
|
||||||
subtree: true,
|
setModalHeight({
|
||||||
}
|
source: 'muob',
|
||||||
);
|
callBack: (height) => {
|
||||||
|
const count = recordCount[height];
|
||||||
|
if (count) {
|
||||||
|
recordCount[height] = ++recordCount[height];
|
||||||
|
if (count > 5) {
|
||||||
|
observer.stop();
|
||||||
|
recordCount = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
recordCount[height] = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{
|
||||||
|
attributes: true,
|
||||||
|
subtree: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:2024-04-18---for:【QQYUN-9035】basicModal不设置maxHeight或height会一直执行setModalHeight,需即使销毁MutationObserver
|
||||||
|
|
||||||
createModalContext({
|
createModalContext({
|
||||||
redoModalHeight: setModalHeight,
|
redoModalHeight: setModalHeight,
|
||||||
|
@ -124,7 +144,11 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setModalHeight() {
|
async function setModalHeight(option?) {
|
||||||
|
console.log("---------性能监控--------setModalHeight----------")
|
||||||
|
const options = option || {};
|
||||||
|
const source = options.source;
|
||||||
|
const callBack = options.callBack;
|
||||||
// 解决在弹窗关闭的时候监听还存在,导致再次打开弹窗没有高度
|
// 解决在弹窗关闭的时候监听还存在,导致再次打开弹窗没有高度
|
||||||
// 加上这个,就必须在使用的时候传递父级的visible
|
// 加上这个,就必须在使用的时候传递父级的visible
|
||||||
if (!props.visible) return;
|
if (!props.visible) return;
|
||||||
|
@ -163,6 +187,12 @@
|
||||||
} else {
|
} else {
|
||||||
realHeightRef.value = props.height ? props.height : realHeight > maxHeight ? maxHeight : realHeight;
|
realHeightRef.value = props.height ? props.height : realHeight > maxHeight ? maxHeight : realHeight;
|
||||||
}
|
}
|
||||||
|
// update-begin--author:liaozhiyang---date:2024-04-18---for:【QQYUN-9035】basicModal不设置maxHeight或height会一直执行setModalHeight,需即使销毁MutationObserver
|
||||||
|
if (source == 'muob') {
|
||||||
|
callBack(realHeightRef.value);
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:2024-04-18---for:【QQYUN-9035】basicModal不设置maxHeight或height会一直执行setModalHeight,需即使销毁MutationObserver
|
||||||
|
|
||||||
emit('height-change', unref(realHeightRef));
|
emit('height-change', unref(realHeightRef));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
Loading…
Reference in New Issue