diff --git a/components/object/info.vue b/components/object/info.vue index 2777acd..2952f0e 100644 --- a/components/object/info.vue +++ b/components/object/info.vue @@ -312,7 +312,6 @@ const retentionFormRef = ref(); const retentionMode = ref(null); const retainUntilDate = ref(null); -console.log('🚀 ~ retainUntilDate:', retainUntilDate.value); const retentionLoading = ref(false); const showRetentionView = ref(false); diff --git a/components/object/list.vue b/components/object/list.vue index 42bc1dc..60760f7 100644 --- a/components/object/list.vue +++ b/components/object/list.vue @@ -90,7 +90,14 @@ import { useAsyncData, useRoute, useRouter } from '#app'; import { NuxtLink } from '#components'; import { ListObjectsV2Command, type _Object, type CommonPrefix } from '@aws-sdk/client-s3'; import dayjs from 'dayjs'; -import type { DataTableColumns, DataTableRowKey } from 'naive-ui'; +import { + NButton, + NSpace, + NPopconfirm, + type DataTableColumns, + type DataTableRowKey, +} from 'naive-ui'; +import { Icon } from '#components'; import { joinRelativeURL } from 'ufo'; import { computed, ref, watch, type VNode } from 'vue'; import { useDeleteTaskManagerStore } from '~/store/delete-tasks'; @@ -229,6 +236,41 @@ const columns: DataTableColumns = [ return row.LastModified ? dayjs(row.LastModified).format('YYYY-MM-DD HH:mm:ss') : ''; }, }, + { + title: t('Actions'), + key: 'actions', + align: 'center', + width: 100, + render: (row: RowData) => { + if (row.type === 'object') + return h( + NSpace, + { + justify: 'center', + }, + { + default: () => [ + h( + NPopconfirm, + { onPositiveClick: () => handledownload(row) }, + { + default: () => t('Confirm Download'), + trigger: () => + h( + NButton, + { size: 'small', secondary: true }, + { + default: () => '', + icon: () => h(Icon, { name: 'ri:download-2-line' }), + } + ), + } + ), + ], + } + ); + }, + }, ]; interface ListObjectsResponse { @@ -278,7 +320,6 @@ watch( ); const contents = computed(() => data.value?.contents || []); -console.log('🚀 ~ contents:', contents.value); const commonPrefixes = computed(() => data.value?.commonPrefixes || []); const nextToken = computed(() => data.value?.nextContinuationToken || null); @@ -371,6 +412,14 @@ function handleBatchDelete() { }); } +// 下载 +const handledownload = async (item: any) => { + const msg = message.loading(t('Getting URL')); + const url = await objectApi.getSignedUrl(item.Key); + msg.destroy(); + window.open(url, '_blank'); +}; + // 为了实现 "Previous" 功能,需要记录访问过的 token 列表。 // 因为我们是通过路由导航,每次下一页时会改变 URL,从而 SSR 获取新数据。 // 当访问过的 token 会体现在浏览器历史记录中。 diff --git a/i18n/locales/en-US.json b/i18n/locales/en-US.json index 418a29b..0a26215 100644 --- a/i18n/locales/en-US.json +++ b/i18n/locales/en-US.json @@ -555,5 +555,6 @@ "Batch allocation policies": "Batch allocation policies", "Object Versions": "Object Versions", "VersionId": "VersionId", - "LastModified": "LastModified" + "LastModified": "LastModified", + "Confirm Download": "Confirm Download?" } diff --git a/i18n/locales/zh-CN.json b/i18n/locales/zh-CN.json index f6b84c9..2556597 100644 --- a/i18n/locales/zh-CN.json +++ b/i18n/locales/zh-CN.json @@ -645,5 +645,6 @@ "Search User Group": "搜索用户组", "Object Versions": "对象版本", "VersionId": "版本ID", - "LastModified": "最后修改时间" + "LastModified": "最后修改时间", + "Confirm Download": "确认下载?" }