123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <template>
- <div id="dialog_index" v-show="show">
- <div class="created_dialog">
- <div class="blurBox"></div>
- <div class="content">
- <div class="dialog_title">{{ title }}</div>
- <div class="dialog_link">
- <p>
- {{ shareLink }}
- </p>
- </div>
- <div class="created_btn">
- <div class="created_cancel" @click="closeCreated">{{ t('base.cancel') }}</div>
- <div
- class="created_confirm"
- ref="copylink$"
- :data-clipboard-text="shareLink"
- @click="createdConfirm"
- >
- <!-- 复制分享 -->
- {{ t('base.copyShare') }}
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import {
- onMounted,
- defineProps,
- defineEmits,
- ref,
- unref,
- watchEffect,
- nextTick,
- onUnmounted,
- } from 'vue';
- import ClipboardJS from 'clipboard';
- import Dialog from '/@/components/basic/dialog';
- import { useI18n } from '/@/hooks/useI18n';
- const { t } = useI18n();
- const emit = defineEmits(['close']);
- const props = defineProps({
- title: {
- type: String,
- default: () => {
- const { t } = useI18n();
- return t('base.inviteFriends');
- },
- },
- shareLink: {
- type: String,
- default: '',
- },
- });
- const copylink$ = ref<Nullable<HTMLElement>>(null);
- const show = ref(false);
- let copyInstance: ClipboardJS;
- const closeCreated = () => {
- show.value = false;
- emit('close');
- };
- onMounted(() => {
- const ele = unref(copylink$) as any as HTMLElement;
- copyInstance = new ClipboardJS(ele);
- copyInstance.on('success', (e) => {
- e.clearSelection();
- });
- });
- onUnmounted(() => {
- copyInstance.destroy();
- });
- const createdConfirm = async () => {
- if (unref(copylink$)) {
- await nextTick(() => {
- console.log('copySuccess');
- Dialog.toast({ content: t('base.copyShareSuccess'), type: 'success' });
- setTimeout(() => {
- show.value = false;
- emit('close');
- }, 300);
- });
- }
- };
- onMounted(() => {
- watchEffect(() => {
- if (props.shareLink?.length) {
- show.value = true;
- }
- });
- });
- </script>
- <style scoped lang="scss">
- #dialog_index {
- width: 100vw;
- height: 100%;
- // background: rgba(0, 0, 0, 0.5);
- position: fixed;
- left: 0;
- top: 0;
- z-index: 100000;
- pointer-events: none;
- .created_dialog {
- width: 8.64rem;
- // min-height: 5rem;
- // background: #ffffff;
- border-radius: 8px;
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- pointer-events: auto;
- border: 1px solid rgba(255, 255, 255, 0.1);
- border-radius: 4px;
- .blurBox {
- position: absolute;
- z-index: 1;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background: rgba(0, 0, 0, 0.7);
- filter: blur(1px);
- }
- .content {
- position: relative;
- z-index: 2;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- }
- .dialog_title {
- width: 100%;
- height: 1.39rem;
- padding: 0 0.56rem;
- box-sizing: border-box;
- font-size: 0.39rem;
- color: #fff;
- line-height: 1.39rem;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- border-bottom-style: solid;
- border-bottom-width: 1px;
- border-bottom-color: rgba(255, 255, 255, 0.1);
- }
- .dialog_link {
- width: 100%;
- font-size: 0.39rem;
- color: rgba(255, 255, 255, 0.5);
- padding: 0.53rem 0.56rem;
- box-sizing: border-box;
- text-align: justify;
- text-align: left;
- > p {
- background: rgba(0, 0, 0, 0.5);
- padding: 0.15rem 0.28rem;
- word-break: break-all;
- word-wrap: break-word;
- text-overflow: -o-ellipsis-lastline;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- line-clamp: 2;
- -webkit-box-orient: vertical;
- line-height: 0.72rem;
- }
- }
- .created_btn {
- width: 100%;
- height: 1.36rem;
- border-top-style: solid;
- border-top-width: 1px;
- border-top-color: rgba(255, 255, 255, 0.1);
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: center;
- > div {
- width: 50%;
- height: 1.36rem;
- text-align: center;
- line-height: 1.36rem;
- font-size: 0.39rem;
- box-sizing: border-box;
- &.created_cancel {
- color: #fff;
- border-right-style: solid;
- border-right-width: 1px;
- border-right-color: rgba(0, 0, 0, 0.05);
- }
- &.created_confirm {
- color: #ed5d18;
- }
- }
- }
- }
- }
- </style>
|