From 6a7bcabb6fa63b14e33fe0812850ee2ff7b43cfb Mon Sep 17 00:00:00 2001 From: erio Date: Fri, 6 Mar 2026 22:56:23 +0800 Subject: [PATCH] feat(frontend): add GDrive storage test button in profile drawer Co-Authored-By: Claude Opus 4.6 --- frontend/src/api/admin/settings.ts | 21 +++++++++++++++- frontend/src/i18n/locales/en.ts | 5 +++- frontend/src/i18n/locales/zh.ts | 5 +++- .../src/views/admin/DataManagementView.vue | 24 +++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/frontend/src/api/admin/settings.ts b/frontend/src/api/admin/settings.ts index 7f152d0a96..e6650c89f9 100644 --- a/frontend/src/api/admin/settings.ts +++ b/frontend/src/api/admin/settings.ts @@ -469,6 +469,24 @@ export async function exchangeGDriveOAuthCode(request: ExchangeGDriveOAuthCodeRe return data } +export interface TestGDriveStorageResponse { + status: string + quota_limit_bytes?: number + quota_used_bytes?: number + uploaded_file_id?: string + uploaded_file_name?: string + uploaded_file_size?: number + access_url?: string + web_view_link?: string + deleted?: boolean + delete_warning?: string +} + +export async function testGDriveStorage(): Promise { + const { data } = await apiClient.post('/admin/settings/sora-storage/gdrive-test') + return data +} + export const settingsAPI = { getSettings, updateSettings, @@ -488,7 +506,8 @@ export const settingsAPI = { deleteSoraS3Profile, setActiveSoraS3Profile, startGDriveOAuth, - exchangeGDriveOAuthCode + exchangeGDriveOAuthCode, + testGDriveStorage } export default settingsAPI diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index 3b70bb1e90..423e3973ac 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -3976,7 +3976,10 @@ export default { oauthSuccess: 'Google Drive authorization successful', oauthFailed: 'Google Drive authorization failed', closeWindow: 'This window will close automatically', - processing: 'Processing authorization...' + processing: 'Processing authorization...', + testStorage: 'Test Storage', + testSuccess: 'Google Drive storage test passed (upload, access, delete all OK)', + testFailed: 'Google Drive storage test failed' } }, streamTimeout: { diff --git a/frontend/src/i18n/locales/zh.ts b/frontend/src/i18n/locales/zh.ts index a2ec660f70..7840892525 100644 --- a/frontend/src/i18n/locales/zh.ts +++ b/frontend/src/i18n/locales/zh.ts @@ -4136,7 +4136,10 @@ export default { oauthSuccess: 'Google Drive 授权成功', oauthFailed: 'Google Drive 授权失败', closeWindow: '此窗口将自动关闭', - processing: '正在处理授权...' + processing: '正在处理授权...', + testStorage: '测试存储', + testSuccess: 'Google Drive 存储测试成功(上传、访问、删除均正常)', + testFailed: 'Google Drive 存储测试失败' } }, streamTimeout: { diff --git a/frontend/src/views/admin/DataManagementView.vue b/frontend/src/views/admin/DataManagementView.vue index c2d59bc4c9..bde24fbead 100644 --- a/frontend/src/views/admin/DataManagementView.vue +++ b/frontend/src/views/admin/DataManagementView.vue @@ -307,6 +307,15 @@ > {{ testingSoraProfile ? t('common.loading') : t('admin.settings.soraS3.testConnection') }} + @@ -563,6 +572,21 @@ async function testSoraProfileConnection() { } } +async function testGDriveStorageConnection() { + testingSoraProfile.value = true + try { + const result = await adminAPI.settings.testGDriveStorage() + const msg = result.status === 'ok' + ? t('admin.settings.soraS3.gdrive.testSuccess') + : t('admin.settings.soraS3.gdrive.testFailed') + appStore.showSuccess(msg) + } catch (error) { + appStore.showError((error as { message?: string })?.message || t('admin.settings.soraS3.gdrive.testFailed')) + } finally { + testingSoraProfile.value = false + } +} + async function startGDriveOAuth() { const form = soraProfileForm.value if (!form.client_id || !form.client_secret) {