feat(frontend): add GDrive storage test button in profile drawer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
erio
2026-03-06 22:56:23 +08:00
co-authored by Claude Opus 4.6
parent 298f5c1baf
commit 6a7bcabb6f
4 changed files with 52 additions and 3 deletions
+20 -1
View File
@@ -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<TestGDriveStorageResponse> {
const { data } = await apiClient.post<TestGDriveStorageResponse>('/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
+4 -1
View File
@@ -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: {
+4 -1
View File
@@ -4136,7 +4136,10 @@ export default {
oauthSuccess: 'Google Drive 授权成功',
oauthFailed: 'Google Drive 授权失败',
closeWindow: '此窗口将自动关闭',
processing: '正在处理授权...'
processing: '正在处理授权...',
testStorage: '测试存储',
testSuccess: 'Google Drive 存储测试成功(上传、访问、删除均正常)',
testFailed: 'Google Drive 存储测试失败'
}
},
streamTimeout: {
@@ -307,6 +307,15 @@
>
{{ testingSoraProfile ? t('common.loading') : t('admin.settings.soraS3.testConnection') }}
</button>
<button
v-if="soraProfileForm.provider === 'gdrive' && !creatingSoraProfile"
type="button"
class="btn btn-secondary btn-sm"
:disabled="testingSoraProfile || !soraProfileForm.enabled"
@click="testGDriveStorageConnection"
>
{{ testingSoraProfile ? t('common.loading') : t('admin.settings.soraS3.gdrive.testStorage') }}
</button>
<button type="button" class="btn btn-primary btn-sm" :disabled="savingSoraProfile" @click="saveSoraProfile">
{{ savingSoraProfile ? t('common.loading') : t('admin.settings.soraS3.saveProfile') }}
</button>
@@ -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) {