@fmdevui/fm-dev
Version:
Page level components developed based on Element Plus.
144 lines (139 loc) • 5.26 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var vueRouter = require('vue-router');
var pinia = require('pinia');
require('../../stores/index.js');
require('../../utils/index.js');
var index = require('../../utils/emit/index.js');
require('./iframes.vue.js');
var iframes_vue_vue_type_script_setup_true_name_layoutIframeView_lang = require('./iframes.vue2.js');
var keepAliveNames = require('../../stores/keepAliveNames.js');
var themeConfig = require('../../stores/themeConfig.js');
var index$1 = require('../../utils/storage/index.js');
const _hoisted_1 = { class: "layout-parent" };
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "parent",
setup(__props) {
const Iframes = iframes_vue_vue_type_script_setup_true_name_layoutIframeView_lang.default;
const route = vueRouter.useRoute();
const router = vueRouter.useRouter();
const storesKeepAliveNames = keepAliveNames.useKeepALiveNames();
const storesThemeConfig = themeConfig.useThemeConfig();
const { keepAliveNames: keepAliveNames$1, cachedViews } = pinia.storeToRefs(storesKeepAliveNames);
const { themeConfig: themeConfig$1 } = pinia.storeToRefs(storesThemeConfig);
const state = vue.reactive({
refreshRouterViewKey: "",
// 非 iframe tagsview 右键菜单刷新时
iframeRefreshKey: "",
// iframe tagsview 右键菜单刷新时
keepAliveNameList: [],
iframeList: []
});
const setTransitionName = vue.computed(() => {
return themeConfig$1.value.animation;
});
const getKeepAliveNames = vue.computed(() => {
return themeConfig$1.value.isTagsview ? cachedViews.value : state.keepAliveNameList;
});
const isIframePage = vue.computed(() => {
return route.meta.isIframe;
});
const getIframeListRoutes = async () => {
router.getRoutes().forEach((v) => {
if (v.meta.isIframe) {
v.meta.isIframeOpen = false;
v.meta.loading = true;
state.iframeList.push({ ...v });
}
});
};
vue.onBeforeMount(() => {
state.keepAliveNameList = keepAliveNames$1.value;
index.default.on("onTagsViewRefreshRouterView", (fullPath) => {
const cacheList = cachedViews.value;
if (route.meta.isKeepAlive) cachedViews.value = cachedViews.value?.filter((name) => route.name !== name);
state.keepAliveNameList = keepAliveNames$1.value.filter((name) => route.name !== name);
state.refreshRouterViewKey = "";
state.iframeRefreshKey = "";
vue.nextTick(() => {
if (route.meta.isKeepAlive) cachedViews.value = cacheList;
state.keepAliveNameList = keepAliveNames$1.value;
state.refreshRouterViewKey = fullPath;
state.iframeRefreshKey = fullPath;
});
});
});
vue.onMounted(() => {
getIframeListRoutes();
vue.nextTick(() => {
setTimeout(() => {
if (themeConfig$1.value.isCacheTagsView) {
let tagsViewArr = index$1.Session.get("tagsViewList") || [];
cachedViews.value = tagsViewArr.filter((item) => item.meta?.isKeepAlive).map((item) => item.name);
}
}, 0);
});
});
vue.onUnmounted(() => {
index.default.off("onTagsViewRefreshRouterView", () => {
});
});
vue.watch(
() => route.fullPath,
() => {
state.refreshRouterViewKey = decodeURI(route.fullPath);
},
{
immediate: true
}
);
return (_ctx, _cache) => {
const _component_router_view = vue.resolveComponent("router-view");
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
vue.createVNode(_component_router_view, null, {
default: vue.withCtx(({ Component }) => [
vue.createVNode(vue.Transition, {
name: setTransitionName.value,
mode: "out-in"
}, {
default: vue.withCtx(() => [
(vue.openBlock(), vue.createBlock(vue.KeepAlive, { include: getKeepAliveNames.value }, [
vue.withDirectives((vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(Component), {
key: state.refreshRouterViewKey,
class: "w100"
})), [
[vue.vShow, !isIframePage.value]
])
], 1032, ["include"]))
]),
_: 2
/* DYNAMIC */
}, 1032, ["name"])
]),
_: 1
/* STABLE */
}),
vue.createVNode(vue.Transition, {
name: setTransitionName.value,
mode: "out-in",
persisted: ""
}, {
default: vue.withCtx(() => [
vue.withDirectives(vue.createVNode(vue.unref(Iframes), {
class: "w100",
refreshKey: state.iframeRefreshKey,
name: setTransitionName.value,
list: state.iframeList
}, null, 8, ["refreshKey", "name", "list"]), [
[vue.vShow, isIframePage.value]
])
]),
_: 1
/* STABLE */
}, 8, ["name"])
]);
};
}
});
exports.default = _sfc_main;