CopyLink.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <Teleport to="body">
  3. <div class="login-layer">
  4. <div class="login-box">
  5. <header>
  6. <h4>{{ $t('header.shareLink') }}</h4>
  7. <span class="close" @click="emits('close')"><i class="iconfont icon-close"></i></span>
  8. </header>
  9. <main>
  10. <input readonly v-model="shareURL" />
  11. </main>
  12. <footer>
  13. <button @click="emits('close')">{{ $t('common.cancel') }}</button>
  14. <button type="submit" ref="copy" :data-clipboard-text="shareURL">{{$t('header.copyLink')}}</button>
  15. </footer>
  16. </div>
  17. </div>
  18. </Teleport>
  19. </template>
  20. <script setup>
  21. import ClipboardJS from 'clipboard'
  22. import { ref, onMounted } from 'vue'
  23. import Toast from '@/components/dialog/Toast'
  24. const emits = defineEmits(['close', 'done'])
  25. const shareURL = ref(window.location.href.replace('&split', '').replace('&adjust', ''))
  26. const showToast = ref(false)
  27. const copy = ref(null)
  28. onMounted(() => {
  29. var clipboard = new ClipboardJS(copy.value)
  30. clipboard.on('success', function (e) {
  31. e.clearSelection()
  32. showToast.value = true
  33. emits('done')
  34. })
  35. })
  36. </script>
  37. <style lang="scss" scoped>
  38. .login-layer {
  39. position: absolute;
  40. left: 0;
  41. top: 0;
  42. width: 100%;
  43. height: 100%;
  44. z-index: 9999;
  45. display: flex;
  46. align-items: center;
  47. justify-content: center;
  48. }
  49. .login-box {
  50. position: absolute;
  51. width: 400px;
  52. background: rgba(27, 27, 28, 0.8);
  53. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
  54. border-radius: 4px 4px 4px 4px;
  55. opacity: 1;
  56. border: 1px solid #000000;
  57. backdrop-filter: blur(4px);
  58. color: #fff;
  59. header {
  60. padding: 20px;
  61. display: flex;
  62. align-items: center;
  63. justify-content: space-between;
  64. h4 {
  65. font-size: 16px;
  66. font-weight: 400;
  67. margin: 0;
  68. padding: 0;
  69. }
  70. .close {
  71. cursor: pointer;
  72. i {
  73. font-size: 14px;
  74. }
  75. }
  76. }
  77. main {
  78. padding: 40px 20px;
  79. border-top: solid 1px rgba(255, 255, 255, 0.16);
  80. border-bottom: solid 1px rgba(255, 255, 255, 0.16);
  81. input {
  82. color: #fff;
  83. height: 34px;
  84. background: rgba(255, 255, 255, 0.1);
  85. border-radius: 4px 4px 4px 4px;
  86. border: none;
  87. outline: none;
  88. width: 100%;
  89. padding: 0 7px;
  90. }
  91. }
  92. footer {
  93. height: 60px;
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. button {
  98. cursor: pointer;
  99. color: #0076f6;
  100. width: 105px;
  101. height: 34px;
  102. border: 1px solid #0076f6;
  103. margin-left: 20px;
  104. border-radius: 4px;
  105. background: transparent;
  106. &[type='submit'] {
  107. color: #fff;
  108. background: #0076f6;
  109. }
  110. }
  111. }
  112. }
  113. </style>