<template>
  <router-view v-slot="{ Component }" v-if="!clearCache">
    <keep-alive include="Home,Record">
      <component :is="Component"/>
    </keep-alive>
  </router-view>
</template>

<script setup lang="ts">
import { onMounted, onBeforeUnmount, computed } from 'vue';
import { useMainStore } from './store';

const mainStore = useMainStore();
const clearCache = computed(() => mainStore.getClearCache);

const handleLinkClick = (e: MouseEvent) => {
  const target = (e.target as HTMLElement).closest("a") as HTMLAnchorElement | null;
  if (target && target.tagName === 'A' && target.href) {
    e.preventDefault();
    window.open(target.href, '_blank', 'noopener,noreferrer');
  }
}

onMounted(() => {
  document.addEventListener('click', handleLinkClick);
});

onBeforeUnmount(() => {
  document.removeEventListener('click', handleLinkClick);
});
</script>

<style>
/* 全局样式 */
.help-tip {
  width: 540px;
  /* height: 110px; */
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  .title {
    font-weight: bold;
    font-size: 16px;
    color: #282e30;
    margin-bottom: 10px;
  }

  .value {
    font-weight: 400;
    font-size: 14px;
    color: #282e30;
  }
}
</style>
