feat(media-hosting): add multi-provider configurable upload with fallback

Add Random/Preferred/None modes, preferred provider selection, and provider-order fallback. Catbox/Imgur/PostImages on Android via WebView; Electron CDP automation for Imgur/PostImages. Hide upload controls on web runtime.
This commit is contained in:
plebeius
2026-02-18 18:51:02 +08:00
parent 72b70915fd
commit 96a4aaec0e
63 changed files with 1991 additions and 201 deletions
+24
View File
@@ -0,0 +1,24 @@
import type { ProviderId } from './types';
export interface ProviderAttempt {
provider: ProviderId;
success: boolean;
error?: string;
}
export type TranslateFn = (key: string) => string;
/**
* Formats aggregated error message when all providers fail (random mode).
*/
export function formatAggregatedError(attempts: ProviderAttempt[], t: TranslateFn): string {
const details = attempts.map((a) => `${a.provider}: ${a.error ?? 'unknown'}`).join('; ');
return `${t('upload_failed')}. ${t('upload_failed_all_providers')}: ${details}`;
}
/**
* Formats error for preferred mode with actionable guidance.
*/
export function formatPreferredModeError(errorMessage: string, t: TranslateFn): string {
return `${t('upload_failed')}: ${errorMessage}. ${t('upload_failed_preferred_guidance')}`;
}