Merge pull request #3559 from 315944211/fix/privacy-toast-result

fix: show privacy setting result accurately
This commit is contained in:
Wesley Liddick
2026-06-30 10:50:17 +08:00
committed by GitHub
+28 -1
View File
@@ -1604,12 +1604,39 @@ const handleResetQuota = async (a: Account) => {
console.error('Failed to reset quota:', error)
}
}
const privacyResultMessageKey = (account: Account): { type: 'success' | 'error'; key: string } => {
const mode = typeof account.extra?.privacy_mode === 'string' ? account.extra.privacy_mode : ''
if (account.platform === 'openai') {
switch (mode) {
case 'training_off':
return { type: 'success', key: 'admin.accounts.privacyTrainingOff' }
case 'training_set_cf_blocked':
return { type: 'error', key: 'admin.accounts.privacyCfBlocked' }
default:
return { type: 'error', key: 'admin.accounts.privacyFailed' }
}
}
if (account.platform === 'antigravity') {
if (mode === 'privacy_set') {
return { type: 'success', key: 'admin.accounts.privacyAntigravitySet' }
}
return { type: 'error', key: 'admin.accounts.privacyAntigravityFailed' }
}
return { type: 'error', key: 'admin.accounts.privacyFailed' }
}
const handleSetPrivacy = async (a: Account) => {
try {
const updated = await adminAPI.accounts.setPrivacy(a.id)
patchAccountInList(updated)
enterAutoRefreshSilentWindow()
appStore.showSuccess(t('common.success'))
const result = privacyResultMessageKey(updated)
if (result.type === 'success') {
appStore.showSuccess(t(result.key))
} else {
appStore.showError(t(result.key))
}
} catch (error: any) {
console.error('Failed to set privacy:', error)
appStore.showError(error?.response?.data?.message || t('admin.accounts.privacyFailed'))