2323 @update:model-value =" apiHost = String($event)"
2424 />
2525 <div class =" text-xs text-muted-foreground" >
26- {{
27- t('settings.provider.urlFormat', {
28- defaultUrl: providerWebsites?.defaultBaseUrl || ''
29- })
30- }}
26+ <TooltipProvider v-if =" hasDefaultBaseUrl" :delayDuration =" 200" >
27+ <Tooltip >
28+ <TooltipTrigger as-child >
29+ <button
30+ type =" button"
31+ class =" text-xs text-muted-foreground underline decoration-dotted underline-offset-2 transition-colors hover:text-foreground"
32+ :aria-label =" t('settings.provider.urlFormatFill')"
33+ @click =" fillDefaultBaseUrl"
34+ >
35+ {{
36+ t('settings.provider.urlFormat', {
37+ defaultUrl: defaultBaseUrl
38+ })
39+ }}
40+ </button >
41+ </TooltipTrigger >
42+ <TooltipContent >
43+ {{ t('settings.provider.urlFormatFill') }}
44+ </TooltipContent >
45+ </Tooltip >
46+ </TooltipProvider >
47+ <span v-else >
48+ {{
49+ t('settings.provider.urlFormat', {
50+ defaultUrl: defaultBaseUrl
51+ })
52+ }}
53+ </span >
3154 </div >
3255 </div >
3356
127150</template >
128151
129152<script setup lang="ts">
130- import { onMounted , ref , watch } from ' vue'
153+ import { computed , onMounted , ref , watch } from ' vue'
131154import { useI18n } from ' vue-i18n'
132155import { Label } from ' @shadcn/components/ui/label'
133156import { Input } from ' @shadcn/components/ui/input'
134157import { Button } from ' @shadcn/components/ui/button'
158+ import {
159+ Tooltip ,
160+ TooltipContent ,
161+ TooltipProvider ,
162+ TooltipTrigger
163+ } from ' @shadcn/components/ui/tooltip'
135164import { Icon } from ' @iconify/vue'
136165import GitHubCopilotOAuth from ' ./GitHubCopilotOAuth.vue'
137166import { usePresenter } from ' @/composables/usePresenter'
@@ -169,6 +198,8 @@ const apiHost = ref(props.provider.baseUrl || '')
169198const keyStatus = ref <KeyStatus | null >(null )
170199const isRefreshing = ref (false )
171200const showApiKey = ref (false )
201+ const defaultBaseUrl = computed (() => props .providerWebsites ?.defaultBaseUrl ?.trim () || ' ' )
202+ const hasDefaultBaseUrl = computed (() => defaultBaseUrl .value .length > 0 )
172203
173204watch (
174205 () => props .provider ,
@@ -193,6 +224,12 @@ const handleApiHostChange = (value: string) => {
193224 emit (' api-host-change' , value )
194225}
195226
227+ const fillDefaultBaseUrl = () => {
228+ if (! hasDefaultBaseUrl .value ) return
229+ apiHost .value = defaultBaseUrl .value
230+ handleApiHostChange (defaultBaseUrl .value )
231+ }
232+
196233const handleApiHostBlur = (event : FocusEvent ) => {
197234 const target = event .target as HTMLInputElement | null
198235 if (! target ) return
0 commit comments