mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user