full.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="denet-toolbox">
  3. <div class="head">
  4. <span></span>
  5. <div>
  6. <!-- 缩放 -->
  7. <img :src="require('@/assets/img/icon-full.png')" alt class="fixed" @click="clickFull" />
  8. <!-- 关闭 -->
  9. <img :src="require('@/assets/img/icon-close.png')" alt class="full" @click="clickClose" />
  10. </div>
  11. </div>
  12. <div class="content">
  13. <iframe :src="state.iframe_url" frameborder="0"></iframe>
  14. </div>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { onMounted, reactive, ref } from "vue";
  19. import { sendEventInfo } from "@/uilts/event";
  20. import { $ } from "@/uilts/help";
  21. let state = reactive({
  22. status: '固定', // 全屏
  23. iframe_url: '',
  24. tweetId: ''
  25. })
  26. let dom_fixed = null
  27. window.addEventListener("onEvent", e => {
  28. let info = e.detail
  29. switch (info.event_type) {
  30. // 固定
  31. case 'ToolBox_To_Fixed':
  32. // 替换
  33. if (state.iframe_url || state.tweetId) {
  34. sendClose()
  35. }
  36. state.iframe_url = info.data.iframe_url
  37. state.tweetId = info.data.tweetId
  38. break
  39. }
  40. });
  41. const clickFull = () => {
  42. if (state.status == '固定') {
  43. state.status = '全屏'
  44. changeFull()
  45. } else {
  46. state.status = '固定'
  47. changeFixed()
  48. }
  49. }
  50. onMounted(() => {
  51. dom_fixed = $('#denet-tool-box-fixed')
  52. })
  53. const changeFull = () => {
  54. dom_fixed.style.cssText = `
  55. width:100%;
  56. height: 100%;
  57. position: fixed;
  58. right: 0px;
  59. top: 0px;`
  60. }
  61. const changeFixed = () => {
  62. dom_fixed.style.cssText = `
  63. width: 505px;
  64. height: 544px;
  65. position: fixed;
  66. right: 10px;
  67. top: 10px;`
  68. }
  69. const clickClose = () => {
  70. dom_fixed.style.display = 'none'
  71. sendClose()
  72. }
  73. const sendClose = () => {
  74. let url = state.iframe_url
  75. let tweetId = state.tweetId
  76. sendEventInfo({
  77. event_type: 'ToolBox_Fixed_Close',
  78. data: {
  79. url,
  80. tweetId,
  81. }
  82. })
  83. state.iframe_url = ''
  84. state.tweetId = ''
  85. }
  86. </script>
  87. <style lang="scss">
  88. .denet-toolbox {
  89. width: 100%;
  90. height: 100%;
  91. filter: drop-shadow(0px 4px 20px rgba(0, 0, 0, 0.2));
  92. border-radius: 12px;
  93. overflow: hidden;
  94. .head {
  95. width: 100%;
  96. height: 40px;
  97. background: #373737;
  98. display: flex;
  99. align-items: center;
  100. justify-content: space-between;
  101. span {
  102. color: #FFFFFF;
  103. font-style: normal;
  104. font-weight: 500;
  105. font-size: 14px;
  106. margin-left: 16px;
  107. }
  108. img {
  109. width: 20px;
  110. height: 20px;
  111. cursor: pointer;
  112. }
  113. .full {
  114. margin-right: 16px;
  115. }
  116. .fixed {
  117. margin-right: 20px;
  118. }
  119. }
  120. .content {
  121. width: 100%;
  122. height: calc(100% - 40px);
  123. background: #686868;
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. iframe {
  128. width: 100%;
  129. height: 100%;
  130. }
  131. }
  132. }
  133. </style>