Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,28 @@
<Label :for="`${provider.id}-apikey`" class="flex-1 cursor-pointer">{{
t('settings.provider.apiKeyLabel')
}}</Label>
<Input
:id="`${provider.id}-apikey`"
v-model="apiKey"
type="password"
:placeholder="t('settings.provider.keyPlaceholder')"
@blur="handleApiKeyChange(String($event.target.value))"
@keyup.enter="handleApiKeyEnter(apiKey)"
/>
<div class="relative w-full">
<Input
:id="`${provider.id}-apikey`"
v-model="apiKey"
:type="showApiKey ? 'text' : 'password'"
:placeholder="t('settings.provider.keyPlaceholder')"
style="padding-right: 2.5rem !important"
@blur="handleApiKeyChange(String($event.target.value))"
@keyup.enter="handleApiKeyEnter(apiKey)"
/>
<Button
variant="ghost"
size="sm"
class="absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0 hover:bg-transparent"
@click="showApiKey = !showApiKey"
>
<Icon
:icon="showApiKey ? 'lucide:eye-off' : 'lucide:eye'"
class="w-4 h-4 text-muted-foreground hover:text-foreground"
/>
</Button>
</div>
<div class="flex flex-row gap-2">
<Button
variant="outline"
Expand Down Expand Up @@ -357,6 +371,7 @@ const oauthPresenter = usePresenter('oauthPresenter')
const authMethod = ref<'apikey' | 'oauth'>('apikey')
const apiHost = ref(props.provider.baseUrl || '')
const apiKey = ref(props.provider.apiKey || '')
const showApiKey = ref(false)
const showCheckModelDialog = ref(false)
const showModelListDialog = ref(false)
const checkResult = ref<boolean>(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,28 @@

<div class="flex flex-col items-start p-2 gap-2">
<Label :for="`${provider.id}-apikey`" class="flex-1 cursor-pointer">API Key</Label>
<Input
:id="`${provider.id}-apikey`"
v-model="apiKey"
type="password"
:placeholder="t('settings.provider.keyPlaceholder')"
@blur="handleApiKeyChange(String($event.target.value))"
@keyup.enter="handleApiKeyEnter(apiKey)"
/>
<div class="relative w-full">
<Input
:id="`${provider.id}-apikey`"
v-model="apiKey"
:type="showApiKey ? 'text' : 'password'"
:placeholder="t('settings.provider.keyPlaceholder')"
style="padding-right: 2.5rem !important"
@blur="handleApiKeyChange(String($event.target.value))"
@keyup.enter="handleApiKeyEnter(apiKey)"
/>
<Button
variant="ghost"
size="sm"
class="absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0 hover:bg-transparent"
@click="showApiKey = !showApiKey"
>
<Icon
:icon="showApiKey ? 'lucide:eye-off' : 'lucide:eye'"
class="w-4 h-4 text-muted-foreground hover:text-foreground"
/>
</Button>
</div>
<div class="flex flex-row gap-2">
<Button
variant="outline"
Expand Down Expand Up @@ -281,6 +295,7 @@ const settingsStore = useSettingsStore()
const modelCheckStore = useModelCheckStore()
const apiHost = ref(props.provider.baseUrl || '')
const apiKey = ref(props.provider.apiKey || '')
const showApiKey = ref(false)
const showPullModelDialog = ref(false)
const showDeleteModelDialog = ref(false)
const modelToDelete = ref('')
Expand Down
33 changes: 24 additions & 9 deletions src/renderer/src/components/settings/ProviderApiConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,29 @@
<!-- API Key 配置 (GitHub Copilot 时隐藏手动输入) -->
<div v-if="provider.id !== 'github-copilot'" class="flex flex-col items-start gap-2">
<Label :for="`${provider.id}-apikey`" class="flex-1 cursor-pointer">API Key</Label>
<Input
:id="`${provider.id}-apikey`"
:model-value="apiKey"
type="password"
:placeholder="t('settings.provider.keyPlaceholder')"
@blur="handleApiKeyChange($event.target.value)"
@keyup.enter="$emit('validate-key', apiKey)"
@update:model-value="apiKey = String($event)"
/>
<div class="relative w-full">
<Input
:id="`${provider.id}-apikey`"
:model-value="apiKey"
:type="showApiKey ? 'text' : 'password'"
:placeholder="t('settings.provider.keyPlaceholder')"
style="padding-right: 2.5rem !important"
@blur="handleApiKeyChange($event.target.value)"
@keyup.enter="$emit('validate-key', apiKey)"
@update:model-value="apiKey = String($event)"
/>
<Button
variant="ghost"
size="sm"
class="absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0 hover:bg-transparent"
@click="showApiKey = !showApiKey"
>
<Icon
:icon="showApiKey ? 'lucide:eye-off' : 'lucide:eye'"
class="w-4 h-4 text-muted-foreground hover:text-foreground"
/>
</Button>
</div>
<div class="flex flex-row gap-2">
<Button
variant="outline"
Expand Down Expand Up @@ -153,6 +167,7 @@ const apiKey = ref(props.provider.apiKey || '')
const apiHost = ref(props.provider.baseUrl || '')
const keyStatus = ref<KeyStatus | null>(null)
const isRefreshing = ref(false)
const showApiKey = ref(false)

watch(
() => props.provider,
Expand Down
27 changes: 21 additions & 6 deletions src/renderer/src/views/WelcomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const currentStep = ref(0)
const selectedProvider = ref<string>('openai')
const apiKey = ref('')
const baseUrl = ref('')
const showApiKey = ref(false)

const providerModels = computed(() => {
return (
Expand Down Expand Up @@ -293,12 +294,26 @@ const isFirstStep = computed(() => currentStep.value === 0)

<div v-show="selectedProvider !== 'ollama'" class="flex flex-col gap-2">
<Label for="api-key">{{ t('welcome.provider.apiKey') }}</Label>
<Input
id="api-key"
v-model="apiKey"
type="password"
placeholder="Enter API Key"
/>
<div class="relative w-full">
<Input
id="api-key"
v-model="apiKey"
:type="showApiKey ? 'text' : 'password'"
placeholder="Enter API Key"
style="padding-right: 2.5rem !important"
/>
<Button
variant="ghost"
size="sm"
class="absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0 hover:bg-transparent"
@click="showApiKey = !showApiKey"
>
<Icon
:icon="showApiKey ? 'lucide:eye-off' : 'lucide:eye'"
class="w-4 h-4 text-muted-foreground hover:text-foreground"
/>
</Button>
</div>
<div class="text-xs text-muted-foreground">
{{ t('settings.provider.getKeyTip') }}
<a
Expand Down