22import DirectiveEditor from ' @/views/domain/ngx_conf/directive/DirectiveEditor.vue'
33import LocationEditor from ' @/views/domain/ngx_conf/LocationEditor.vue'
44import {computed , ref } from ' vue'
5- import {useRoute , useRouter } from ' vue-router'
5+ import {useRoute } from ' vue-router'
66import {useGettext } from ' vue3-gettext'
77import Cert from ' @/views/domain/cert/Cert.vue'
88
99const {$gettext} = useGettext ()
1010
11- const {ngx_config, auto_cert, enabled} = defineProps ([' ngx_config' , ' auto_cert' , ' enabled' ])
11+ const props = defineProps ([' ngx_config' , ' auto_cert' , ' enabled' ])
1212
13- const emit = defineEmits ([' callback' ])
13+ const emit = defineEmits ([' callback' , ' update:auto_cert ' ])
1414
1515const route = useRoute ()
1616
@@ -20,13 +20,13 @@ const name = ref(route.params.name)
2020function change_tls(r : any ) {
2121 if (r ) {
2222 // deep copy servers[0] to servers[1]
23- const server = JSON .parse (JSON .stringify (ngx_config .servers [0 ]))
23+ const server = JSON .parse (JSON .stringify (props . ngx_config .servers [0 ]))
2424
25- ngx_config .servers .push (server )
25+ props . ngx_config .servers .push (server )
2626
2727 current_server_index .value = 1
2828
29- const servers = ngx_config .servers
29+ const servers = props . ngx_config .servers
3030
3131 let i = 0
3232 while (i < servers [1 ].directives .length ) {
@@ -67,14 +67,14 @@ function change_tls(r: any) {
6767 } else {
6868 // remove servers[1]
6969 current_server_index .value = 0
70- if (ngx_config .servers .length === 2 ) {
71- ngx_config .servers .splice (1 , 1 )
70+ if (props . ngx_config .servers .length === 2 ) {
71+ props . ngx_config .servers .splice (1 , 1 )
7272 }
7373 }
7474}
7575
7676const current_server_directives = computed (() => {
77- return ngx_config .servers [current_server_index .value ].directives
77+ return props . ngx_config .servers [current_server_index .value ].directives
7878})
7979
8080const directivesMap = computed (() => {
@@ -94,7 +94,7 @@ const directivesMap = computed(() => {
9494
9595
9696const support_ssl = computed (() => {
97- const servers = ngx_config .servers
97+ const servers = props . ngx_config .servers
9898 for (const server_key in servers ) {
9999 for (const k in servers [server_key ].directives ) {
100100 const v = servers [server_key ].directives [k ]
@@ -119,6 +119,15 @@ const current_support_ssl = computed(() => {
119119
120120})
121121
122+ const autoCertRef = computed ({
123+ get() {
124+ return props .auto_cert
125+ },
126+ set(value ) {
127+ emit (' update:auto_cert' , value )
128+ }
129+ })
130+
122131 </script >
123132
124133<template >
@@ -128,15 +137,15 @@ const current_support_ssl = computed(() => {
128137 </a-form-item >
129138
130139 <a-tabs v-model:activeKey =" current_server_index" >
131- <a-tab-pane :tab =" 'Server '+(k+1)" v-for =" (v,k) in ngx_config.servers" :key =" k" >
140+ <a-tab-pane :tab =" 'Server '+(k+1)" v-for =" (v,k) in props. ngx_config.servers" :key =" k" >
132141
133142 <div class =" tab-content" >
134143 <template v-if =" current_support_ssl && enabled " >
135144 <cert
136145 v-if =" current_support_ssl"
137146 :current_server_directives =" current_server_directives"
138147 :directives-map =" directivesMap"
139- v-model:enabled =" auto_cert "
148+ v-model:enabled =" autoCertRef "
140149 @callback =" $emit('callback')"
141150 />
142151 </template >
0 commit comments