112
112
label =" KEY"
113
113
variant =" outlined"
114
114
density =" compact"
115
+ :counter =" 51"
115
116
:append-inner-icon ="
116
117
formData.openaiKey.show ? 'mdi-eye' : 'mdi-eye-off'
117
118
"
132
133
label =" ORGANIZATION"
133
134
variant =" outlined"
134
135
density =" compact"
136
+ :counter =" 28"
135
137
:append-inner-icon ="
136
138
formData.openaiOrganization.show ? 'mdi-eye' : 'mdi-eye-off'
137
139
"
196
198
label =" KEY"
197
199
variant =" outlined"
198
200
density =" compact"
201
+ :counter =" 32"
199
202
:append-inner-icon ="
200
203
formData.azureKey.show ? 'mdi-eye' : 'mdi-eye-off'
201
204
"
280
283
elevation =" 0"
281
284
:block =" true"
282
285
:loading =" PROFILE_STORE.confirmLoading"
283
- :disabled =" PROFILE_STORE.confirmLoading || !isUpdateFormData"
286
+ :disabled ="
287
+ PROFILE_STORE.confirmLoading || !isUpdateFormData || isFormError
288
+ "
284
289
@click =" handleConfirm"
285
290
>
286
291
{{ $t('button.submit') }}
@@ -301,7 +306,8 @@ import { ref, onUnmounted } from 'vue'
301
306
import { watchDeep } from ' @vueuse/core'
302
307
import { useI18n } from ' vue-i18n'
303
308
import { orangeBgColor , greenBgColor } from ' @/utils'
304
- import { useProfileStore } from ' @/store'
309
+ import { useProfileStore , ProfileItem , ProfileKey } from ' @/store'
310
+ import { computed } from ' vue'
305
311
306
312
const { locale } = useI18n ()
307
313
const PROFILE_STORE = useProfileStore ()
@@ -316,12 +322,35 @@ const handleConfirm = async () => {
316
322
await PROFILE_STORE .setProfile ()
317
323
isUpdateFormData .value = false
318
324
}
325
+ const isFormError = computed (() => {
326
+ for (const key in formData ) {
327
+ if (Object .prototype .hasOwnProperty .call (formData , key )) {
328
+ const profileKey = key as ProfileKey
329
+ const element: ProfileItem = formData [profileKey ]
330
+ if (element .error !== undefined && element .error === true ) return true
331
+ }
332
+ }
333
+ return false
334
+ })
319
335
watchDeep (formData , () => {
320
336
isUpdateFormData .value = true
337
+ // Valid openai key length
338
+ if (formData .openaiKey .value && formData .openaiKey .value .length !== 51 )
339
+ formData .openaiKey .error = true
340
+ else formData .openaiKey .error = false
341
+ // Valid openai organization length
342
+ if (
343
+ formData .openaiOrganization .value &&
344
+ formData .openaiOrganization .value .length !== 28
345
+ )
346
+ formData .openaiOrganization .error = true
347
+ else formData .openaiOrganization .error = false
348
+ // Valid azure key length
349
+ if (formData .azureKey .value && formData .azureKey .value .length !== 32 )
350
+ formData .azureKey .error = true
351
+ else formData .azureKey .error = false
321
352
322
- if (formData .notionKey ) {
323
- PROFILE_STORE .profile .notionKey .error = false
324
- }
353
+ if (formData .notionKey ) PROFILE_STORE .profile .notionKey .error = false
325
354
})
326
355
327
356
onUnmounted (() => {
@@ -344,4 +373,7 @@ onUnmounted(() => {
344
373
margin : 0px 5px 0px -5px ;
345
374
padding-right : 13px !important ;
346
375
}
376
+ :deep(.v-counter ) {
377
+ font-size : 10px !important ;
378
+ }
347
379
</style >
0 commit comments