App.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <router-view v-slot="{ Component }" v-if="!clearCache">
  3. <keep-alive include="Home,Record">
  4. <component :is="Component"/>
  5. </keep-alive>
  6. </router-view>
  7. </template>
  8. <script setup lang="ts">
  9. import { onMounted, onBeforeUnmount, computed } from 'vue';
  10. import { useMainStore } from './store';
  11. const mainStore = useMainStore();
  12. const clearCache = computed(() => mainStore.getClearCache);
  13. const handleLinkClick = (e: MouseEvent) => {
  14. const target = (e.target as HTMLElement).closest("a") as HTMLAnchorElement | null;
  15. if (target && target.tagName === 'A' && target.href) {
  16. e.preventDefault();
  17. window.open(target.href, '_blank', 'noopener,noreferrer');
  18. }
  19. }
  20. onMounted(() => {
  21. document.addEventListener('click', handleLinkClick);
  22. });
  23. onBeforeUnmount(() => {
  24. document.removeEventListener('click', handleLinkClick);
  25. });
  26. </script>
  27. <style>
  28. /* 全局样式 */
  29. .help-tip {
  30. width: 540px;
  31. /* height: 110px; */
  32. display: flex;
  33. flex-direction: column;
  34. box-sizing: border-box;
  35. .title {
  36. font-weight: bold;
  37. font-size: 16px;
  38. color: #282e30;
  39. margin-bottom: 10px;
  40. }
  41. .value {
  42. font-weight: 400;
  43. font-size: 14px;
  44. color: #282e30;
  45. }
  46. }
  47. </style>