@@ -166,7 +166,7 @@ import { Icon } from '#components'
166166import { Field , FieldContent , FieldLabel } from ' @/components/ui/field'
167167import { Switch } from ' @/components/ui/switch'
168168import { getBytes } from ' @/utils/functions'
169- import { computed , reactive , ref } from ' vue'
169+ import { computed , reactive , ref , watch } from ' vue'
170170import { useI18n } from ' vue-i18n'
171171import Modal from ' ~/components/modal.vue'
172172import Selector from ' ~/components/selector.vue'
@@ -188,7 +188,7 @@ const submitting = ref(false)
188188
189189const formData = reactive ({
190190 level: ' 1' ,
191- endpoint: ' ' ,
191+ endpoint: ' http:// ' ,
192192 tls: false ,
193193 accesskey: ' ' ,
194194 secrretkey: ' ' ,
@@ -205,6 +205,25 @@ const formData = reactive({
205205 expiredDeleteMark: true ,
206206})
207207
208+ watch (
209+ () => formData .tls ,
210+ val => {
211+ if (val ) {
212+ if (formData .endpoint .startsWith (' http://' )) {
213+ formData .endpoint = formData .endpoint .replace (' http://' , ' https://' )
214+ } else if (! formData .endpoint .startsWith (' https://' )) {
215+ formData .endpoint = ' https://' + formData .endpoint
216+ }
217+ } else {
218+ if (formData .endpoint .startsWith (' https://' )) {
219+ formData .endpoint = formData .endpoint .replace (' https://' , ' http://' )
220+ } else if (! formData .endpoint .startsWith (' http://' )) {
221+ formData .endpoint = ' http://' + formData .endpoint
222+ }
223+ }
224+ }
225+ )
226+
208227const modeOptions = computed (() => [
209228 { label: t (' Asynchronous' ), value: ' async' },
210229 { label: t (' Synchronous' ), value: ' sync' },
@@ -227,7 +246,7 @@ const removeTag = (index: number) => {
227246
228247const resetForm = () => {
229248 formData .level = ' 1'
230- formData .endpoint = ' '
249+ formData .endpoint = ' http:// '
231250 formData .tls = false
232251 formData .accesskey = ' '
233252 formData .secrretkey = ' '
0 commit comments