metas-web.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!-- -->
  2. <template>
  3. <div class="web-box" :style="metasHeight ? `height:${metasHeight}px;` : ''">
  4. <div class="show-tips" v-if="link.length == 0">
  5. <span>{{ $t('tag.toolbox.webShow') }}</span>
  6. </div>
  7. <div class="iframe-box" v-if="link.length > 0">
  8. <div v-if="isEdit" class="del-btn" @click="delWeb()">
  9. <ui-icon type="del"></ui-icon>
  10. </div>
  11. <iframe v-for="(i, index) in link" :src="i.src" frameborder="0"></iframe>
  12. </div>
  13. <div v-if="isEdit" class="input-web" :class="{ disabled: link.length > 0 }">
  14. <input type="text" v-model="inputValue" placeholder="https://" autocomplete="off" />
  15. <div class="ok-web" v-if="link.length <= 0" @click="confirmWeb">
  16. <ui-icon type="checkbox1"></ui-icon>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script setup>
  22. import { ref, computed, defineProps } from 'vue';
  23. const store = useStore();
  24. const linkNum = ref(0);
  25. const hotData = computed(() => store.getters['tag/hotData']);
  26. const link = computed(() => {
  27. return hotData.value.media.link;
  28. });
  29. defineProps({
  30. metasHeight: {
  31. type: Number,
  32. default: null,
  33. },
  34. });
  35. const inputLink = computed(() => store.getters['tag/inputLink']);
  36. const isEdit = computed(() => store.getters['tag/isEdit']);
  37. const inputValue = computed({
  38. get() {
  39. if (inputLink.value && inputLink.value != void 0) {
  40. return inputLink.value;
  41. }
  42. return inputLink.value || '';
  43. },
  44. set(value) {
  45. store.commit('tag/setLink', value);
  46. },
  47. });
  48. const type = ref('link');
  49. const showIframe = ref(false);
  50. const delWeb = () => {
  51. store.commit('tag/delMetas', { type: type.value, index: linkNum.value });
  52. showIframe.value = false;
  53. inputValue.value = null;
  54. };
  55. const confirmWeb = () => {
  56. if (inputValue.value.indexOf('http' || 'https') == -1) {
  57. inputValue.value = 'https://' + inputValue.value;
  58. }
  59. console.log(inputValue.value);
  60. store.commit('tag/setWeb', inputValue.value);
  61. showIframe.value = false;
  62. showIframe.value = true;
  63. };
  64. </script>
  65. <style lang="scss" scoped>
  66. .del-btn {
  67. width: 24px;
  68. height: 24px;
  69. background: rgba(0, 0, 0, 0.3);
  70. border-radius: 50%;
  71. position: absolute;
  72. cursor: pointer;
  73. top: 10px;
  74. right: 10px;
  75. z-index: 10;
  76. display: flex;
  77. align-items: center;
  78. justify-content: center;
  79. }
  80. .web-box {
  81. width: 100%;
  82. height: 100%;
  83. overflow: hidden;
  84. position: absolute;
  85. border-radius: 4px;
  86. border: 1px solid rgba(255, 255, 255, 0.2);
  87. background: rgba(255, 255, 255, 0.1);
  88. top: 0;
  89. left: 0;
  90. z-index: 10;
  91. .show-tips {
  92. width: 100%;
  93. height: 100%;
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. span {
  98. color: rgba(255, 255, 255, 0.3);
  99. font-size: 16px;
  100. font-weight: bold;
  101. }
  102. }
  103. .iframe-box {
  104. width: 100%;
  105. height: 100%;
  106. position: absolute;
  107. top: 0;
  108. left: 0;
  109. iframe {
  110. width: 100%;
  111. height: 100%;
  112. }
  113. }
  114. .input-web {
  115. height: 32px;
  116. background: linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, #000000 200%) !important;
  117. border-radius: 0px 0px 4px 4px;
  118. position: absolute;
  119. bottom: 0;
  120. left: 0;
  121. width: 100%;
  122. display: flex;
  123. align-items: center;
  124. justify-content: space-between;
  125. padding: 0 10px 0 0;
  126. &.disabled {
  127. background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, #000000 200%) !important;
  128. opacity: 0.8 !important;
  129. }
  130. input {
  131. background: none;
  132. border: none;
  133. padding: 0 0 0 10px;
  134. width: 94%;
  135. box-sizing: border-box;
  136. &:focus {
  137. border: none;
  138. }
  139. &::placeholder {
  140. color: rgba(255, 255, 255, 0.6);
  141. }
  142. }
  143. .ok-web {
  144. width: 16px;
  145. height: 16px;
  146. border-radius: 50%;
  147. background: rgba(255, 255, 255, 0.6);
  148. color: rgba(0, 0, 0, 0.6);
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. cursor: pointer;
  153. }
  154. }
  155. }
  156. </style>