()
| 73 | * 服务商表单管理 Hook |
| 74 | */ |
| 75 | export function useProviderForm() { |
| 76 | // 加载状态 |
| 77 | const loading = ref(true) |
| 78 | const saving = ref(false) |
| 79 | const testingText = ref(false) |
| 80 | const testingImage = ref(false) |
| 81 | const feedback = ref<{ |
| 82 | type: 'success' | 'error' |
| 83 | message?: string |
| 84 | error?: AppError |
| 85 | } | null>(null) |
| 86 | |
| 87 | // 配置数据 |
| 88 | const textConfig = ref<ProviderConfig>({ |
| 89 | active_provider: '', |
| 90 | providers: {} |
| 91 | }) |
| 92 | |
| 93 | const imageConfig = ref<ProviderConfig>({ |
| 94 | active_provider: '', |
| 95 | providers: {} |
| 96 | }) |
| 97 | |
| 98 | // 文本服务商弹窗状态 |
| 99 | const showTextModal = ref(false) |
| 100 | const editingTextProvider = ref<string | null>(null) |
| 101 | const textForm = ref<TextProviderForm>(createEmptyTextForm()) |
| 102 | |
| 103 | // 图片服务商弹窗状态 |
| 104 | const showImageModal = ref(false) |
| 105 | const editingImageProvider = ref<string | null>(null) |
| 106 | const imageForm = ref<ImageProviderForm>(createEmptyImageForm()) |
| 107 | |
| 108 | /** |
| 109 | * 创建空的文本服务商表单 |
| 110 | */ |
| 111 | function createEmptyTextForm(): TextProviderForm { |
| 112 | return { |
| 113 | name: '', |
| 114 | type: 'openai_compatible', |
| 115 | api_key: '', |
| 116 | api_key_masked: '', |
| 117 | base_url: '', |
| 118 | model: '', |
| 119 | endpoint_type: '/v1/chat/completions', |
| 120 | _has_api_key: false |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * 创建空的图片服务商表单 |
| 126 | */ |
| 127 | function createEmptyImageForm(): ImageProviderForm { |
| 128 | return { |
| 129 | name: '', |
| 130 | type: 'image_api', |
| 131 | api_key: '', |
| 132 | api_key_masked: '', |
nothing calls this directly
no test coverage detected