'admin-22.11.17:优化v2.3.0版本iframe右键菜单刷新及loading'

This commit is contained in:
lyt 2022-11-17 01:18:18 +08:00
parent 32e2d6cf94
commit f00fc0d2f1

View File

@ -51,22 +51,26 @@ export default defineComponent({
const getRoutePath = computed(() => {
return route.path;
});
// iframe loading
const closeIframeLoading = (val: string, item: any) => {
nextTick(() => {
if (!iframeRef.value) return false;
iframeRef.value.forEach((v: any) => {
if (v.dataset.url === val) {
v.onload = () => {
if (item && item.meta.isIframeOpen && item.meta.loading) item.meta.loading = false;
};
}
});
});
};
// iframe iframe
watch(
() => route.fullPath,
(val) => {
const item: any = props.list.find((v: any) => v.path === val);
if (item && !item.meta.isIframeOpen) item.meta.isIframeOpen = true;
nextTick(() => {
if (!iframeRef.value) return false;
iframeRef.value.forEach((v: any) => {
if (v.dataset.url === val) {
v.onload = () => {
if (item && item.meta.isIframeOpen && item.meta.loading) item.meta.loading = false;
};
}
});
});
closeIframeLoading(val, item);
},
{
immediate: true,
@ -78,8 +82,10 @@ export default defineComponent({
() => {
const item: any = props.list.find((v: any) => v.path === route.path);
if (item && item.meta.isIframeOpen) item.meta.isIframeOpen = false;
nextTick(() => {
setTimeout(() => {
item.meta.isIframeOpen = true;
item.meta.loading = true;
closeIframeLoading(route.fullPath, item);
});
},
{