share.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div id="dialog_index">
  3. <div class="created_dialog">
  4. <div class="blurBox"></div>
  5. <div class="content">
  6. <div class="dialog_title">{{ title || $t('share.shareLinkTips') }}</div>
  7. <div class="dialog_link">
  8. <p>
  9. {{ shareLink }}
  10. </p>
  11. </div>
  12. <div class="created_btn">
  13. <div class="created_cancel" @click="closeCreated">{{ $t('common.cancel')}}</div>
  14. <div class="created_confirm" ref="copylink$" :data-clipboard-text="shareLink" @click="createdConfirm">{{ $t('share.shareLink')}} 複製分享</div>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20. <script setup>
  21. import { onMounted, watch, defineProps, defineEmits, ref, nextTick } from "vue";
  22. import ClipboardJS from 'clipboard'
  23. import { Dialog } from '@/global_components/'
  24. import { useI18n, getLocale } from '@/i18n'
  25. const { t } = useI18n({ useScope: 'global' })
  26. const emit = defineEmits(["closeDialog"]);
  27. const props = defineProps({
  28. title: {
  29. type: String,
  30. default: ``,
  31. },
  32. shareLink: {
  33. type: String,
  34. default: "",
  35. },
  36. });
  37. const copylink$ = ref(null)
  38. const closeCreated = () => {
  39. emit("closeDialog");
  40. };
  41. const createdConfirm = () => {
  42. emit("closeDialog");
  43. };
  44. onMounted(() => {
  45. nextTick(()=>{
  46. new ClipboardJS(copylink$.value).on('success', function (e) {
  47. e.clearSelection()
  48. Dialog.toast({ content: '鏈接複製成功', type: 'success' })
  49. })
  50. })
  51. })
  52. </script>
  53. <style scoped lang="scss">
  54. #dialog_index {
  55. width: 100vw;
  56. height: 100%;
  57. // background: rgba(0, 0, 0, 0.5);
  58. position: fixed;
  59. left: 0;
  60. top: 0;
  61. z-index: 100000;
  62. pointer-events: none;
  63. .created_dialog {
  64. width: 8.64rem;
  65. // min-height: 5rem;
  66. // background: #ffffff;
  67. border-radius: 8px;
  68. position: absolute;
  69. left: 50%;
  70. top: 50%;
  71. transform: translate(-50%, -50%);
  72. pointer-events: auto;
  73. border: 1px solid rgba(255, 255, 255, 0.1);
  74. border-radius: 4px;
  75. .blurBox {
  76. position: absolute;
  77. z-index: 1;
  78. top: 0;
  79. left: 0;
  80. width: 100%;
  81. height: 100%;
  82. background: rgba(0, 0, 0, 0.7);
  83. filter: blur(1px);
  84. }
  85. .content {
  86. position: relative;
  87. z-index: 2;
  88. top: 0;
  89. left: 0;
  90. width: 100%;
  91. height: 100%;
  92. }
  93. .dialog_title {
  94. width: 100%;
  95. height: 1.39rem;
  96. padding: 0 0.56rem;
  97. box-sizing: border-box;
  98. font-size: 0.39rem;
  99. color: #fff;
  100. line-height: 1.39rem;
  101. overflow: hidden;
  102. text-overflow: ellipsis;
  103. white-space: nowrap;
  104. border-bottom-style: solid;
  105. border-bottom-width: 1px;
  106. border-bottom-color: rgba(255, 255, 255, 0.1);
  107. }
  108. .dialog_link {
  109. width: 100%;
  110. font-size: 0.39rem;
  111. color: rgba(255, 255, 255, 0.5);
  112. padding: 0.53rem 0.56rem;
  113. box-sizing: border-box;
  114. text-align: justify;
  115. text-align: left;
  116. > p {
  117. background: rgba(0, 0, 0, 0.5);
  118. padding: 0.15rem 0.28rem;
  119. word-break: break-all;
  120. word-wrap: break-word;
  121. text-overflow: -o-ellipsis-lastline;
  122. overflow: hidden;
  123. text-overflow: ellipsis;
  124. display: -webkit-box;
  125. -webkit-line-clamp: 2;
  126. line-clamp: 2;
  127. -webkit-box-orient: vertical;
  128. line-height: 0.72rem;
  129. }
  130. }
  131. .created_btn {
  132. width: 100%;
  133. height: 1.36rem;
  134. border-top-style: solid;
  135. border-top-width: 1px;
  136. border-top-color: rgba(255, 255, 255, 0.1);
  137. box-sizing: border-box;
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. > div {
  142. width: 50%;
  143. height: 1.36rem;
  144. text-align: center;
  145. line-height: 1.36rem;
  146. font-size: 0.39rem;
  147. box-sizing: border-box;
  148. &.created_cancel {
  149. color: #fff;
  150. border-right-style: solid;
  151. border-right-width: 1px;
  152. border-right-color: rgba(0, 0, 0, 0.05);
  153. }
  154. &.created_confirm {
  155. color: #ed5d18;
  156. }
  157. }
  158. }
  159. }
  160. }
  161. </style>