index.vue 3.04 KB
<template>
  <RouterView>
    <template #default="{ Component, route }">
      <transition
        :name="
          getTransitionName({
            route,
            openCache,
            enableTransition: getEnableTransition,
            cacheTabs: getCaches,
            def: getBasicTransition,
          })
        "
        mode="out-in"
        appear
      >
        <keep-alive v-if="openCache" :include="getCaches">
          <component :is="Component" :key="route.fullPath" />
        </keep-alive>
        <component v-else :is="Component" :key="route.fullPath" />
      </transition>
    </template>
  </RouterView>
  <BasicModal
    @register="register"
    v-bind="$attrs"
    :mask="true"
    :showCancelBtn="false"
    :showOkBtn="false"
    :canFullscreen="false"
    :closable="false"
    :maskStyle="maskColor"
    :height="600"
    :width="1500"
    :maskClosable="false"
    title="请您修改初始密码"
    :helpMessage="['请您修改初始密码']"
    :keyboard="false"
  >
    <PasswordDialog />
  </BasicModal>
  <FrameLayout v-if="getCanEmbedIFramePage" />
</template>

<script lang="ts">
  import { computed, defineComponent, ref, unref, onMounted } from 'vue';
  import PasswordDialog from '/@/views/system/password/index.vue';

  import FrameLayout from '/@/layouts/iframe/index.vue';

  import { useRootSetting } from '/@/hooks/setting/useRootSetting';

  import { useTransitionSetting } from '/@/hooks/setting/useTransitionSetting';
  import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting';
  import { getTransitionName } from './transition';

  import { useMultipleTabStore } from '/@/store/modules/multipleTab';
  import { BasicModal, useModal } from '/@/components/Modal';
  import { USER_INFO_KEY } from '/@/enums/cacheEnum';
  import { getAuthCache } from '/@/utils/auth';
  export default defineComponent({
    name: 'PageLayout',
    components: { FrameLayout, BasicModal, PasswordDialog },
    setup() {
      const { getShowMultipleTab } = useMultipleTabSetting();
      const tabStore = useMultipleTabStore();

      const { getOpenKeepAlive, getCanEmbedIFramePage } = useRootSetting();

      const { getBasicTransition, getEnableTransition } = useTransitionSetting();

      const openCache = computed(() => unref(getOpenKeepAlive) && unref(getShowMultipleTab));

      const getCaches = computed((): string[] => {
        if (!unref(getOpenKeepAlive)) {
          return [];
        }
        return tabStore.getCachedTabList;
      });

      const [register, { openModal }] = useModal();
      const maskColor = ref({ backgroundColor: 'grey' });
      const statusModel = ref(false);
      onMounted(() => {
        const userInfo = getAuthCache(USER_INFO_KEY);
        if (userInfo.needSetPwd == true) {
          statusModel.value = true;
          openModal(statusModel.value);
        }
      });

      return {
        getTransitionName,
        openCache,
        getEnableTransition,
        getBasicTransition,
        getCaches,
        getCanEmbedIFramePage,
        register,
        maskColor,
      };
    },
  });
</script>