From 2d26b5a8b38c7dc76bc0738577882e48fa91458c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E7=99=BB=E5=B1=B1?= Date: Tue, 1 Jul 2025 14:31:17 +0800 Subject: [PATCH] feat : API --- components/replication/new-form.vue | 268 ++++++++++++++++++---------- composables/useBucket.ts | 44 +++++ i18n/locales/en-US.json | 11 +- i18n/locales/zh-CN.json | 11 +- pages/replication/index.vue | 189 +++++++++++++------- 5 files changed, 364 insertions(+), 159 deletions(-) diff --git a/components/replication/new-form.vue b/components/replication/new-form.vue index bdc006e..e12631a 100644 --- a/components/replication/new-form.vue +++ b/components/replication/new-form.vue @@ -1,10 +1,16 @@ diff --git a/composables/useBucket.ts b/composables/useBucket.ts index a4e5ed1..c19738e 100644 --- a/composables/useBucket.ts +++ b/composables/useBucket.ts @@ -23,8 +23,13 @@ import { GetBucketLifecycleConfigurationCommand, PutBucketLifecycleConfigurationCommand, DeleteBucketLifecycleCommand, + GetBucketReplicationCommand, + PutBucketReplicationCommand, + DeleteBucketReplicationCommand, } from "@aws-sdk/client-s3"; +const { $api } = useNuxtApp(); + export function useBucket({ region }: { region?: string }) { const $client = useNuxtApp().$s3Client; @@ -195,6 +200,40 @@ export function useBucket({ region }: { region?: string }) { return await $client.send(new DeleteBucketEncryptionCommand(params)); }; + /********************S3 Replication********************/ + const getBucketReplication = async (bucket: string) => { + const params = { + Bucket: bucket, + }; + return await $client.send(new GetBucketReplicationCommand(params)); + }; + const putBucketReplication = async (bucket: string, replication: any) => { + const params = { + Bucket: bucket, + ReplicationConfiguration: replication, + }; + return await $client.send(new PutBucketReplicationCommand(params)); + }; + const deleteBucketReplication = async (bucket: string) => { + const params = { + Bucket: bucket, + }; + return await $client.send(new DeleteBucketReplicationCommand(params)); + }; + + /********************S3 Replication********************/ + + const setRemoteReplicationTarget = async (bucket: string, data: any) => { + console.log("🚀 ~ setRemoteReplicationTarget ~ bucket:", bucket); + return await $api.put(`/set-remote-target?bucket=${bucket}}`, data); + }; + + const listRemoteReplicationTarget = async (bucket: string) => { + return await $api.get(`/list-remote-target?bucket=${bucket}`); + }; + + /********************rustfs Replication********************/ + return { listBuckets, createBucket, @@ -218,5 +257,10 @@ export function useBucket({ region }: { region?: string }) { getBucketEncryption, putBucketEncryption, deleteBucketEncryption, + getBucketReplication, + putBucketReplication, + deleteBucketReplication, + setRemoteReplicationTarget, + listRemoteReplicationTarget, }; } diff --git a/i18n/locales/en-US.json b/i18n/locales/en-US.json index 32fdbc8..ed338ee 100644 --- a/i18n/locales/en-US.json +++ b/i18n/locales/en-US.json @@ -343,5 +343,14 @@ "Days After": "Days After", "Expire": "Expire", "On": "On", - "Off": "Off" + "Off": "Off", + "Replicate existing objects": "Replicate existing objects", + "Sync metadata": "Sync metadata", + "Replicate soft delete": "Replicate soft delete", + "Replicate version delete": "Replicate version delete", + "Health Check Duration": "Health Check Duration", + "Please enter health check duration": "Please enter health check duration", + "Please enter bandwidth": "Please enter bandwidth", + "Please enter storage type": "Please enter storage type", + "Add Replication Rule": "Add Replication Rule" } diff --git a/i18n/locales/zh-CN.json b/i18n/locales/zh-CN.json index f64deda..0c53e48 100644 --- a/i18n/locales/zh-CN.json +++ b/i18n/locales/zh-CN.json @@ -534,5 +534,14 @@ "Please enter valid days": "请输入天数", "Expire": "过期", "On": "开启", - "Off": "关闭" + "Off": "关闭", + "Replicate existing objects": "复制现有对象", + "Sync metadata": "同步元数据", + "Replicate soft delete": "复制软删除", + "Replicate version delete": "复制版本删除", + "Health Check Duration": "健康检查时长", + "Please enter health check duration": "请输入健康检查时长", + "Please enter bandwidth": "请输入带宽", + "Please enter storage type": "请输入存储类型", + "Add Replication Rule": "添加复制规则" } diff --git a/pages/replication/index.vue b/pages/replication/index.vue index c223029..779bc6a 100644 --- a/pages/replication/index.vue +++ b/pages/replication/index.vue @@ -2,107 +2,127 @@
-
+
- +
- {{ t('Add Replication Rule') }} + {{ t("Add Replication Rule") }} - + - {{ t('Refresh') }} + {{ t("Refresh") }}
- - + + + - - + -