Skip to content

Commit 8edff99

Browse files
authored
feat: version copyed (#40)
1 parent fcb7563 commit 8edff99

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

components/object/versions.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<script setup lang="ts">
1010
import { Button } from '@/components/ui/button'
11+
import { Icon } from '#components'
1112
1213
import DataTable from '@/components/data-table/data-table.vue'
1314
import { useDataTable } from '@/components/data-table/useDataTable'
@@ -47,11 +48,37 @@ const loading = ref(false)
4748
4849
const objectApi = useObject({ bucket: props.bucketName })
4950
51+
const copyVersionId = async (versionId: string) => {
52+
if (!versionId) return
53+
try {
54+
await navigator.clipboard.writeText(versionId)
55+
message.success(t('Copy Success'))
56+
} catch (error) {
57+
message.error(t('Copy Failed'))
58+
}
59+
}
60+
5061
const columns = computed<ColumnDef<any, any>[]>(() => [
5162
{
5263
id: 'versionId',
5364
header: () => t('VersionId'),
54-
cell: ({ row }: any) => shortVersionId(row.original.VersionId),
65+
cell: ({ row }: any) => {
66+
const versionId = row.original.VersionId || ''
67+
return h('div', { class: 'flex items-center gap-2' }, [
68+
h('span', { class: 'font-mono text-sm' }, versionId),
69+
h(
70+
ActionButton,
71+
{
72+
variant: 'ghost',
73+
size: 'sm',
74+
class: 'h-6 w-6 p-0 shrink-0',
75+
onClick: () => copyVersionId(versionId),
76+
title: t('Copy'),
77+
},
78+
() => h(Icon, { name: 'ri:file-copy-line', size: 14 })
79+
),
80+
])
81+
},
5582
},
5683
{
5784
id: 'lastModified',

0 commit comments

Comments
 (0)