fix: improve model list layout in ProviderCard (#311)
* fix: add LongCat provider, OpenRouter free models, model list in cards - Add longcat to PROVIDER_ENV_MAP and PROVIDER_PRESETS - Add freeOnly param to fetchProviderModels, use for OpenRouter - Show model list in ProviderCard with count - Fix qq.ts import.meta.url → __dirname for CJS compat - Add zh/en i18n keys for model count display * fix: improve model list layout in ProviderCard - Change models-list from max-height to fixed height (100px) - Add align-content: flex-start to prevent vertical spacing - Optimize gap to 4px vertical, 6px horizontal - Fix model-tag height to 20px to prevent background stretching - Use inline-flex for better tag alignment Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: idle888 <546806917@qq.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,17 @@ export async function getAvailable(ctx: any) {
|
||||
}
|
||||
if (Object.keys(modelMeta).length === 0) modelMeta = undefined
|
||||
}
|
||||
} else if (providerKey === 'openrouter') {
|
||||
// OpenRouter has 200+ models — fetch dynamically like Copilot
|
||||
if (envMapping.api_key_env) {
|
||||
const orKey = envGetValue(envMapping.api_key_env)
|
||||
if (orKey) {
|
||||
try {
|
||||
const fetched = await fetchProviderModels(baseUrl, orKey, true)
|
||||
if (fetched.length > 0) modelsList = fetched
|
||||
} catch { /* ignore — leave empty, won't show */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (modelsList.length > 0) {
|
||||
const apiKey = envMapping.api_key_env ? envGetValue(envMapping.api_key_env) : ''
|
||||
|
||||
@@ -32,6 +32,7 @@ export const PROVIDER_ENV_MAP: Record<string, { api_key_env: string; base_url_en
|
||||
nous: { api_key_env: '', base_url_env: '' },
|
||||
'openai-codex': { api_key_env: '', base_url_env: '' },
|
||||
copilot: { api_key_env: '', base_url_env: '' },
|
||||
longcat: { api_key_env: 'LONGCAT_API_KEY', base_url_env: 'LONGCAT_BASE_URL' },
|
||||
}
|
||||
|
||||
// --- Types ---
|
||||
@@ -182,7 +183,7 @@ export async function listFilesRecursive(dir: string, prefix: string): Promise<{
|
||||
|
||||
// --- Provider model helpers ---
|
||||
|
||||
export async function fetchProviderModels(baseUrl: string, apiKey: string): Promise<string[]> {
|
||||
export async function fetchProviderModels(baseUrl: string, apiKey: string, freeOnly = false): Promise<string[]> {
|
||||
const base = baseUrl.replace(/\/+$/, '')
|
||||
const modelsUrl = /\/v\d+\/?$/.test(base) ? `${base}/models` : `${base}/v1/models`
|
||||
try {
|
||||
@@ -199,7 +200,9 @@ export async function fetchProviderModels(baseUrl: string, apiKey: string): Prom
|
||||
logger.warn('available-models %s returned unexpected format', modelsUrl)
|
||||
return []
|
||||
}
|
||||
return data.data.map(m => m.id).sort()
|
||||
let models = data.data.map(m => m.id)
|
||||
if (freeOnly) models = models.filter(m => m.endsWith(':free'))
|
||||
return models.sort()
|
||||
} catch (err: any) {
|
||||
logger.error(err, 'available-models %s failed', modelsUrl)
|
||||
return []
|
||||
|
||||
@@ -256,6 +256,13 @@ export const PROVIDER_PRESETS: ProviderPreset[] = [
|
||||
base_url: 'https://opencode.ai/zen/go/v1',
|
||||
models: ['glm-5.1', 'glm-5', 'kimi-k2.5', 'mimo-v2-pro', 'mimo-v2-omni', 'minimax-m2.7', 'minimax-m2.5'],
|
||||
},
|
||||
{
|
||||
label: 'LongCat',
|
||||
value: 'longcat',
|
||||
builtin: true,
|
||||
base_url: 'https://api.longcat.chat/openai',
|
||||
models: ['LongCat-Flash-Lite', 'LongCat-2.0-Preview'],
|
||||
},
|
||||
{
|
||||
label: 'OpenAI Codex',
|
||||
value: 'openai-codex',
|
||||
|
||||
Reference in New Issue
Block a user