Share.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="url-share" v-show="show">
  3. <div>
  4. <div class="tips">
  5. <h4>{{ $t("share.shareLink") }}</h4>
  6. <i class="iconfont icon-close" @click="onNo"></i>
  7. </div>
  8. <div class="url">{{ copyLink }}</div>
  9. <div class="btns">
  10. <ui-button class="ccc" @click="onNo">{{ $t("common.cancel") }}</ui-button>
  11. <ui-button class="primary" :data-clipboard-text="copyLink" ref="copy$">{{ $t("share.copyLink") }}</ui-button>
  12. </div>
  13. </div>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { ref, onMounted, computed, watch, nextTick } from "vue";
  18. import { useI18n, getLocale } from "@/i18n";
  19. import { useStore } from "vuex";
  20. import { Dialog } from '@/global_components/'
  21. import { getApp } from "@/app";
  22. import browser from '@/utils/browser'
  23. import ClipboardJS from 'clipboard'
  24. const store = useStore();
  25. const { t } = useI18n({ useScope: "global" });
  26. const url = ref(location.href);
  27. const copy$ = ref(null);
  28. const show = computed(() => store.getters["functions/showShareUrl"]);
  29. let share_url = browser.getURLParam("share_url");
  30. if (share_url) {
  31. share_url = decodeURIComponent(share_url);
  32. } else {
  33. share_url = location.href.split("#")[0];
  34. }
  35. const copyLink = computed(() => {
  36. return share_url.replace("&app", "");
  37. });
  38. const onOk = () => {};
  39. const onNo = () => {
  40. store.commit("functions/setShareUrl", false);
  41. };
  42. onMounted(() => {
  43. nextTick(()=>{
  44. new ClipboardJS(copy$.value.$el).on("success", (e)=> {
  45. e.clearSelection();
  46. onNo()
  47. Dialog.toast({ content: t("toast.copySuccess"), type: "success" });
  48. });
  49. })
  50. });
  51. </script>
  52. <style lang="scss" scoped>
  53. .url-share {
  54. position: fixed;
  55. top: 0;
  56. left: 0;
  57. right: 0;
  58. bottom: 0;
  59. z-index: 99999;
  60. > div {
  61. position: absolute;
  62. left: 50%;
  63. top: 50vh;
  64. transform: translate(-50%,-50%);
  65. width: 400px;
  66. height: 230px;
  67. background: rgba(27,27,28,0.8);
  68. box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.3);
  69. border-radius: 4px;
  70. border: 1px solid #000000;
  71. backdrop-filter: blur(4px);
  72. padding: 26px;
  73. .tips {
  74. display: flex;
  75. align-items: center;
  76. justify-content: space-between;
  77. h4 {
  78. margin: 0;
  79. font-size: 18px;
  80. font-weight: normal;
  81. }
  82. i {
  83. font-size: 14px;
  84. cursor: pointer;
  85. color: #969799;
  86. }
  87. }
  88. .url {
  89. color: #fff;
  90. text-align: center;
  91. padding: 10px 16px;
  92. width: 100%;
  93. margin: 40px auto;
  94. border-radius: 0.07rem;
  95. line-height: 1.5;
  96. font-size: 16px;
  97. background: rgba(26,27,29,0.8);
  98. overflow: hidden;
  99. text-overflow: ellipsis;
  100. white-space:nowrap;
  101. }
  102. .btns {
  103. display: flex;
  104. justify-content: flex-end;
  105. button {
  106. font-size: 14px;
  107. width: 88px;
  108. margin-left: 10px;
  109. }
  110. .ccc{
  111. background: #313131!important;
  112. border-radius: 4px;
  113. border-color: transparent;
  114. }
  115. }
  116. }
  117. }
  118. @media screen and (max-width: 600px) {
  119. .url-share {
  120. >div{
  121. width: 90%;
  122. }
  123. }
  124. }
  125. </style>