diff --git a/frontend/src/api/domain.ts b/frontend/src/api/domain.ts index 201ea8b9..6879f3d2 100644 --- a/frontend/src/api/domain.ts +++ b/frontend/src/api/domain.ts @@ -25,6 +25,10 @@ class Domain extends Curd { duplicate(name: string, data: any) { return http.post(this.baseUrl + '/' + name + '/duplicate', data) } + + advance_mode(name: string, data: any) { + return http.post(this.baseUrl + '/' + name + '/advance', data) + } } const domain = new Domain('/domain') diff --git a/frontend/src/views/domain/DomainEdit.vue b/frontend/src/views/domain/DomainEdit.vue index 33d718fe..9fa0d449 100644 --- a/frontend/src/views/domain/DomainEdit.vue +++ b/frontend/src/views/domain/DomainEdit.vue @@ -8,11 +8,10 @@ import {computed, provide, reactive, ref, watch} from 'vue' import {useRoute, useRouter} from 'vue-router' import domain from '@/api/domain' import ngx from '@/api/ngx' -import {message} from 'ant-design-vue' +import {message, Modal} from 'ant-design-vue' import config from '@/api/config' import ChatGPT from '@/components/ChatGPT/ChatGPT.vue' - const {$gettext, interpolate} = useGettext() const route = useRoute() @@ -25,7 +24,7 @@ watch(route, () => { const update = ref(0) -const ngx_config = reactive({ +const ngx_config: any = reactive({ name: '', upstreams: [], servers: [] @@ -57,6 +56,10 @@ const history_chatgpt_record = ref([]) function handle_response(r: any) { + if (r.advanced) { + advance_mode.value = true + } + Object.keys(cert_info_map).forEach(v => { delete cert_info_map[v] }) @@ -95,14 +98,17 @@ function handle_parse_error(r: any) { throw r } -function on_mode_change(advance_mode: boolean) { - if (advance_mode) { - build_config() - } else { - return ngx.tokenize_config(configText.value).then((r: any) => { - Object.assign(ngx_config, r) - }).catch(handle_parse_error) - } +function on_mode_change(advanced: boolean) { + domain.advance_mode(name.value, {advanced}).then(() => { + advance_mode.value = advanced + if (advanced) { + build_config() + } else { + return ngx.tokenize_config(configText.value).then((r: any) => { + Object.assign(ngx_config, r) + }).catch(handle_parse_error) + } + }) } function build_config() { @@ -140,6 +146,7 @@ const save = async () => { } function enable() { + enabled.value = true domain.enable(name.value).then(() => { message.success($gettext('Enabled successfully')) enabled.value = true @@ -149,6 +156,7 @@ function enable() { } function disable() { + enabled.value = false domain.disable(name.value).then(() => { message.success($gettext('Disabled successfully')) enabled.value = false @@ -158,11 +166,18 @@ function disable() { } function on_change_enabled(checked: boolean) { - if (checked) { - enable() - } else { - disable() - } + Modal.confirm({ + title: checked ? $gettext('Do you want to enable this site?') : $gettext('Do you want to disable this site?'), + mask: false, + centered: true, + async onOk() { + if (checked) { + enable() + } else { + disable() + } + } + }) } const editor_md = computed(() => history_chatgpt_record?.value?.length > 1 ? 16 : 24) @@ -187,7 +202,7 @@ provide('save_site_config', save)