add copy to clipboard

This commit is contained in:
AceDataCloud committed 2023-01-24 00:01:08 +08:00
1 parent e3e0c0525a
commit f6065f4672
4 files changed
+58 -2

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
<template>
<font-awesome-icon v-if="!copied" icon="fa-regular fa-copy" @click="onCopy" />
<el-tooltip v-else :visible="copied" effect="dark" :content="$t('common.message.copied')" placement="top-start">
<font-awesome-icon icon="fa-solid fa-check" />
</el-tooltip>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import copy from 'copy-to-clipboard';
export default defineComponent({
name: 'CopyToClipboard',
components: {
FontAwesomeIcon
},
props: {
content: {
type: String,
required: true
}
},
data() {
return {
copied: false
};
},
methods: {
onCopy() {
copy(this.content, {
debug: true
});
this.copied = true;
setTimeout(() => {
this.copied = false;
}, 3000);
}
}
});
</script>
+4 -2
View File
@@ -32,7 +32,7 @@
<template #default="scope">
<span class="key">{{ scope.row.api_key }}</span>
<span class="copy">
<font-awesome-icon icon="fa-regular fa-copy" />
<copy-to-clipboard :content="scope.row.api_key" />
</span>
</template>
</el-table-column>
@@ -67,6 +67,7 @@ import { defineComponent } from 'vue';
import { applicationOperator, IApplication, IApplicationListResponse, IService } from '@/operators';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import Pagination from '@/components/common/Pagination.vue';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
interface IData {
applications: IApplication[];
@@ -80,7 +81,8 @@ export default defineComponent({
name: 'ApplicationList',
components: {
FontAwesomeIcon,
Pagination
Pagination,
CopyToClipboard
},
data(): IData {
return {