11<script setup lang="ts">
22import { useGettext } from ' vue3-gettext'
33import { inject } from ' vue'
4- import type { IData } from ' @/views/preference/typedef'
4+ import type { Settings } from ' @/views/preference/typedef'
55
66const { $gettext } = useGettext ()
77
8- const data: IData = inject (' data' )!
8+ const data: Settings = inject (' data' )!
9+ const errors: Record <string , Record <string , string >> = inject (' errors' ) as Record <string , Record <string , string >>
910 </script >
1011
1112<template >
@@ -26,19 +27,37 @@ const data: IData = inject('data')!
2627 </ASelectOption >
2728 </ASelect >
2829 </AFormItem >
29- <AFormItem :label =" $gettext('API Base Url')" >
30+ <AFormItem
31+ :label =" $gettext('API Base Url')"
32+ :validate-status =" errors?.openai?.base_url ? 'error' : ''"
33+ :help =" errors?.openai?.base_url === 'url'
34+ ? $gettext('The url is not valid')
35+ : ''"
36+ >
3037 <AInput
3138 v-model:value =" data.openai.base_url"
3239 :placeholder =" $gettext('Leave blank for the default: https://api.openai.com/')"
3340 />
3441 </AFormItem >
35- <AFormItem :label =" $gettext('API Proxy')" >
42+ <AFormItem
43+ :label =" $gettext('API Proxy')"
44+ :validate-status =" errors?.openai?.proxy ? 'error' : ''"
45+ :help =" errors?.openai?.proxy === 'url'
46+ ? $gettext('The url is not valid')
47+ : ''"
48+ >
3649 <AInput
3750 v-model:value =" data.openai.proxy"
3851 placeholder =" http://127.0.0.1:1087"
3952 />
4053 </AFormItem >
41- <AFormItem :label =" $gettext('API Token')" >
54+ <AFormItem
55+ :label =" $gettext('API Token')"
56+ :validate-status =" errors?.openai?.token ? 'error' : ''"
57+ :help =" errors?.openai?.token === 'alphanumdash'
58+ ? $gettext('Token is not valid')
59+ : ''"
60+ >
4261 <AInputPassword v-model:value =" data.openai.token" />
4362 </AFormItem >
4463 </AForm >
0 commit comments