'admin-22.11.17:优化v2.3.0版本iframe右键菜单刷新及loading'
This commit is contained in:
parent
32e2d6cf94
commit
f00fc0d2f1
@ -51,22 +51,26 @@ export default defineComponent({
|
|||||||
const getRoutePath = computed(() => {
|
const getRoutePath = computed(() => {
|
||||||
return route.path;
|
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 时,切换不生效
|
// 监听路由变化,初始化 iframe 数据,防止多个 iframe 时,切换不生效
|
||||||
watch(
|
watch(
|
||||||
() => route.fullPath,
|
() => route.fullPath,
|
||||||
(val) => {
|
(val) => {
|
||||||
const item: any = props.list.find((v: any) => v.path === val);
|
const item: any = props.list.find((v: any) => v.path === val);
|
||||||
if (item && !item.meta.isIframeOpen) item.meta.isIframeOpen = true;
|
if (item && !item.meta.isIframeOpen) item.meta.isIframeOpen = true;
|
||||||
nextTick(() => {
|
closeIframeLoading(val, item);
|
||||||
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;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
@ -78,8 +82,10 @@ export default defineComponent({
|
|||||||
() => {
|
() => {
|
||||||
const item: any = props.list.find((v: any) => v.path === route.path);
|
const item: any = props.list.find((v: any) => v.path === route.path);
|
||||||
if (item && item.meta.isIframeOpen) item.meta.isIframeOpen = false;
|
if (item && item.meta.isIframeOpen) item.meta.isIframeOpen = false;
|
||||||
nextTick(() => {
|
setTimeout(() => {
|
||||||
item.meta.isIframeOpen = true;
|
item.meta.isIframeOpen = true;
|
||||||
|
item.meta.loading = true;
|
||||||
|
closeIframeLoading(route.fullPath, item);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user