fix(ui): P0-4 — SaaS settings page crash from paginated API response
Some checks failed
CI / Build Frontend (push) Has been cancelled
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Build Frontend (push) Has been cancelled
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
listRelayTasks() expected RelayTaskInfo[] but API returns
{items:[], total:0, page:1, page_size:20}. When setTasks() received
the paginated object, tasks.map() crashed during render, triggering
the ErrorBoundary fallback "SaaS 平台加载失败".
Fix: extract .items from paginated response with Array.isArray fallback.
Also adds onError logging to ErrorBoundary wrappers for easier debugging.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -113,6 +113,9 @@ export function SettingsLayout({ onBack }: SettingsLayoutProps) {
|
||||
case 'saas': return (
|
||||
<ErrorBoundary
|
||||
fallback={<div className="p-6 text-center text-gray-500">SaaS 平台加载失败,请稍后重试</div>}
|
||||
onError={(err, info) => {
|
||||
console.error('[Settings] SaaS page render error:', err, info.componentStack);
|
||||
}}
|
||||
>
|
||||
<SaaSSettings />
|
||||
</ErrorBoundary>
|
||||
@@ -120,6 +123,9 @@ export function SettingsLayout({ onBack }: SettingsLayoutProps) {
|
||||
case 'billing': return (
|
||||
<ErrorBoundary
|
||||
fallback={<div className="p-6 text-center text-gray-500">计费信息加载失败,请稍后重试</div>}
|
||||
onError={(err, info) => {
|
||||
console.error('[Settings] Billing page render error:', err, info.componentStack);
|
||||
}}
|
||||
>
|
||||
<PricingPage />
|
||||
</ErrorBoundary>
|
||||
|
||||
@@ -16,14 +16,15 @@ export function installRelayMethods(ClientClass: { prototype: any }): void {
|
||||
|
||||
// --- Relay Task Management ---
|
||||
|
||||
/** List relay tasks for the current user */
|
||||
/** List relay tasks for the current user (extracts items from paginated response) */
|
||||
proto.listRelayTasks = async function (this: { request<T>(method: string, path: string, body?: unknown): Promise<T> }, query?: { status?: string; page?: number; page_size?: number }): Promise<RelayTaskInfo[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (query?.status) params.set('status', query.status);
|
||||
if (query?.page) params.set('page', String(query.page));
|
||||
if (query?.page_size) params.set('page_size', String(query.page_size));
|
||||
const qs = params.toString();
|
||||
return this.request<RelayTaskInfo[]>('GET', `/api/v1/relay/tasks${qs ? '?' + qs : ''}`);
|
||||
const result = await this.request<{ items: RelayTaskInfo[]; total: number }>('GET', `/api/v1/relay/tasks${qs ? '?' + qs : ''}`);
|
||||
return Array.isArray(result) ? result : (result?.items ?? []);
|
||||
};
|
||||
|
||||
/** Retry a failed relay task (admin only) */
|
||||
|
||||
Reference in New Issue
Block a user