|
@@ -28,7 +28,16 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
- import { onMounted, defineProps, defineEmits, ref, unref, watchEffect } from 'vue';
|
|
|
+ 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';
|
|
@@ -51,16 +60,27 @@
|
|
|
});
|
|
|
const copylink$ = ref<Nullable<HTMLElement>>(null);
|
|
|
const show = ref(false);
|
|
|
+ let copyInstance: ClipboardJS;
|
|
|
const closeCreated = () => {
|
|
|
show.value = false;
|
|
|
emit('close');
|
|
|
};
|
|
|
|
|
|
- const createdConfirm = () => {
|
|
|
+ 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$)) {
|
|
|
- const ele = unref(copylink$) as any as HTMLElement;
|
|
|
- new ClipboardJS(ele).on('success', function (e) {
|
|
|
- e.clearSelection();
|
|
|
+ await nextTick(() => {
|
|
|
+ console.log('copySuccess');
|
|
|
Dialog.toast({ content: t('base.copyShareSuccess'), type: 'success' });
|
|
|
setTimeout(() => {
|
|
|
show.value = false;
|