11<script setup lang="ts">
22import {useGettext } from ' vue3-gettext'
3- import {computed , inject , nextTick , provide , reactive , Ref , ref } from ' vue'
3+ import {computed , inject , nextTick , provide , reactive , ref } from ' vue'
44import websocket from ' @/lib/websocket'
55import Modal from ' ant-design-vue/lib/modal'
66import {message } from ' ant-design-vue'
@@ -10,6 +10,8 @@ import AutoCertStepOne from '@/views/domain/cert/components/AutoCertStepOne.vue'
1010
1111const {$gettext, interpolate} = useGettext ()
1212
13+ const emit = defineEmits ([' update:auto_cert' ])
14+
1315const modalVisible = ref (false )
1416
1517const step = ref (1 )
@@ -34,10 +36,10 @@ provide('data', data)
3436
3537const logContainer = ref (null )
3638
37- const save_site_config: Function = inject (' save_site_config' )!
38- const no_server_name: Ref = inject (' no_server_name' )!
39+ const save_site_config = inject (' save_site_config' )!
40+ const no_server_name = inject (' no_server_name' )!
3941const props: any = inject (' props' )!
40- const issuing_cert: Ref < boolean > = inject (' issuing_cert' )!
42+ const issuing_cert = inject (' issuing_cert' )!
4143
4244async function callback(ssl_certificate : string , ssl_certificate_key : string ) {
4345 props .directivesMap [' ssl_certificate' ][0 ][' params' ] = ssl_certificate
@@ -69,19 +71,22 @@ async function onchange(r: boolean) {
6971
7072 v .locations .push (... r .locations )
7173 })
74+ }).then (async () => {
75+ // if ssl_certificate is empty, do not save, just use the config from last step.
76+ if (props .directivesMap [' ssl_certificate' ]?.[0 ]) {
77+ await save_site_config ()
78+ }
79+ job ()
7280 })
73- // if ssl_certificate is empty, do not save, just use the config from last step.
74- if (! props .directivesMap [' ssl_certificate' ]?.[0 ]) {
75- await save_site_config ()
76- }
77- job ()
7881 } else {
7982 await props .ngx_config .servers .forEach ((v : any ) => {
8083 v .locations = v .locations .filter ((l : any ) => l .path !== ' /.well-known/acme-challenge' )
8184 })
8285 save_site_config ()
8386 change_auto_cert (r )
8487 }
88+
89+ emit (' update:auto_cert' , r )
8590}
8691
8792function job() {
0 commit comments