full.vue 3.6 KB

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