import { http, type RequestOptions } from './http.ts' export interface JavaApiResponse { success: boolean message: string data: T | null } export interface LegacyApiSuccess { success: true msg?: string data?: T } export async function callJava( config: RequestOptions, ): Promise { const body = await http.request(config) const data = (body as { data?: unknown }).data ?? body if ( data && typeof data === 'object' && 'success' in data && typeof (data as { success: unknown }).success === 'boolean' ) { const wrapped = data as { success: boolean; message?: string; msg?: string; error?: string; data?: T } if (!wrapped.success) { throw new Error(wrapped.message || wrapped.msg || wrapped.error || '请求失败') } return wrapped.data as T } return data as T }