fix(settings/models): keep the model-discovery button visible before an API key is set

This commit is contained in:
matevip 2026-06-30 10:09:04 +08:00
parent fb811b9dc1
commit db11433883
3 changed files with 14 additions and 3 deletions

View File

@ -947,6 +947,7 @@ export default {
discovery: {
discover: 'Discover Models',
discovering: 'Discovering...',
configureFirst: 'Add an API Key under “Configure” first, then discover all of this providers models',
testConnection: 'Test Connection',
testing: 'Testing...',
testModel: 'Test',

View File

@ -809,6 +809,7 @@ export default {
discovery: {
discover: '发现模型',
discovering: '正在发现...',
configureFirst: '请先在「配置」里填入 API Key再发现该供应商的全部模型',
testConnection: '测试连接',
testing: '测试中...',
testModel: '测试',

View File

@ -14,10 +14,16 @@
{{ t('settings.model.manageTitle') }} · {{ provider.name }}
</h2>
<div class="modal-header-actions">
<!-- Always visible when the provider supports discovery, so the entry
point doesn't silently vanish before an API key is set; disabled
with a hint until the provider is configured (discovery hits the
live API and needs the key). -->
<button
v-if="provider.supportModelDiscovery && provider.configured"
v-if="provider.supportModelDiscovery"
class="btn-primary discover-btn"
:disabled="discovering"
:class="{ 'is-discovering': discovering }"
:disabled="discovering || !provider.configured"
:title="!provider.configured ? t('settings.model.discovery.configureFirst') : ''"
@click="$emit('discover')"
>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@ -255,7 +261,10 @@ defineEmits<{
.discover-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 12px; }
.discover-btn svg { flex-shrink: 0; }
.discover-btn:disabled svg { animation: spin 1s linear infinite; }
/* Spin only while actually discovering — not when disabled for a missing key. */
.discover-btn.is-discovering svg { animation: spin 1s linear infinite; }
/* Disabled-for-missing-key state reads as inactive (the discovering state keeps full opacity + spinner). */
.discover-btn:disabled:not(.is-discovering) { opacity: 0.5; cursor: not-allowed; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.discover-panel { margin-bottom: 16px; padding: 14px; border: 1px solid var(--mc-primary-bg); border-radius: 12px; background: var(--mc-primary-bg); }