mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
Merge pull request #3559 from 315944211/fix/privacy-toast-result
fix: show privacy setting result accurately
This commit is contained in:
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user