|
| 1 | +<template> |
| 2 | + <div class="ai-model-selector"> |
| 3 | + <select v-if="loading" class="form-control" disabled> |
| 4 | + <option>Loading models...</option> |
| 5 | + </select> |
| 6 | + <select |
| 7 | + v-else-if="models && models.length > 0" |
| 8 | + class="form-control" |
| 9 | + :value="modelValue" |
| 10 | + @change="$emit('update:modelValue', $event.target.value)" |
| 11 | + :disabled="disabled" |
| 12 | + > |
| 13 | + <option v-for="m in models" :key="m.id" :value="m.id"> |
| 14 | + {{ m.name || m.id }} |
| 15 | + </option> |
| 16 | + </select> |
| 17 | + <input |
| 18 | + v-else |
| 19 | + type="text" |
| 20 | + class="form-control" |
| 21 | + :value="modelValue" |
| 22 | + @input="$emit('update:modelValue', $event.target.value)" |
| 23 | + placeholder="Enter model name or validate API key" |
| 24 | + :disabled="disabled" |
| 25 | + /> |
| 26 | + </div> |
| 27 | +</template> |
| 28 | + |
| 29 | +<script> |
| 30 | +export default { |
| 31 | + name: "AiModelSelector", |
| 32 | + props: { |
| 33 | + modelValue: { |
| 34 | + type: String, |
| 35 | + default: "", |
| 36 | + }, |
| 37 | + models: { |
| 38 | + type: Array, |
| 39 | + default: () => [], |
| 40 | + }, |
| 41 | + loading: { |
| 42 | + type: Boolean, |
| 43 | + default: false, |
| 44 | + }, |
| 45 | + disabled: { |
| 46 | + type: Boolean, |
| 47 | + default: false, |
| 48 | + }, |
| 49 | + }, |
| 50 | + emits: ["update:modelValue"], |
| 51 | +}; |
| 52 | +</script> |
| 53 | + |
| 54 | +<style scoped> |
| 55 | +.ai-model-selector { |
| 56 | + width: 100%; |
| 57 | +} |
| 58 | +
|
| 59 | +.form-control { |
| 60 | + width: 100%; |
| 61 | + max-width: 400px; |
| 62 | + padding: 6px 10px; |
| 63 | + border: 1px solid var(--color-border-primary, #e0e0e0); |
| 64 | + border-radius: var(--radius-sm, 4px); |
| 65 | + font-size: var(--font-size-md, 13px); |
| 66 | + background: rgba(255, 255, 255, 0.08); |
| 67 | + transition: all var(--transition-fast, 0.15s ease); |
| 68 | + font-family: inherit; |
| 69 | + color: inherit; |
| 70 | +} |
| 71 | +
|
| 72 | +.form-control:focus { |
| 73 | + outline: none; |
| 74 | + border-color: var(--color-border-focus, #007aff); |
| 75 | + box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2); |
| 76 | +} |
| 77 | +
|
| 78 | +.form-control:disabled { |
| 79 | + background: rgba(255, 255, 255, 0.06); |
| 80 | + color: var(--color-text-tertiary, #999999); |
| 81 | + cursor: not-allowed; |
| 82 | + opacity: 0.6; |
| 83 | +} |
| 84 | +
|
| 85 | +/* Dark mode support */ |
| 86 | +@media (prefers-color-scheme: dark) { |
| 87 | + .form-control { |
| 88 | + background: rgba(255, 255, 255, 0.06); |
| 89 | + color: #ececec; |
| 90 | + border-color: rgba(255, 255, 255, 0.12); |
| 91 | + } |
| 92 | +
|
| 93 | + .form-control::placeholder { |
| 94 | + color: #666666; |
| 95 | + } |
| 96 | +
|
| 97 | + .form-control:hover { |
| 98 | + background: rgba(255, 255, 255, 0.08); |
| 99 | + border-color: rgba(255, 255, 255, 0.18); |
| 100 | + } |
| 101 | +
|
| 102 | + .form-control:focus { |
| 103 | + background: rgba(255, 255, 255, 0.08); |
| 104 | + border-color: #007aff; |
| 105 | + box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.25); |
| 106 | + } |
| 107 | +
|
| 108 | + .form-control:disabled { |
| 109 | + background: rgba(255, 255, 255, 0.02); |
| 110 | + color: #666666; |
| 111 | + } |
| 112 | +
|
| 113 | + select.form-control option { |
| 114 | + background: #1c1c1e; |
| 115 | + color: #ececec; |
| 116 | + } |
| 117 | +} |
| 118 | +</style> |
0 commit comments