link.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="layout-padding layout-link-container">
  3. <div class="layout-padding-auto layout-padding-view">
  4. <div class="layout-link-warp">
  5. <i class="layout-link-icon iconfont icon-xingqiu"></i>
  6. <div class="layout-link-msg">页面 "{{ currentRouteMeta.title }}" 已在新窗口中打开</div>
  7. <el-button class="mt30" round @click="onGotoFullPage">
  8. <i class="iconfont icon-lianjie"></i>
  9. <span>立即前往体验</span>
  10. </el-button>
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script lang="ts">
  16. import { defineComponent, toRefs, reactive, watch } from 'vue';
  17. import { useRoute, RouteMeta } from 'vue-router';
  18. import { verifyUrl } from '/@/utils/toolsValidate';
  19. // 定义接口来定义对象的类型
  20. interface LinkViewState {
  21. currentRouteMeta: {
  22. isLink: string;
  23. title: string;
  24. };
  25. }
  26. interface LinkViewRouteMeta extends RouteMeta {
  27. isLink: string;
  28. title: string;
  29. }
  30. export default defineComponent({
  31. name: 'layoutLinkView',
  32. setup() {
  33. const route = useRoute();
  34. const state = reactive<LinkViewState>({
  35. currentRouteMeta: {
  36. isLink: '',
  37. title: '',
  38. },
  39. });
  40. // 立即前往
  41. const onGotoFullPage = () => {
  42. const { origin, pathname } = window.location;
  43. if (verifyUrl(state.currentRouteMeta.isLink)) window.open(state.currentRouteMeta.isLink);
  44. else window.open(`${origin}${pathname}#${state.currentRouteMeta.isLink}`);
  45. };
  46. // 监听路由的变化,设置内容
  47. watch(
  48. () => route.path,
  49. () => {
  50. state.currentRouteMeta = <LinkViewRouteMeta>route.meta;
  51. },
  52. {
  53. immediate: true,
  54. }
  55. );
  56. return {
  57. onGotoFullPage,
  58. ...toRefs(state),
  59. };
  60. },
  61. });
  62. </script>
  63. <style scoped lang="scss">
  64. .layout-link-container {
  65. .layout-link-warp {
  66. margin: auto;
  67. display: flex;
  68. flex-direction: column;
  69. align-items: center;
  70. justify-content: center;
  71. i.layout-link-icon {
  72. position: relative;
  73. font-size: 100px;
  74. color: var(--el-color-primary);
  75. &::after {
  76. content: '';
  77. position: absolute;
  78. left: 50px;
  79. top: 0;
  80. width: 15px;
  81. height: 100px;
  82. background: linear-gradient(
  83. rgba(255, 255, 255, 0.01),
  84. rgba(255, 255, 255, 0.01),
  85. rgba(255, 255, 255, 0.01),
  86. rgba(255, 255, 255, 0.05),
  87. rgba(255, 255, 255, 0.05),
  88. rgba(255, 255, 255, 0.05),
  89. rgba(235, 255, 255, 0.5),
  90. rgba(255, 255, 255, 0.05),
  91. rgba(255, 255, 255, 0.05),
  92. rgba(255, 255, 255, 0.05),
  93. rgba(255, 255, 255, 0.01),
  94. rgba(255, 255, 255, 0.01),
  95. rgba(255, 255, 255, 0.01)
  96. );
  97. transform: rotate(-15deg);
  98. animation: toRight 5s linear infinite;
  99. }
  100. }
  101. .layout-link-msg {
  102. font-size: 12px;
  103. color: var(--next-bg-topBarColor);
  104. opacity: 0.7;
  105. margin-top: 15px;
  106. }
  107. }
  108. }
  109. </style>