From 6902355a5e8dba05aacb10f16e27bbae46fead22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E7=99=BB=E5=B1=B1?= Date: Wed, 13 Aug 2025 18:01:27 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat=EF=BC=9A=20UI=20done?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierrc | 2 +- config/navs.ts | 97 +++---- i18n/locales/en-US.json | 96 ++++++- i18n/locales/tr-TR.json | 96 ++++++- i18n/locales/zh-CN.json | 96 ++++++- nuxt.config.ts | 3 +- pages/sse/index.vue | 596 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 934 insertions(+), 52 deletions(-) create mode 100644 pages/sse/index.vue diff --git a/.prettierrc b/.prettierrc index 309de83..e07cccc 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,7 +4,7 @@ "trailingComma": "es5", "tabWidth": 2, "useTabs": false, - "printWidth": 100, + "printWidth": 120, "endOfLine": "lf", "bracketSpacing": true, "arrowParens": "avoid", diff --git a/config/navs.ts b/config/navs.ts index 0e4346c..6ebc09f 100644 --- a/config/navs.ts +++ b/config/navs.ts @@ -1,31 +1,31 @@ // icons: https://icones.js.org/collection/ri -import type { NavItem } from '~/types/app-config' +import type { NavItem } from '~/types/app-config'; export default [ { - label: "Browser", - to: "/browser", - icon: "ri:box-3-line", + label: 'Browser', + to: '/browser', + icon: 'ri:box-3-line', }, { - label: "Access Keys", - to: "/access-keys", - icon: "ri:door-lock-line", + label: 'Access Keys', + to: '/access-keys', + icon: 'ri:door-lock-line', }, { - label: "Policies", - to: "/policies", - icon: "ri:shield-check-line", + label: 'Policies', + to: '/policies', + icon: 'ri:shield-check-line', }, { - label: "Users", - to: "/users", - icon: "ri:file-user-line", + label: 'Users', + to: '/users', + icon: 'ri:file-user-line', }, { - label: "Performance", - to: "/performance", - icon: "ri:bar-chart-box-line", + label: 'Performance', + to: '/performance', + icon: 'ri:bar-chart-box-line', }, // { // label: 'Site Replication', @@ -33,57 +33,62 @@ export default [ // icon: 'ri:upload-cloud-2-line', // }, { - label: "Bucket Setting", - icon: "ri:settings-2-line", + label: 'Bucket Setting', + icon: 'ri:settings-2-line', children: [ { - label: "Bucket Events", - to: "/events", - icon: "ri:broadcast-line", + label: 'Bucket Events', + to: '/events', + icon: 'ri:broadcast-line', }, { - label: "Bucket Replication", - to: "/replication", - icon: "ri:file-copy-line", + label: 'Bucket Replication', + to: '/replication', + icon: 'ri:file-copy-line', }, { - label: "Lifecycle", - to: "/lifecycle", - icon: "ri:exchange-2-line", + label: 'Lifecycle', + to: '/lifecycle', + icon: 'ri:exchange-2-line', }, ], }, { - label: "divider", - key: "divider-1", - type: "divider", + label: 'divider', + key: 'divider-1', + type: 'divider', }, { - label: "Tiered Storage", - to: "/tiers", - icon: "ri:stack-line", + label: 'Tiered Storage', + to: '/tiers', + icon: 'ri:stack-line', }, { - label: "Event Destinations", - to: "/events-target", - icon: "ri:bookmark-3-line", + label: 'Event Destinations', + to: '/events-target', + icon: 'ri:bookmark-3-line', }, { - label: "divider", - key: "divider-2", - type: "divider", + label: 'SSE Settings', + to: '/sse', + icon: 'ri:secure-payment-line', }, { - label: "License", - to: "/license", - icon: "ri:copyright-line", + label: 'divider', + key: 'divider-2', + type: 'divider', }, { - label: "Documentation", - to: "https://docs.rustfs.com/", - target: "_blank", - icon: "ri:file-list-3-line", + label: 'License', + to: '/license', + icon: 'ri:copyright-line', + }, + { + label: 'Documentation', + to: 'https://docs.rustfs.com/', + target: '_blank', + icon: 'ri:file-list-3-line', }, ] as NavItem[]; diff --git a/i18n/locales/en-US.json b/i18n/locales/en-US.json index 9df2926..06e58a3 100644 --- a/i18n/locales/en-US.json +++ b/i18n/locales/en-US.json @@ -651,5 +651,99 @@ "Replication Options": "Replication Options", "Please enter prefix": "Please enter prefix", "Suffix": "Suffix", - "Please enter suffix": "Please enter suffix" + "Please enter suffix": "Please enter suffix", + "SSE Settings": "SSE Settings", + "Server-Side Encryption (SSE) Configuration": "Server-Side Encryption (SSE) Configuration", + "Configure server-side encryption for your objects using external key management services.": "Configure server-side encryption for your objects using external key management services.", + "KMS Status": "KMS Status", + "Not Configured": "Not Configured", + "Available": "Available", + "KMS server is not configured": "KMS server is not configured", + "KMS server is available and ready for use": "KMS server is available and ready for use", + "KMS Configuration": "KMS Configuration", + "Current KMS Type": "Current KMS Type", + "Vault Server": "Vault Server", + "Mount Path": "Mount Path", + "Default Key ID": "Default Key ID", + "No KMS configuration found": "No KMS configuration found", + "Configure KMS": "Configure KMS", + "Edit Configuration": "Edit Configuration", + "KMS Type": "KMS Type", + "HashiCorp Vault Transit Engine": "HashiCorp Vault Transit Engine", + + "Vault Server Address": "Vault Server Address", + "e.g., https://vault.example.com": "e.g., https://vault.example.com", + "Vault Token": "Vault Token", + "Enter your Vault authentication token": "Enter your Vault authentication token", + "Optional: Use Token authentication": "Optional: Use Token authentication", + "AppRole ID": "AppRole ID", + "Enter AppRole ID": "Enter AppRole ID", + "Optional: Use AppRole authentication with Secret ID": "Optional: Use AppRole authentication with Secret ID", + "AppRole Secret ID": "AppRole Secret ID", + "Enter AppRole Secret ID": "Enter AppRole Secret ID", + "Vault Namespace": "Vault Namespace", + "Leave empty for root namespace": "Leave empty for root namespace", + "Optional: Vault Enterprise namespace": "Optional: Vault Enterprise namespace", + "Mount Path": "Mount Path", + "Transit engine mount name, default: transit": "Transit engine mount name, default: transit", + "Timeout (seconds)": "Timeout (seconds)", + "Request timeout in seconds, default: 30": "Request timeout in seconds, default: 30", + "Default master key ID for SSE-KMS, fallback: rustfs-default-key": "Default master key ID for SSE-KMS, fallback: rustfs-default-key", + "Please select KMS type": "Please select KMS type", + "Save Configuration": "Save Configuration", + "Cancel": "Cancel", + + "KMS Keys Management": "KMS Keys Management", + "Key ID": "Key ID", + "Status": "Status", + "Created": "Created", + "Copy cURD": "Copy cURD", + "Disable": "Disable", + "Enable": "Enable", + "Total Keys": "Total Keys", + "Create New Key": "Create New Key", + "Edit": "Edit", + "Delete": "Delete", + "No KMS keys found": "No KMS keys found", + "Create your first KMS key to get started": "Create your first KMS key to get started", + "Create First Key": "Create First Key", + "Edit Key": "Edit Key", + "Create New Key": "Create New Key", + "Key Name": "Key Name", + "e.g., app-default": "e.g., app-default", + "Main key ID (Transit key name). Use business-related readable ID.": "Main key ID (Transit key name). Use business-related readable ID.", + "Algorithm": "Algorithm", + "Select encryption algorithm": "Select encryption algorithm", + "Encryption algorithm for the key.": "Encryption algorithm for the key.", + "Initial Status": "Initial Status", + "Update Key": "Update Key", + "Create Key": "Create Key", + "Confirm Delete": "Confirm Delete", + "Are you sure you want to delete this key?": "Are you sure you want to delete this key?", + "This action cannot be undone.": "This action cannot be undone.", + "Delete Key": "Delete Key", + "Key updated successfully": "Key updated successfully", + "Key created successfully": "Key created successfully", + "Failed to save key": "Failed to save key", + "Key deleted successfully": "Key deleted successfully", + "Failed to delete key": "Failed to delete key", + "Please enter key name": "Please enter key name", + "Last Updated": "Last Updated", + "Refresh": "Refresh", + "Reset": "Reset", + "Configuration loaded successfully": "Configuration loaded successfully", + "Failed to load configuration": "Failed to load configuration", + "Configuration saved successfully": "Configuration saved successfully", + "Failed to save configuration": "Failed to save configuration", + "Configuration reset successfully": "Configuration reset successfully", + "Configuration refreshed successfully": "Configuration refreshed successfully", + "KMS connection test successful": "KMS connection test successful", + "KMS connection test failed": "KMS connection test failed", + "cURD command copied to clipboard": "cURD command copied to clipboard", + "Key status updated successfully": "Key status updated successfully", + "Failed to update key status": "Failed to update key status", + "Please select a KMS provider": "Please select a KMS provider", + "Please enter Vault server address": "Please enter Vault server address", + "Please enter Vault key path": "Please enter Vault key path", + "Please enter Vault token": "Please enter Vault token" } diff --git a/i18n/locales/tr-TR.json b/i18n/locales/tr-TR.json index e37a9a2..53aca85 100644 --- a/i18n/locales/tr-TR.json +++ b/i18n/locales/tr-TR.json @@ -651,5 +651,99 @@ "Replication Options": "Çoğaltma Seçenekleri", "Please enter prefix": "Lütfen önek girin", "Suffix": "Son Ek", - "Please enter suffix": "Lütfen son ek girin" + "Please enter suffix": "Lütfen son ek girin", + "SSE Settings": "SSE Ayarları", + "Server-Side Encryption (SSE) Configuration": "Sunucu Tarafı Şifreleme (SSE) Yapılandırması", + "Configure server-side encryption for your objects using external key management services.": "Nesneleriniz için harici anahtar yönetim servisleri kullanarak sunucu tarafı şifrelemeyi yapılandırın.", + "KMS Status": "KMS Durumu", + "Not Configured": "Yapılandırılmamış", + "Available": "Mevcut", + "KMS server is not configured": "KMS sunucusu yapılandırılmamış", + "KMS server is available and ready for use": "KMS sunucusu mevcut ve kullanıma hazır", + "KMS Configuration": "KMS Yapılandırması", + "Current KMS Type": "Mevcut KMS Türü", + "Vault Server": "Vault Sunucusu", + "Mount Path": "Bağlama Yolu", + "Default Key ID": "Varsayılan Anahtar ID", + "No KMS configuration found": "KMS yapılandırması bulunamadı", + "Configure KMS": "KMS Yapılandır", + "Edit Configuration": "Yapılandırmayı Düzenle", + "KMS Type": "KMS Türü", + "HashiCorp Vault Transit Engine": "HashiCorp Vault Transit Motoru", + + "Vault Server Address": "Vault Sunucu Adresi", + "e.g., https://vault.example.com": "örn., https://vault.example.com", + "Vault Token": "Vault Token", + "Enter your Vault authentication token": "Vault kimlik doğrulama token'ınızı girin", + "Optional: Use Token authentication": "İsteğe bağlı: Token kimlik doğrulaması kullanın", + "AppRole ID": "AppRole ID", + "Enter AppRole ID": "AppRole ID girin", + "Optional: Use AppRole authentication with Secret ID": "İsteğe bağlı: Secret ID ile AppRole kimlik doğrulaması kullanın", + "AppRole Secret ID": "AppRole Secret ID", + "Enter AppRole Secret ID": "AppRole Secret ID girin", + "Vault Namespace": "Vault Ad Alanı", + "Leave empty for root namespace": "Kök ad alanı için boş bırakın", + "Optional: Vault Enterprise namespace": "İsteğe bağlı: Vault Enterprise ad alanı", + "Mount Path": "Bağlama Yolu", + "Transit engine mount name, default: transit": "Transit motor bağlama adı, varsayılan: transit", + "Timeout (seconds)": "Zaman Aşımı (saniye)", + "Request timeout in seconds, default: 30": "Saniye cinsinden istek zaman aşımı, varsayılan: 30", + "Default master key ID for SSE-KMS, fallback: rustfs-default-key": "SSE-KMS için varsayılan ana anahtar ID, geri dönüş: rustfs-default-key", + "Please select KMS type": "Lütfen KMS türünü seçin", + "Save Configuration": "Yapılandırmayı Kaydet", + "Cancel": "İptal", + + "KMS Keys Management": "KMS Anahtarları Yönetimi", + "Key ID": "Anahtar ID", + "Status": "Durum", + "Created": "Oluşturuldu", + "Copy cURD": "cURD Kopyala", + "Disable": "Devre Dışı Bırak", + "Enable": "Etkinleştir", + "Total Keys": "Toplam Anahtar", + "Create New Key": "Yeni Anahtar Oluştur", + "Edit": "Düzenle", + "Delete": "Sil", + "No KMS keys found": "KMS anahtarı bulunamadı", + "Create your first KMS key to get started": "Başlamak için ilk KMS anahtarınızı oluşturun", + "Create First Key": "İlk Anahtarı Oluştur", + "Edit Key": "Anahtarı Düzenle", + "Create New Key": "Yeni Anahtar Oluştur", + "Key Name": "Anahtar Adı", + "e.g., app-default": "örn., app-default", + "Main key ID (Transit key name). Use business-related readable ID.": "Ana anahtar ID (Transit key adı). İş ile ilgili okunabilir ID kullanın.", + "Algorithm": "Algoritma", + "Select encryption algorithm": "Şifreleme algoritması seçin", + "Encryption algorithm for the key.": "Anahtar için şifreleme algoritması.", + "Initial Status": "Başlangıç Durumu", + "Update Key": "Anahtarı Güncelle", + "Create Key": "Anahtar Oluştur", + "Confirm Delete": "Silme Onayı", + "Are you sure you want to delete this key?": "Bu anahtarı silmek istediğinizden emin misiniz?", + "This action cannot be undone.": "Bu işlem geri alınamaz.", + "Delete Key": "Anahtarı Sil", + "Key updated successfully": "Anahtar başarıyla güncellendi", + "Key created successfully": "Anahtar başarıyla oluşturuldu", + "Failed to save key": "Anahtar kaydedilemedi", + "Key deleted successfully": "Anahtar başarıyla silindi", + "Failed to delete key": "Anahtar silinemedi", + "Please enter key name": "Lütfen anahtar adını girin", + "Last Updated": "Son Güncelleme", + "Refresh": "Yenile", + "Reset": "Sıfırla", + "Configuration loaded successfully": "Yapılandırma başarıyla yüklendi", + "Failed to load configuration": "Yapılandırma yüklenemedi", + "Configuration saved successfully": "Yapılandırma başarıyla kaydedildi", + "Failed to save configuration": "Yapılandırma kaydedilemedi", + "Configuration reset successfully": "Yapılandırma başarıyla sıfırlandı", + "Configuration refreshed successfully": "Yapılandırma başarıyla yenilendi", + "KMS connection test successful": "KMS bağlantı testi başarılı", + "KMS connection test failed": "KMS bağlantı testi başarısız", + "cURD command copied to clipboard": "cURD komutu panoya kopyalandı", + "Key status updated successfully": "Anahtar durumu başarıyla güncellendi", + "Failed to update key status": "Anahtar durumu güncellenemedi", + "Please select a KMS provider": "Lütfen bir KMS sağlayıcısı seçin", + "Please enter Vault server address": "Lütfen Vault sunucu adresini girin", + "Please enter Vault key path": "Lütfen Vault anahtar yolunu girin", + "Please enter Vault token": "Lütfen Vault token girin" } diff --git a/i18n/locales/zh-CN.json b/i18n/locales/zh-CN.json index 6a5e671..961c836 100644 --- a/i18n/locales/zh-CN.json +++ b/i18n/locales/zh-CN.json @@ -652,5 +652,99 @@ "Download ready": "下载准备就绪", "Access Key length must be between 3 and 20 characters": "访问密钥长度必须为3到20个字符", "Secret Key length must be between 8 and 40 characters": "密钥长度必须为8到40个字符", - "Please select encryption type": "请选择加密类型" + "Please select encryption type": "请选择加密类型", + "SSE Settings": "加密设置", + "Server-Side Encryption (SSE) Configuration": "服务器端加密 (SSE) 配置", + "Configure server-side encryption for your objects using external key management services.": "为您的对象配置服务器端加密,使用外部密钥管理服务。", + "KMS Status": "KMS 状态", + "Not Configured": "未配置", + "Available": "可用", + "KMS server is not configured": "KMS服务器未配置", + "KMS server is available and ready for use": "KMS服务器可用且准备就绪", + "KMS Configuration": "KMS 配置", + "Current KMS Type": "当前KMS类型", + "Vault Server": "Vault 服务器", + "Mount Path": "挂载路径", + "Default Key ID": "默认密钥ID", + "No KMS configuration found": "未找到KMS配置", + "Configure KMS": "配置KMS", + "Edit Configuration": "编辑配置", + "KMS Type": "KMS 类型", + "HashiCorp Vault Transit Engine": "HashiCorp Vault Transit 引擎", + + "Vault Server Address": "Vault 服务器地址", + "e.g., https://vault.example.com": "例如:https://vault.example.com", + "Vault Token": "Vault 令牌", + "Enter your Vault authentication token": "输入您的Vault认证令牌", + "Optional: Use Token authentication": "可选:使用Token认证", + "AppRole ID": "AppRole ID", + "Enter AppRole ID": "输入AppRole ID", + "Optional: Use AppRole authentication with Secret ID": "可选:使用AppRole和Secret ID认证", + "AppRole Secret ID": "AppRole Secret ID", + "Enter AppRole Secret ID": "输入AppRole Secret ID", + "Vault Namespace": "Vault 命名空间", + "Leave empty for root namespace": "留空表示根命名空间", + "Optional: Vault Enterprise namespace": "可选:Vault Enterprise命名空间", + "Mount Path": "挂载路径", + "Transit engine mount name, default: transit": "Transit引擎挂载名,默认:transit", + "Timeout (seconds)": "超时时间(秒)", + "Request timeout in seconds, default: 30": "请求超时时间(秒),默认:30", + "Default master key ID for SSE-KMS, fallback: rustfs-default-key": "SSE-KMS的默认主密钥ID,回退:rustfs-default-key", + "Please select KMS type": "请选择KMS类型", + "Save Configuration": "保存配置", + "Cancel": "取消", + + "KMS Keys Management": "KMS 密钥管理", + "Key ID": "密钥ID", + "Status": "状态", + "Created": "创建时间", + "Copy cURD": "复制cURD", + "Disable": "禁用", + "Enable": "启用", + "Total Keys": "密钥总数", + "Create New Key": "创建新密钥", + "Edit": "编辑", + "Delete": "删除", + "No KMS keys found": "未找到KMS密钥", + "Create your first KMS key to get started": "创建您的第一个KMS密钥开始使用", + "Create First Key": "创建第一个密钥", + "Edit Key": "编辑密钥", + "Create New Key": "创建新密钥", + "Key Name": "密钥名称", + "e.g., app-default": "例如:app-default", + "Main key ID (Transit key name). Use business-related readable ID.": "主密钥ID(Transit key名)。使用业务相关的可读ID。", + "Algorithm": "算法", + "Select encryption algorithm": "选择加密算法", + "Encryption algorithm for the key.": "密钥的加密算法。", + "Initial Status": "初始状态", + "Update Key": "更新密钥", + "Create Key": "创建密钥", + "Confirm Delete": "确认删除", + "Are you sure you want to delete this key?": "您确定要删除这个密钥吗?", + "This action cannot be undone.": "此操作无法撤销。", + "Delete Key": "删除密钥", + "Key updated successfully": "密钥更新成功", + "Key created successfully": "密钥创建成功", + "Failed to save key": "密钥保存失败", + "Key deleted successfully": "密钥删除成功", + "Failed to delete key": "密钥删除失败", + "Please enter key name": "请输入密钥名称", + "Last Updated": "最后更新", + "Refresh": "刷新", + "Reset": "重置", + "Configuration loaded successfully": "配置加载成功", + "Failed to load configuration": "配置加载失败", + "Configuration saved successfully": "配置保存成功", + "Failed to save configuration": "配置保存失败", + "Configuration reset successfully": "配置重置成功", + "Configuration refreshed successfully": "配置刷新成功", + "KMS connection test successful": "KMS连接测试成功", + "KMS connection test failed": "KMS连接测试失败", + "cURD command copied to clipboard": "cURD命令已复制到剪贴板", + "Key status updated successfully": "密钥状态更新成功", + "Failed to update key status": "密钥状态更新失败", + "Please select a KMS provider": "请选择KMS提供商", + "Please enter Vault server address": "请输入Vault服务器地址", + "Please enter Vault key path": "请输入Vault密钥路径", + "Please enter Vault token": "请输入Vault令牌" } diff --git a/nuxt.config.ts b/nuxt.config.ts index 7027fa7..a150ccb 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -4,8 +4,7 @@ import Components from 'unplugin-vue-components/vite'; const appName = process.env.APP_NAME || 'RustFS'; const baseUrl = (process.env.BASE_URL || '/rustfs/console/').replace(/\/$/, ''); -const appDescription = - process.env.APP_DESCRIPTION || 'RustFS is a distributed file system written in Rust.'; +const appDescription = process.env.APP_DESCRIPTION || 'RustFS is a distributed file system written in Rust.'; // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ diff --git a/pages/sse/index.vue b/pages/sse/index.vue new file mode 100644 index 0000000..bee3bad --- /dev/null +++ b/pages/sse/index.vue @@ -0,0 +1,596 @@ + + + + + From 99467dc5736e791594e9b5de2d938152899a1725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E7=99=BB=E5=B1=B1?= Date: Thu, 14 Aug 2025 14:15:49 +0800 Subject: [PATCH 2/8] =?UTF-8?q?feat=EF=BC=9A=20Delete=20Duplicate=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/locales/en-US.json | 16 ---------------- i18n/locales/tr-TR.json | 16 ---------------- i18n/locales/zh-CN.json | 18 ------------------ 3 files changed, 50 deletions(-) diff --git a/i18n/locales/en-US.json b/i18n/locales/en-US.json index 06e58a3..9ee39d1 100644 --- a/i18n/locales/en-US.json +++ b/i18n/locales/en-US.json @@ -377,7 +377,6 @@ "Server Address": "Server Address", "Please enter server address (e.g., http://localhost:9000)": "Please enter server address (e.g., http://localhost:9000)", "Example: http://localhost:9000 or https://your-domain.com": "Example: http://localhost:9000 or https://your-domain.com", - "Save Configuration": "Save Configuration", "Skip": "Skip", "Need help?": "Need help?", "View Documentation": "View Documentation", @@ -395,7 +394,6 @@ "Page will refresh automatically after saving configuration": "Page will refresh automatically after saving configuration", "Make sure the server address is accessible from your network": "Make sure the server address is accessible from your network", "Failed to load current configuration": "Failed to load current configuration", - "Configuration saved successfully": "Configuration saved successfully", "Configuration reset successfully": "Configuration reset successfully", "Reset to default successfully": "Reset to default successfully", "Leave empty to use current host as default": "Leave empty to use current host as default", @@ -409,7 +407,6 @@ "Bucket Configuration": "Bucket Configuration", "Adding to Upload Queue": "Adding to Upload Queue", "Adding to Delete Queue": "Adding to Delete Queue", - "Chinese": "Chinese", "English": "English", "Turkish": "Turkish", @@ -519,7 +516,6 @@ "Network": "Network", "Total Space": "Total Space", "Used": "Used", - "Available": "Available", "Servers": "Servers", "Disks": "Disks", "Uptime": "Uptime", @@ -684,31 +680,24 @@ "Vault Namespace": "Vault Namespace", "Leave empty for root namespace": "Leave empty for root namespace", "Optional: Vault Enterprise namespace": "Optional: Vault Enterprise namespace", - "Mount Path": "Mount Path", "Transit engine mount name, default: transit": "Transit engine mount name, default: transit", "Timeout (seconds)": "Timeout (seconds)", "Request timeout in seconds, default: 30": "Request timeout in seconds, default: 30", "Default master key ID for SSE-KMS, fallback: rustfs-default-key": "Default master key ID for SSE-KMS, fallback: rustfs-default-key", "Please select KMS type": "Please select KMS type", "Save Configuration": "Save Configuration", - "Cancel": "Cancel", - "KMS Keys Management": "KMS Keys Management", "Key ID": "Key ID", - "Status": "Status", "Created": "Created", "Copy cURD": "Copy cURD", "Disable": "Disable", "Enable": "Enable", "Total Keys": "Total Keys", "Create New Key": "Create New Key", - "Edit": "Edit", - "Delete": "Delete", "No KMS keys found": "No KMS keys found", "Create your first KMS key to get started": "Create your first KMS key to get started", "Create First Key": "Create First Key", "Edit Key": "Edit Key", - "Create New Key": "Create New Key", "Key Name": "Key Name", "e.g., app-default": "e.g., app-default", "Main key ID (Transit key name). Use business-related readable ID.": "Main key ID (Transit key name). Use business-related readable ID.", @@ -716,9 +705,7 @@ "Select encryption algorithm": "Select encryption algorithm", "Encryption algorithm for the key.": "Encryption algorithm for the key.", "Initial Status": "Initial Status", - "Update Key": "Update Key", "Create Key": "Create Key", - "Confirm Delete": "Confirm Delete", "Are you sure you want to delete this key?": "Are you sure you want to delete this key?", "This action cannot be undone.": "This action cannot be undone.", "Delete Key": "Delete Key", @@ -729,13 +716,10 @@ "Failed to delete key": "Failed to delete key", "Please enter key name": "Please enter key name", "Last Updated": "Last Updated", - "Refresh": "Refresh", - "Reset": "Reset", "Configuration loaded successfully": "Configuration loaded successfully", "Failed to load configuration": "Failed to load configuration", "Configuration saved successfully": "Configuration saved successfully", "Failed to save configuration": "Failed to save configuration", - "Configuration reset successfully": "Configuration reset successfully", "Configuration refreshed successfully": "Configuration refreshed successfully", "KMS connection test successful": "KMS connection test successful", "KMS connection test failed": "KMS connection test failed", diff --git a/i18n/locales/tr-TR.json b/i18n/locales/tr-TR.json index 53aca85..4ff90d1 100644 --- a/i18n/locales/tr-TR.json +++ b/i18n/locales/tr-TR.json @@ -657,20 +657,17 @@ "Configure server-side encryption for your objects using external key management services.": "Nesneleriniz için harici anahtar yönetim servisleri kullanarak sunucu tarafı şifrelemeyi yapılandırın.", "KMS Status": "KMS Durumu", "Not Configured": "Yapılandırılmamış", - "Available": "Mevcut", "KMS server is not configured": "KMS sunucusu yapılandırılmamış", "KMS server is available and ready for use": "KMS sunucusu mevcut ve kullanıma hazır", "KMS Configuration": "KMS Yapılandırması", "Current KMS Type": "Mevcut KMS Türü", "Vault Server": "Vault Sunucusu", - "Mount Path": "Bağlama Yolu", "Default Key ID": "Varsayılan Anahtar ID", "No KMS configuration found": "KMS yapılandırması bulunamadı", "Configure KMS": "KMS Yapılandır", "Edit Configuration": "Yapılandırmayı Düzenle", "KMS Type": "KMS Türü", "HashiCorp Vault Transit Engine": "HashiCorp Vault Transit Motoru", - "Vault Server Address": "Vault Sunucu Adresi", "e.g., https://vault.example.com": "örn., https://vault.example.com", "Vault Token": "Vault Token", @@ -690,20 +687,13 @@ "Request timeout in seconds, default: 30": "Saniye cinsinden istek zaman aşımı, varsayılan: 30", "Default master key ID for SSE-KMS, fallback: rustfs-default-key": "SSE-KMS için varsayılan ana anahtar ID, geri dönüş: rustfs-default-key", "Please select KMS type": "Lütfen KMS türünü seçin", - "Save Configuration": "Yapılandırmayı Kaydet", - "Cancel": "İptal", - "KMS Keys Management": "KMS Anahtarları Yönetimi", "Key ID": "Anahtar ID", - "Status": "Durum", "Created": "Oluşturuldu", "Copy cURD": "cURD Kopyala", "Disable": "Devre Dışı Bırak", "Enable": "Etkinleştir", "Total Keys": "Toplam Anahtar", - "Create New Key": "Yeni Anahtar Oluştur", - "Edit": "Düzenle", - "Delete": "Sil", "No KMS keys found": "KMS anahtarı bulunamadı", "Create your first KMS key to get started": "Başlamak için ilk KMS anahtarınızı oluşturun", "Create First Key": "İlk Anahtarı Oluştur", @@ -716,9 +706,7 @@ "Select encryption algorithm": "Şifreleme algoritması seçin", "Encryption algorithm for the key.": "Anahtar için şifreleme algoritması.", "Initial Status": "Başlangıç Durumu", - "Update Key": "Anahtarı Güncelle", "Create Key": "Anahtar Oluştur", - "Confirm Delete": "Silme Onayı", "Are you sure you want to delete this key?": "Bu anahtarı silmek istediğinizden emin misiniz?", "This action cannot be undone.": "Bu işlem geri alınamaz.", "Delete Key": "Anahtarı Sil", @@ -729,13 +717,9 @@ "Failed to delete key": "Anahtar silinemedi", "Please enter key name": "Lütfen anahtar adını girin", "Last Updated": "Son Güncelleme", - "Refresh": "Yenile", - "Reset": "Sıfırla", "Configuration loaded successfully": "Yapılandırma başarıyla yüklendi", "Failed to load configuration": "Yapılandırma yüklenemedi", - "Configuration saved successfully": "Yapılandırma başarıyla kaydedildi", "Failed to save configuration": "Yapılandırma kaydedilemedi", - "Configuration reset successfully": "Yapılandırma başarıyla sıfırlandı", "Configuration refreshed successfully": "Yapılandırma başarıyla yenilendi", "KMS connection test successful": "KMS bağlantı testi başarılı", "KMS connection test failed": "KMS bağlantı testi başarısız", diff --git a/i18n/locales/zh-CN.json b/i18n/locales/zh-CN.json index 961c836..168404f 100644 --- a/i18n/locales/zh-CN.json +++ b/i18n/locales/zh-CN.json @@ -533,7 +533,6 @@ "S3 Compatible": "兼容 S3", "Reliable distributed file system": "靠谱的分布式文件系统", "Visit website": "访问官网", - "Update Key": "更新密钥", "Update Success": "更新成功", "Update Failed": "更新失败", "TierNameAlreadyExist": "", @@ -590,7 +589,6 @@ "Expire": "过期", "On": "开启", "Off": "关闭", - "Click to modify": "点击修改", "Replicate existing objects": "复制现有对象", "Sync metadata": "同步元数据", @@ -601,13 +599,11 @@ "Please enter bandwidth": "请输入带宽", "Please enter storage type": "请输入存储类型", "Add Replication Rule": "添加复制规则", - "Server Configuration": "服务器配置", "Please configure your RustFS server address": "请配置您的RustFS服务器地址", "Server Address": "服务器地址", "Please enter server address (e.g., http://localhost:9000)": "请输入服务器地址(例如:http://localhost:9000)", "Example: http://localhost:9000 or https://your-domain.com": "示例:http://localhost:9000 或 https://your-domain.com", - "Save Configuration": "保存配置", "Skip": "跳过", "Need help?": "需要帮助?", "View Documentation": "查看文档", @@ -625,8 +621,6 @@ "Page will refresh automatically after saving configuration": "保存配置后页面将自动刷新", "Make sure the server address is accessible from your network": "确保服务器地址在您的网络中可访问", "Failed to load current configuration": "加载当前配置失败", - "Configuration saved successfully": "配置保存成功", - "Configuration reset successfully": "配置重置成功", "Reset to default successfully": "重置为默认成功", "Leave empty to use current host as default": "留空表示使用当前主机作为默认值", "All files are already in Tasks.": "所有文件都已经在任务中。", @@ -658,20 +652,17 @@ "Configure server-side encryption for your objects using external key management services.": "为您的对象配置服务器端加密,使用外部密钥管理服务。", "KMS Status": "KMS 状态", "Not Configured": "未配置", - "Available": "可用", "KMS server is not configured": "KMS服务器未配置", "KMS server is available and ready for use": "KMS服务器可用且准备就绪", "KMS Configuration": "KMS 配置", "Current KMS Type": "当前KMS类型", "Vault Server": "Vault 服务器", - "Mount Path": "挂载路径", "Default Key ID": "默认密钥ID", "No KMS configuration found": "未找到KMS配置", "Configure KMS": "配置KMS", "Edit Configuration": "编辑配置", "KMS Type": "KMS 类型", "HashiCorp Vault Transit Engine": "HashiCorp Vault Transit 引擎", - "Vault Server Address": "Vault 服务器地址", "e.g., https://vault.example.com": "例如:https://vault.example.com", "Vault Token": "Vault 令牌", @@ -692,19 +683,13 @@ "Default master key ID for SSE-KMS, fallback: rustfs-default-key": "SSE-KMS的默认主密钥ID,回退:rustfs-default-key", "Please select KMS type": "请选择KMS类型", "Save Configuration": "保存配置", - "Cancel": "取消", - "KMS Keys Management": "KMS 密钥管理", "Key ID": "密钥ID", - "Status": "状态", "Created": "创建时间", "Copy cURD": "复制cURD", "Disable": "禁用", "Enable": "启用", "Total Keys": "密钥总数", - "Create New Key": "创建新密钥", - "Edit": "编辑", - "Delete": "删除", "No KMS keys found": "未找到KMS密钥", "Create your first KMS key to get started": "创建您的第一个KMS密钥开始使用", "Create First Key": "创建第一个密钥", @@ -719,7 +704,6 @@ "Initial Status": "初始状态", "Update Key": "更新密钥", "Create Key": "创建密钥", - "Confirm Delete": "确认删除", "Are you sure you want to delete this key?": "您确定要删除这个密钥吗?", "This action cannot be undone.": "此操作无法撤销。", "Delete Key": "删除密钥", @@ -730,8 +714,6 @@ "Failed to delete key": "密钥删除失败", "Please enter key name": "请输入密钥名称", "Last Updated": "最后更新", - "Refresh": "刷新", - "Reset": "重置", "Configuration loaded successfully": "配置加载成功", "Failed to load configuration": "配置加载失败", "Configuration saved successfully": "配置保存成功", From 90efb6c00b81b91a943e6127c65f7f57ab038fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E7=99=BB=E5=B1=B1?= Date: Fri, 15 Aug 2025 14:47:39 +0800 Subject: [PATCH 3/8] =?UTF-8?q?feat=EF=BC=9AAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composables/useSSE.ts | 49 ++++++ i18n/locales/en-US.json | 24 ++- i18n/locales/tr-TR.json | 23 +++ i18n/locales/zh-CN.json | 23 ++- pages/sse/index.vue | 342 +++++++++++++++++++++++++++++----------- 5 files changed, 370 insertions(+), 91 deletions(-) create mode 100644 composables/useSSE.ts diff --git a/composables/useSSE.ts b/composables/useSSE.ts new file mode 100644 index 0000000..42cbdf5 --- /dev/null +++ b/composables/useSSE.ts @@ -0,0 +1,49 @@ +export const useSSE = () => { + const { $api } = useNuxtApp(); + return { + // 获取KMS的状态 + async getKMSStatus() { + return await $api.get('/kms/status'); + }, + + // 配置KMS + async configureKMS(data: any) { + return await $api.post('/kms/configure', data); + }, + + // 获取配置 + async getConfiguration() { + return await $api.get('/kms/config'); + }, + + // 创建秘钥 + async createKey(data: any) { + return await $api.post('/kms/key/create', data); + }, + + // 启用秘钥 + async enableKey(keyName: string) { + return await $api.put('/kms/key/enable', {}, { params: { keyName } }); + }, + + // 禁用秘钥 + async disableKey(keyName: string) { + return await $api.put('/kms/key/disable', {}, { params: { keyName } }); + }, + + // 获取秘钥状态 + async getKeyStatus(params: any) { + return await $api.get('/kms/key/status', { params: params }); + }, + + // 获取秘钥列表 + async getKeyList() { + return await $api.get('/kms/key/list'); + }, + + // 删除秘钥 + async deleteKey(keyName: string) { + return await $api.delete('/kms/key/delete', { params: { keyName } }); + }, + }; +}; diff --git a/i18n/locales/en-US.json b/i18n/locales/en-US.json index 9ee39d1..58f3956 100644 --- a/i18n/locales/en-US.json +++ b/i18n/locales/en-US.json @@ -225,6 +225,15 @@ "Canceled": "Canceled", "Groups": "Groups", "Status": "Status", + "Active": "Active", + "Inactive": "Inactive", + "Activate": "Activate", + "Deactivate": "Deactivate", + "Pending Deletion": "Pending Deletion", + "Cannot modify status while pending deletion": "Cannot modify status while pending deletion", + "Already pending deletion": "Already pending deletion", + "Deleting...": "Deleting...", + "Key is already pending deletion": "Key is already pending deletion", "Members": "Members", "Search Group": "Search Group", "Assign Policy": "Assign Policy", @@ -704,7 +713,6 @@ "Algorithm": "Algorithm", "Select encryption algorithm": "Select encryption algorithm", "Encryption algorithm for the key.": "Encryption algorithm for the key.", - "Initial Status": "Initial Status", "Create Key": "Create Key", "Are you sure you want to delete this key?": "Are you sure you want to delete this key?", "This action cannot be undone.": "This action cannot be undone.", @@ -726,6 +734,20 @@ "cURD command copied to clipboard": "cURD command copied to clipboard", "Key status updated successfully": "Key status updated successfully", "Failed to update key status": "Failed to update key status", + "Failed to load key list": "Failed to load key list", + "Set as Local Development": "Set as Local Development", + "Local development mode set successfully": "Local development mode set successfully", + "Failed to set local development mode": "Failed to set local development mode", + "KMS is not configured, please configure it first": "KMS is not configured, please configure it first", + "Please configure KMS first": "Please configure KMS first", + "KMS not available for key operations": "KMS not available for key operations", + "Backend": "Backend", + "Degraded": "Degraded", + "Failed": "Failed", + "Unknown": "Unknown", + "KMS server is reachable but encryption/decryption path not fully verified": "KMS server is reachable but encryption/decryption path not fully verified", + "KMS server is not reachable": "KMS server is not reachable", + "KMS server status unknown": "KMS server status unknown", "Please select a KMS provider": "Please select a KMS provider", "Please enter Vault server address": "Please enter Vault server address", "Please enter Vault key path": "Please enter Vault key path", diff --git a/i18n/locales/tr-TR.json b/i18n/locales/tr-TR.json index 4ff90d1..f4a1674 100644 --- a/i18n/locales/tr-TR.json +++ b/i18n/locales/tr-TR.json @@ -225,6 +225,15 @@ "Canceled": "İptal Edildi", "Groups": "Gruplar", "Status": "Durum", + "Active": "Aktif", + "Inactive": "Pasif", + "Activate": "Etkinleştir", + "Deactivate": "Devre Dışı Bırak", + "Pending Deletion": "Silme Bekliyor", + "Cannot modify status while pending deletion": "Silme beklerken durum değiştirilemez", + "Already pending deletion": "Zaten silme bekliyor", + "Deleting...": "Siliniyor...", + "Key is already pending deletion": "Anahtar zaten silme bekliyor", "Members": "Üyeler", "Search Group": "Grup Ara", "Assign Policy": "Politika Ata", @@ -726,6 +735,20 @@ "cURD command copied to clipboard": "cURD komutu panoya kopyalandı", "Key status updated successfully": "Anahtar durumu başarıyla güncellendi", "Failed to update key status": "Anahtar durumu güncellenemedi", + "Failed to load key list": "Anahtar listesi yüklenemedi", + "Set as Local Development": "Yerel Geliştirme Olarak Ayarla", + "Local development mode set successfully": "Yerel geliştirme modu başarıyla ayarlandı", + "Failed to set local development mode": "Yerel geliştirme modu ayarlanamadı", + "KMS is not configured, please configure it first": "KMS yapılandırılmamış, lütfen önce yapılandırın", + "Please configure KMS first": "Lütfen önce KMS'i yapılandırın", + "KMS not available for key operations": "KMS anahtar işlemleri için mevcut değil", + "Backend": "Arka Uç", + "Degraded": "Düşürülmüş", + "Failed": "Başarısız", + "Unknown": "Bilinmeyen", + "KMS server is reachable but encryption/decryption path not fully verified": "KMS sunucusu erişilebilir ancak şifreleme/şifre çözme yolu tam olarak doğrulanmadı", + "KMS server is not reachable": "KMS sunucusuna erişilemiyor", + "KMS server status unknown": "KMS sunucu durumu bilinmiyor", "Please select a KMS provider": "Lütfen bir KMS sağlayıcısı seçin", "Please enter Vault server address": "Lütfen Vault sunucu adresini girin", "Please enter Vault key path": "Lütfen Vault anahtar yolunu girin", diff --git a/i18n/locales/zh-CN.json b/i18n/locales/zh-CN.json index 168404f..13d1764 100644 --- a/i18n/locales/zh-CN.json +++ b/i18n/locales/zh-CN.json @@ -249,6 +249,15 @@ "Canceled": "已取消", "Groups": "分组", "Status": "状态", + "Active": "激活", + "Inactive": "未激活", + "Activate": "激活", + "Deactivate": "停用", + "Pending Deletion": "删除中", + "Cannot modify status while pending deletion": "删除中无法修改状态", + "Already pending deletion": "已在删除中", + "Deleting...": "删除中...", + "Key is already pending deletion": "密钥已在删除中", "Members": "成员", "Search Group": "搜索用户组", "Assign Policy": "分配策略", @@ -701,7 +710,6 @@ "Algorithm": "算法", "Select encryption algorithm": "选择加密算法", "Encryption algorithm for the key.": "密钥的加密算法。", - "Initial Status": "初始状态", "Update Key": "更新密钥", "Create Key": "创建密钥", "Are you sure you want to delete this key?": "您确定要删除这个密钥吗?", @@ -725,6 +733,19 @@ "cURD command copied to clipboard": "cURD命令已复制到剪贴板", "Key status updated successfully": "密钥状态更新成功", "Failed to update key status": "密钥状态更新失败", + "Failed to load key list": "密钥列表加载失败", + "Set as Local Development": "设置为本地开发", + "Local development mode set successfully": "本地开发模式设置成功", + "Failed to set local development mode": "设置本地开发模式失败", + "KMS is not configured, please configure it first": "KMS未配置,请先进行配置", + "Please configure KMS first": "请先配置KMS", + "KMS not available for key operations": "KMS不可用于密钥操作", + "Backend": "后端", + "Degraded": "降级", + "Unknown": "未知", + "KMS server is reachable but encryption/decryption path not fully verified": "KMS服务器可达,但加解密路径未完全验证", + "KMS server is not reachable": "KMS服务器不可达", + "KMS server status unknown": "KMS服务器状态未知", "Please select a KMS provider": "请选择KMS提供商", "Please enter Vault server address": "请输入Vault服务器地址", "Please enter Vault key path": "请输入Vault密钥路径", diff --git a/pages/sse/index.vue b/pages/sse/index.vue index bee3bad..aea4fee 100644 --- a/pages/sse/index.vue +++ b/pages/sse/index.vue @@ -21,6 +21,9 @@
{{ getKmsStatusDescription() }}
+
+ {{ t('Backend') }}: {{ sseKmsForm.kms_backend }} +
@@ -170,7 +173,12 @@
{{ t('Total Keys') }}: {{ kmsKeys.length }}
- + @@ -180,28 +188,39 @@
-
+
-
{{ key.name }}
+
{{ key.keyName }}
-
{{ t('Key ID') }}: {{ key.id }}
+
{{ t('Key ID') }}: {{ key.keyId }}
{{ t('Algorithm') }}: {{ key.algorithm }}
{{ t('Status') }}: - - {{ key.status === 'enabled' ? t('Enabled') : t('Disabled') }} + + {{ getKeyStatusText(key.status) }}
-
{{ t('Created') }}: {{ formatDate(key.createdAt) }}
+
{{ t('Created') }}: {{ formatDate(new Date(key.createdAt)) }}
- - {{ key.status === 'enabled' ? t('Disable') : t('Enable') }} + + {{ key.status === 'Active' ? t('Deactivate') : t('Activate') }} - - {{ t('Delete') }} + + {{ key.status === 'PendingDeletion' ? t('Deleting...') : t('Delete') }}
@@ -213,7 +232,12 @@
{{ t('No KMS keys found') }}
{{ t('Create your first KMS key to get started') }}
- + {{ t('Create First Key') }}
@@ -252,13 +276,6 @@
- - - - {{ t('Enabled') }} - {{ t('Disabled') }} - - - {{ t('Disabled') }} + {{ t('Disabled') }} + SSE-KMS + SSE-S3 + {{ t('Disabled') }} - + @@ -175,13 +165,7 @@ draggable :style="{ width: '550px' }" > - + - - + + @@ -213,12 +196,7 @@ draggable :style="{ width: '550px' }" > - + {{ t('COMPLIANCE') }} @@ -266,7 +244,7 @@ const getData = async () => { await getTags(); await getVersioningStatus(); await getObjectLockConfig(); - // await getBucketEncryptionFn(); + await getBucketEncryptionFn(); await getbucketPolicy(); }; @@ -286,6 +264,9 @@ const { deleteBucketEncryption, } = useBucket({}); +// 使用 SSE 相关功能 +const { getKeyList } = useSSE(); + /**********object lock ***********************/ const lockStatus = ref(false); const objectLockLoading = ref(false); @@ -296,18 +277,15 @@ const getObjectLockConfig = async () => { getObjectLockConfiguration(bucketName.value) .then(res => { if (res.ObjectLockConfiguration?.ObjectLockEnabled) { - lockStatus.value = - res.ObjectLockConfiguration?.ObjectLockEnabled == 'Enabled' ? true : false; + lockStatus.value = res.ObjectLockConfiguration?.ObjectLockEnabled == 'Enabled' ? true : false; if (res.ObjectLockConfiguration?.Rule) { retentionEnabled.value = true; - retentionFormValue.value.retentionMode = - res.ObjectLockConfiguration?.Rule?.DefaultRetention?.Mode || null; + retentionFormValue.value.retentionMode = res.ObjectLockConfiguration?.Rule?.DefaultRetention?.Mode || null; retentionFormValue.value.retentionPeriod = res.ObjectLockConfiguration?.Rule?.DefaultRetention?.Days || res.ObjectLockConfiguration?.Rule?.DefaultRetention?.Years || null; - retentionFormValue.value.retentionUnit = res.ObjectLockConfiguration?.Rule - ?.DefaultRetention?.Years + retentionFormValue.value.retentionUnit = res.ObjectLockConfiguration?.Rule?.DefaultRetention?.Years ? 'Years' : res.ObjectLockConfiguration?.Rule?.DefaultRetention?.Days ? 'Days' @@ -338,11 +316,7 @@ const getbucketPolicy = async () => { if (res.Policy) { policyFormValue.value.content = res.Policy; - bucketPolicy.value = getBucketPolicyFn( - JSON.parse(res.Policy).Statement, - bucketName.value, - '' - ); + bucketPolicy.value = getBucketPolicyFn(JSON.parse(res.Policy).Statement, bucketName.value, ''); policyFormValue.value.policy = bucketPolicy.value; if (bucketPolicy.value == 'none') { bucketPolicy.value = 'custom'; @@ -384,12 +358,7 @@ const submitPolicyForm = () => { message.error(t('Edit Failed') + ': ' + error.message); }); } else { - const policys = setBucketPolicy( - [], - policyFormValue.value.policy as BucketPolicyType, - bucketName.value, - '' - ); + const policys = setBucketPolicy([], policyFormValue.value.policy as BucketPolicyType, bucketName.value, ''); console.log('🚀 ~ policys:', policys); putBucketPolicy(bucketName.value, JSON.stringify({ Version: '2012-10-17', Statement: policys })) .then(() => { @@ -426,6 +395,9 @@ const encryptFormValue = ref({ kmsKeyId: '', }); +// KMS 密钥列表 +const kmsKeyOptions = ref([]); + const encryptOptions = [ { label: t('Disabled'), @@ -442,47 +414,126 @@ const encryptOptions = [ ]; const getBucketEncryptionFn = async () => { - const res = await getBucketEncryption(bucketName.value); - console.log(res); + try { + const res = await getBucketEncryption(bucketName.value); + if ( + res && + res.ServerSideEncryptionConfiguration && + res.ServerSideEncryptionConfiguration.Rules && + res.ServerSideEncryptionConfiguration.Rules.length > 0 + ) { + const rule = res.ServerSideEncryptionConfiguration.Rules[0]; + if (rule.ApplyServerSideEncryptionByDefault) { + const sseAlgorithm = rule.ApplyServerSideEncryptionByDefault.SSEAlgorithm; + if (sseAlgorithm) { + encryptFormValue.value.encrypt = sseAlgorithm; + } + const kmsKeyId = rule.ApplyServerSideEncryptionByDefault.KMSMasterKeyID; + if (kmsKeyId) { + encryptFormValue.value.kmsKeyId = kmsKeyId; + } + } + } else { + encryptFormValue.value.encrypt = 'disabled'; + encryptFormValue.value.kmsKeyId = ''; + } + } catch (error: any) { + // 如果没有加密配置,设置为禁用状态 + if (error.status === 404) { + encryptFormValue.value.encrypt = 'disabled'; + encryptFormValue.value.kmsKeyId = ''; + } else { + console.error('Failed to get bucket encryption:', error); + } + } }; + +// 获取 KMS 密钥列表 +const fetchKMSKeys = async () => { + try { + const response = await getKeyList(); + if (response && response.keys) { + kmsKeyOptions.value = response.keys.map((key: any) => ({ + label: key.keyName || key.keyId, + value: key.keyId || key.keyName, + })); + } + } catch (error) { + console.error('Failed to fetch KMS keys:', error); + message.error(t('Failed to fetch KMS keys')); + } +}; + +// 监听加密类型变化,当选择 SSE-KMS 时自动获取 KMS 密钥列表 +watch( + () => encryptFormValue.value.encrypt, + newValue => { + if (newValue === 'SSE-KMS') { + fetchKMSKeys(); + } + } +); const editEncript = () => { showEncryptModal.value = true; + // 当选择 SSE-KMS 时,获取 KMS 密钥列表 + if (encryptFormValue.value.encrypt === 'SSE-KMS') { + fetchKMSKeys(); + } }; const submitEncryptForm = () => { - // 处理表单提交逻辑 - // console.log("提交表单数据:", encryptFormValue.value) - // showEncryptModal.value = false - // if (encryptFormValue.value.encrypt == "disabled") { - // deleteBucketEncryption(bucketName.value).then(() => { - // message.success("修改成功"); - // showEncryptModal.value = false; - // }); - // } else { - // putBucketEncryption(bucketName.value, { - // Rules: [ - // { - // ServerSideEncryptionByDefault: { - // SSEAlgorithm: encryptFormValue.value.encrypt, - // KMSMasterKeyID: encryptFormValue.value.encrypt == "SSE-KMS" ? encryptFormValue.value.kmsKeyId : "", - // }, - // }, - // ], - // }).then(() => { - // message.success("修改成功"); - // showEncryptModal.value = false; - // }); - // } - if (encryptFormValue.value.encrypt == 'SSE-KMS') { - message.error( - t( - 'The XML format you provided is incorrect, or has not been validated against our published schema. (MasterKeyID not found aws:kms).' - ) - ); - } else if (encryptFormValue.value.encrypt == 'SSE-S3') { - message.error(t('Server-side encryption is specified, but S3 is not configured.')); - } else { - message.success(t('Edit Success')); - showEncryptModal.value = false; + if (encryptFormValue.value.encrypt === 'disabled') { + // 禁用加密 + deleteBucketEncryption(bucketName.value) + .then(() => { + message.success(t('Edit Success')); + showEncryptModal.value = false; + }) + .catch(error => { + message.error(t('Edit Failed') + ': ' + error.message); + }); + } else if (encryptFormValue.value.encrypt === 'SSE-KMS') { + // 验证是否选择了 KMS Key + if (!encryptFormValue.value.kmsKeyId) { + message.error(t('Please select a KMS key for SSE-KMS encryption')); + return; + } + + // 启用 SSE-KMS 加密 + putBucketEncryption(bucketName.value, { + Rules: [ + { + ServerSideEncryptionByDefault: { + SSEAlgorithm: encryptFormValue.value.encrypt, + KMSMasterKeyID: encryptFormValue.value.kmsKeyId, + }, + }, + ], + }) + .then(() => { + message.success(t('Edit Success')); + showEncryptModal.value = false; + }) + .catch(error => { + message.error(t('Edit Failed') + ': ' + error.message); + }); + } else if (encryptFormValue.value.encrypt === 'SSE-S3') { + // 启用 SSE-S3 加密 + putBucketEncryption(bucketName.value, { + Rules: [ + { + ServerSideEncryptionByDefault: { + SSEAlgorithm: encryptFormValue.value.encrypt, + }, + }, + ], + }) + .then(() => { + message.success(t('Edit Success')); + showEncryptModal.value = false; + }) + .catch(error => { + message.error(t('Edit Failed') + ': ' + error.message); + }); } }; @@ -636,14 +687,8 @@ const submitRetentionForm = () => { Rule: { DefaultRetention: { Mode: retentionFormValue.value.retentionMode, - Days: - retentionFormValue.value.retentionUnit == 'Days' - ? retentionFormValue.value.retentionPeriod - : null, - Years: - retentionFormValue.value.retentionUnit == 'Years' - ? retentionFormValue.value.retentionPeriod - : null, + Days: retentionFormValue.value.retentionUnit == 'Days' ? retentionFormValue.value.retentionPeriod : null, + Years: retentionFormValue.value.retentionUnit == 'Years' ? retentionFormValue.value.retentionPeriod : null, }, }, }).then(() => { diff --git a/composables/useSSE.ts b/composables/useSSE.ts index 42cbdf5..521f7ef 100644 --- a/composables/useSSE.ts +++ b/composables/useSSE.ts @@ -18,7 +18,7 @@ export const useSSE = () => { // 创建秘钥 async createKey(data: any) { - return await $api.post('/kms/key/create', data); + return await $api.post('/kms/key/create', {}, { params: data }); }, // 启用秘钥 diff --git a/pages/sse/index.vue b/pages/sse/index.vue index aea4fee..83a7c38 100644 --- a/pages/sse/index.vue +++ b/pages/sse/index.vue @@ -255,8 +255,8 @@ aria-modal="true" > - - + +